* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --secondary-color: #64748b;
    --background: #f8fafc;
    --sidebar-bg: #1e293b;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-light: #cbd5e1;
    --border-color: #e2e8f0;
    --hover-bg: #334155;
    --active-bg: #475569;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Sidebar Styles */
.sidebar {
    width: 320px;
    background: var(--sidebar-bg);
    color: var(--text-light);
    overflow-y: auto;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
}

.nav-menu {
    padding: 1.5rem 0;
    flex: 1;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 2rem;
}

.nav-category {
    font-size: 1.125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    padding: 0.75rem 1.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

.nav-list {
    list-style: none;
}

.nav-list li {
    margin-bottom: 0.25rem;
}

.nav-list a {
    display: block;
    padding: 0.75rem 1.5rem;
    color: var(--text-light);
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    font-size: 0.9375rem;
}

.nav-list a:hover {
    background: var(--hover-bg);
    border-left-color: var(--primary-color);
    padding-left: 1.75rem;
}

.nav-list a.active {
    background: var(--active-bg);
    border-left-color: var(--primary-color);
    color: white;
    font-weight: 500;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
    margin-top: auto;
}

.sidebar-footer p {
    font-size: 0.8125rem;
    color: var(--text-light);
    text-align: center;
    margin: 0;
    opacity: 0.8;
    line-height: 1.5;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 320px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.content-header {
    background: white;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.back-to-home-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: auto;
}

.back-to-home-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.back-to-home-btn:active {
    transform: translateY(0);
}

.back-icon {
    font-size: 1.25rem;
    font-weight: 600;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.menu-toggle span {
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    transition: all 0.3s ease;
}

.content-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.animated-title {
    background: linear-gradient(
        90deg,
        #667eea 0%,
        #764ba2 20%,
        #f093fb 40%,
        #f5576c 60%,
        #4facfe 80%,
        #00f2fe 100%
    );
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: colorShift 4s ease infinite;
    font-weight: 700;
}

@keyframes colorShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* PDF Viewer Container */
.pdf-viewer-container {
    flex: 1;
    position: relative;
    background: #525252;
    overflow: hidden;
}

.welcome-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(-45deg, #1e3a8a, #3b82f6, #6366f1, #8b5cf6, #a855f7, #3b82f6, #1e3a8a);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    opacity: 0.95;
    z-index: 0;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.pdf-viewer {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    position: relative;
    z-index: 1;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: calc(100vh - 73px);
    max-height: calc(100vh - 73px);
    padding: 1rem 2rem;
    position: relative;
    z-index: 1;
    overflow-y: auto;
    box-sizing: border-box;
}

.welcome-content {
    text-align: center;
    max-width: 900px;
    width: 100%;
    position: relative;
    z-index: 2;
}

.book-icon {
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
    display: flex;
    justify-content: center;
    align-items: center;
}

.welcome-image {
    max-width: 180px;
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-20px);
    }
}

.welcome-content h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.75rem;
}

.welcome-content p {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 1.5rem;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-top: 1.5rem;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

.stat-item {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(15px);
    padding: 0.875rem 0.5rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    text-align: center;
    font-family: inherit;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    /* Reset button defaults */
    margin: 0;
    outline: none;
    min-width: 0;
}

.stat-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: 200% 200%;
    animation: statGradient 3s ease infinite;
    opacity: 0.6;
    z-index: 0;
    border-radius: 10px;
}

.stat-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.stat-item:active {
    transform: translateY(-2px);
}

.stat-item * {
    position: relative;
    z-index: 1;
}

/* Animated gradient backgrounds for each button */
.stat-essays::before {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
}

.stat-plays::before {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 50%, #4facfe 100%);
}

.stat-poems::before {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 50%, #43e97b 100%);
}

.stat-stories::before {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 50%, #30cfd0 100%);
}

@keyframes statGradient {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.stat-number {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.2rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    line-height: 1.1;
}

.stat-label {
    display: block;
    font-size: 0.65rem;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    line-height: 1.1;
}

/* Loading Spinner */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: white;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading p {
    font-size: 1.125rem;
    color: rgba(255, 255, 255, 0.9);
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: flex;
    }

    .content-header {
        padding: 1rem 1.5rem;
    }

    .content-header h2 {
        font-size: 1.25rem;
    }

    .back-to-home-btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }

    .back-to-home-btn span:not(.back-icon) {
        display: none;
    }

    .sidebar-header {
        padding: 1.5rem 1rem;
    }

    .sidebar-header h1 {
        font-size: 1.5rem;
    }

    .nav-list a {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    .stats {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.75rem;
        max-width: 100%;
        padding: 0 1rem;
    }

    .stat-item {
        padding: 0.875rem 0.5rem;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.65rem;
    }
}

@media (max-width: 480px) {
    .welcome-content h2 {
        font-size: 1.5rem;
    }

    .welcome-content p {
        font-size: 1rem;
    }

    .book-icon {
        font-size: 4rem;
    }

    .stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .stat-item {
        padding: 1rem 0.75rem;
    }

    .stat-number {
        font-size: 1.75rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }
}

/* Scrollbar Styling */
.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

