/* ===== CSS Variables / Design Tokens ===== */
/* Dark Mode (Default) */
:root {
    --primary: #8b5cf6;
    --primary-dark: #7c3aed;
    --secondary: #ec4899;
    --accent: #06b6d4;

    --bg-dark: #0f172a;
    --bg-darker: #020617;
    --card-bg: #1e293b;
    --card-bg-hover: #273549;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --border-color: #334155;
    --border-light: #475569;

    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;

    --gradient-primary: linear-gradient(135deg, var(--primary), var(--secondary));
    --gradient-accent: linear-gradient(135deg, var(--accent), var(--primary));

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 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);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.3);

    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    --navbar-bg: rgba(15, 23, 42, 0.8);
}

/* Light Mode */
[data-theme="light"] {
    --bg-dark: #f8fafc;
    --bg-darker: #e2e8f0;
    --card-bg: #ffffff;
    --card-bg-hover: #f1f5f9;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;

    --border-color: #e2e8f0;
    --border-light: #cbd5e1;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.03);
    --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.15);

    --navbar-bg: rgba(248, 250, 252, 0.9);
}

/* Theme Toggle Button */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: none;
    background: var(--card-bg);
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    border: 1px solid var(--border-color);
}

.theme-toggle:hover {
    background: var(--card-bg-hover);
    color: var(--text-primary);
}

.theme-toggle i {
    font-size: 1rem;
}

.theme-toggle .theme-text-night,
.theme-toggle .ri-moon-line {
    display: inline;
}

.theme-toggle .theme-text-day,
.theme-toggle .ri-sun-line {
    display: none;
}

[data-theme="light"] .theme-toggle .theme-text-day,
[data-theme="light"] .theme-toggle .ri-sun-line {
    display: inline;
}

[data-theme="light"] .theme-toggle .theme-text-night,
[data-theme="light"] .theme-toggle .ri-moon-line {
    display: none;
}

/* Logo Image */
.navbar .logo img {
    height: 36px;
    width: auto;
    object-fit: contain;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    overflow-y: auto;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
}

/* ===== Utility Classes ===== */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

.gradient-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Navbar ===== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--navbar-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

.navbar .logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
}

.navbar .logo i {
    font-size: 1.75rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.navbar .nav-links {
    display: flex;
    gap: 2rem;
}

.navbar .nav-links a {
    color: var(--text-secondary);
    font-weight: 500;
    transition: color var(--transition-fast);
    position: relative;
}

.navbar .nav-links a:hover,
.navbar .nav-links a.active {
    color: var(--text-primary);
}

.navbar .nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gradient-primary);
    border-radius: 1px;
}

/* ===== Hero Section ===== */
.hero-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6rem 2rem 2rem;
    gap: 4rem;
    max-width: 1400px;
    margin: 0 auto;
}

.hero-content {
    flex: 1;
    max-width: 600px;
}

.hero-content h1 {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    letter-spacing: -0.02em;
}

.hero-sub {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.7;
}

.hero-visual {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ===== Book Preview Mockup ===== */
.book-preview-mockup {
    width: 300px;
    height: 400px;
    position: relative;
    perspective: 1000px;
    transform-style: preserve-3d;
}

.book-preview-mockup .page {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    transition: transform var(--transition-slow);
}

.book-preview-mockup .page-left {
    transform: rotateY(-15deg) translateX(-10px);
    z-index: 1;
}

.book-preview-mockup .page-right {
    transform: rotateY(15deg) translateX(10px);
    z-index: 2;
    background: linear-gradient(135deg, #334155 0%, #475569 100%);
}

.book-preview-mockup:hover .page-left {
    transform: rotateY(-25deg) translateX(-20px);
}

.book-preview-mockup:hover .page-right {
    transform: rotateY(25deg) translateX(20px);
}

/* ===== Upload Container ===== */
.upload-container {
    background: var(--card-bg);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-xl);
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.upload-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.upload-container:hover,
.upload-container.drag-over {
    border-color: var(--primary);
    background: var(--card-bg-hover);
}

.upload-container:hover::before,
.upload-container.drag-over::before {
    opacity: 0.05;
}

.upload-content {
    position: relative;
    z-index: 1;
}

.upload-content .icon-circle {
    width: 80px;
    height: 80px;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2rem;
    color: white;
    box-shadow: var(--shadow-glow);
}

.upload-content h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.upload-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.upload-progress {
    position: relative;
    z-index: 1;
}

.upload-progress .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--card-bg-hover);
    border-color: var(--border-light);
}

.btn-copy {
    background: var(--card-bg-hover);
    color: var(--text-primary);
    padding: 0.75rem;
}

.btn-copy:hover {
    background: var(--border-color);
}

/* ===== Upload Settings ===== */
.upload-settings {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.03);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 250px;
    flex: 1;
}

.setting-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 0.5rem;
    height: 24px;
}

.setting-group label i {
    color: var(--primary);
    font-size: 1.1rem;
}

/* Modern Input Fields */
.setting-group input[type="text"],
.setting-group input[type="password"] {
    width: 100%;
    padding: 0.875rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

.setting-group input[type="text"]:focus,
.setting-group input[type="password"]:focus {
    background: rgba(0, 0, 0, 0.3);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
}

.setting-group input::placeholder {
    color: var(--text-muted);
}

/* Password Toggle Container */
.password-toggle-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 0.5rem;
    height: 24px;
}

/* Override label margin inside header since header handles it */
.password-toggle-header label {
    margin-bottom: 0;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background: var(--gradient-primary);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

/* Password Input Animation */
#viewPasswordField {
    animation: slideDown 0.3s ease forwards;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 600px) {
    .upload-settings {
        flex-direction: column;
        gap: 1.5rem;
        padding: 1rem;
        text-align: left;
    }

    .setting-group {
        width: 100%;
        min-width: 0;
    }
}



/* ===== Modal ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal.visible {
    display: flex !important;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    position: relative;
    box-shadow: var(--shadow-xl);
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color var(--transition-fast);
    line-height: 1;
}

.close-modal:hover {
    color: var(--text-primary);
}

.modal-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.modal-header .success-icon {
    font-size: 3rem;
    color: var(--success);
    margin-bottom: 0.5rem;
}

.modal-header h2 {
    font-size: 1.5rem;
}

.modal-body p {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 1.5rem;
}

.link-box {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.link-box input {
    flex: 1;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.link-box input:focus {
    outline: none;
    border-color: var(--primary);
}

.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.action-buttons .btn {
    flex: 1;
}

/* ===== Recent Files Section ===== */
.recent-files {
    margin-top: 3rem;
}

.recent-files h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.file-card {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
}

.file-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

/* ===== Footer ===== */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    margin-top: 2rem;
}

.admin-link {
    cursor: pointer;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: color 0.2s;
}

.admin-link:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* ===== Responsive ===== */
@media (max-width: 968px) {
    .hero-section {
        flex-direction: column;
        text-align: center;
        padding-top: 8rem;
    }

    .hero-content h1 {
        font-size: 2.5rem;
    }

    .hero-visual {
        order: -1;
    }

    .book-preview-mockup {
        width: 200px;
        height: 280px;
    }
}

@media (max-width: 640px) {

    /* Navbar Vertical Stack */
    .navbar {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
        height: auto;
        /* Allow height to grow */
    }

    .navbar .logo {
        font-size: 1.5rem;
        width: 100%;
        justify-content: center;
    }

    .navbar .logo img {
        height: 32px;
    }

    .navbar .nav-links {
        gap: 1.5rem;
        font-size: 1rem;
        width: 100%;
        justify-content: center;
    }

    /* Push content down further because navbar is taller now */
    .page-container {
        padding-top: 11rem !important;
        /* Increased from 7rem */
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .page-header h1 {
        font-size: 1.75rem;
        text-align: center;
    }

    .page-header p {
        text-align: center;
    }

    /* Stack filters on mobile */
    .filters-container {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .search-input-group,
    .date-filter,
    .date-filter input,
    .filters-container .btn {
        width: 100%;
    }

    .date-filter {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    /* Optimize table for mobile - card layout */
    .flipbooks-table {
        border: none;
    }

    .flipbooks-table thead {
        display: none;
        /* Hide header on mobile */
    }

    .flipbooks-table tbody {
        display: block;
    }

    .flipbooks-table tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
        border-radius: 12px;
        padding: 1rem;
        background: var(--card-bg);
    }

    .flipbooks-table td {
        display: block;
        padding: 0.25rem 0;
        border: none;
        text-align: left;
    }

    /* Hide size column on mobile */
    .flipbooks-table td:nth-child(3) {
        display: none;
    }

    .flipbooks-table td:nth-child(2) {
        font-size: 0.85rem;
        color: var(--text-muted);
        margin-bottom: 0.75rem;
    }

    .file-name-cell {
        margin-bottom: 0.25rem;
    }

    .file-name {
        font-weight: 600;
        font-size: 1rem;
        white-space: normal;
        overflow: visible;
        max-width: 100%;
        word-break: break-word;
    }

    /* Action buttons full width on mobile */
    .actions-cell {
        display: flex !important;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-top: 0.5rem;
        width: 100%;
    }

    .actions-cell a,
    .actions-cell button {
        flex: 1;
        min-width: 80px;
        justify-content: center;
    }

    .hero-content h1 {
        font-size: 2rem;
    }

    .hero-sub {
        font-size: 1rem;
    }

    .upload-container {
        padding: 2rem 1.5rem;
    }

    .modal-content {
        padding: 1.5rem;
    }

    .action-buttons {
        flex-direction: column;
    }
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.animate-fade-in {
    animation: fadeIn 0.5s ease forwards;
}

.animate-slide-up {
    animation: slideUp 0.5s ease forwards;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}