/* Global Styles */
:root {
    --bg-color: #f3f6fc;
    --text-main: #1d1f2b;
    --text-muted: #64748b;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --danger: #ef4444;
    --danger-hover: #b91c1c;
    --surface: rgba(255, 255, 255, 0.9);
    --border: rgba(226, 232, 240, 0.8);
    --border-action: #cbd5e1;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-md: 12px;
    --radius-lg: 20px;
    --font-family: 'Inter', system-ui, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, #e0eafc, #cfdef3);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    width: 100%;
}

html {
    overflow-x: hidden;
    width: 100%;
}

/* Base Utility Classes */
.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(79, 70, 229, 0.39);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}

.btn-secondary {
    background-color: white;
    color: var(--text-main);
    border: 1px solid var(--border-action);
}

.btn-secondary:hover {
    background-color: #f8fafc;
    border-color: #94a3b8;
}

/* Layout Container */
.app-container {
    width: 100%;
    max-width: 1200px;
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 100px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 40px;
    border: 1px solid var(--border);
    position: relative;
    z-index: 100;
}

/* Hidden on desktop — shown via mobile media query */
.hamburger {
    display: none;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
}

.logo i {
    font-size: 1.75rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
    /* Reduced gap since each a has padding */
    margin-left: auto;
    /* Push to the right */
}

.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 14px;
    /* Rounded pill */
}

.nav-links a i {
    font-size: 1.25rem;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary);
    background: rgba(79, 70, 229, 0.06);
    transform: translateY(-2px);
}

.nav-dropdown {
    position: relative;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.nav-dropdown-btn {
    color: var(--text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 10px 16px;
    border-radius: 14px;
}

.nav-dropdown:hover .nav-dropdown-btn {
    color: var(--primary);
    background: rgba(79, 70, 229, 0.06);
}

.nav-dropdown-btn i {
    transition: transform 0.3s ease;
}

.nav-dropdown:hover .nav-dropdown-btn i {
    transform: rotate(180deg);
}

.nav-dropdown-content {
    position: absolute;
    top: calc(100% + 15px);
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 380px;
    z-index: 9999;
    pointer-events: none;
}

.nav-dropdown::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    height: 20px;
}

.nav-dropdown:hover .nav-dropdown-content {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.nav-dropdown-content a {
    padding: 12px 16px;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    color: var(--text-main);
}

.nav-dropdown-content a i {
    font-size: 1.25rem;
}

.nav-dropdown-content a:hover,
.nav-dropdown-content a.active {
    background: #f8fafc;
    color: var(--primary);
    transform: translateX(6px);
    box-shadow: var(--shadow-sm);
}

/* Hero Section */
.hero {
    text-align: center;
    margin-bottom: 48px;
}

.hero h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 16px;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--text-main), var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    font-size: 1.125rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Drop Zone Styles */
.upload-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

.drop-zone {
    width: 100%;
    padding: 60px 20px;
    border: 2px dashed #94a3b8;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.drop-zone.drag-active {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
    transform: scale(1.02);
}

.drop-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}

.icon-circle {
    width: 80px;
    height: 80px;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    margin-bottom: 24px;
    box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.5);
}

.drop-content h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.drop-content p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.drop-content .btn-primary {
    pointer-events: auto;
    /* Required so button clicks */
}

/* Workspace (File List & Actions) */
.workspace {
    width: 100%;
    background: white;
    padding: 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    margin-top: 24px;
    position: relative;
    animation: slideUp 0.4s ease forwards;
}

.file-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: transform 0.2s, box-shadow 0.2s;
}

.file-item:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-sm);
    border-color: var(--primary);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
    flex: 1;
}

.file-icon {
    font-size: 1.5rem;
    color: #ef4444;
    /* PDF Red */
    flex-shrink: 0;
}

.file-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.file-name {
    font-weight: 600;
    word-break: break-word;
    padding-right: 8px;
}

.file-size {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.file-controls {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

.icon-btn.delete:hover {
    background: #fee2e2;
    color: var(--danger);
}

/* Custom Controls Form (Select Dropdowns) */
.controls-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 24px;
    padding: 16px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.control-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
}

.control-group label {
    font-weight: 500;
    color: var(--text-main);
    font-size: 0.95rem;
}

/* Custom HTML Dropdown Component */
.custom-dropdown {
    position: relative;
    width: 180px;
    font-family: var(--font-family);
    user-select: none;
}

.dropdown-selected {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background-color: white;
    border: 1px solid var(--border-action);
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-main);
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.dropdown-selected:hover {
    border-color: var(--primary);
}

.dropdown-selected i {
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

/* When the dropdown is open */
.custom-dropdown.open .dropdown-selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.custom-dropdown.open .dropdown-selected i {
    transform: rotate(180deg);
}

.dropdown-options {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    background-color: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.custom-dropdown.open .dropdown-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-option {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-main);
    transition: background-color 0.2s;
}

.dropdown-option:hover {
    background-color: #f1f5f9;
    color: var(--primary);
}

.dropdown-option.selected {
    background-color: #e0e7ff;
    color: var(--primary);
    font-weight: 600;
}

.action-buttons {
    display: flex;
    gap: 16px;
}

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    border-top: 1px solid var(--border);
    padding-top: 24px;
    margin-top: 24px;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Footer */
footer {
    margin-top: auto;
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Split Options Form */
.split-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
    padding: 24px;
    background: #f8fafc;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.range-input-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.range-input {
    padding: 12px 16px;
    border: 1px solid var(--border-action);
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: var(--font-family);
    width: 200px;
    outline: none;
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        padding: 12px;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .navbar {
        padding: 16px 20px;
        position: relative;
        z-index: 1000;
    }

    .hamburger {
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        width: 30px;
        height: 25px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        z-index: 1001;
        /* margin-left: auto; Removed to let it flow naturally */
    }

    .hamburger span {
        width: 30px;
        height: 3px;
        background: var(--text-main);
        border-radius: 10px;
        transition: all 0.3s linear;
        position: relative;
        transform-origin: 1px;
    }

    /* Transform hamburger into X when active */
    .nav-active .hamburger span:nth-child(1) {
        transform: rotate(45deg);
    }

    .nav-active .hamburger span:nth-child(2) {
        opacity: 0;
    }

    .nav-active .hamburger span:nth-child(3) {
        transform: rotate(-45deg);
    }

    .nav-links {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: -100%;
        width: 85%;
        /* slightly wider */
        max-width: 340px;
        height: 100dvh;
        /* use dynamic viewport height for mobile browsers */
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        padding: 80px 20px 20px 20px;
        /* Increased top padding so cards clear the close button */
        box-shadow: -20px 0 40px rgba(0, 0, 0, 0.08);
        border-left: 1px solid rgba(226, 232, 240, 0.5);
        /* Fixed border direction */
        gap: 12px;
        /* Increased gap for nice floating cards */
        z-index: 1000;
        overflow-y: auto;
        border-radius: 24px 0 0 24px;
        /* Fixed border radius direction */

        transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        margin-left: 0;
        /* Reset desktop margin */
    }

    .nav-active .nav-links {
        right: 0;
    }

    .nav-links a,
    .nav-dropdown-content a {
        padding: 14px 16px;
        border-radius: 16px;
        text-align: left;
        font-size: 1rem;
        background: rgba(255, 255, 255, 0.85) !important;
        transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        display: flex;
        align-items: center;
        width: 100%;
        box-sizing: border-box;
        gap: 12px;
        color: var(--text-main) !important;
        font-weight: 500;
        border: 1px solid rgba(0, 0, 0, 0.04) !important;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
    }

    html.dark .nav-links a,
    html.dark .nav-dropdown-content a {
        background: rgba(30, 36, 51, 0.95) !important;
        color: var(--text-main) !important;
        border-color: var(--border) !important;
    }

    .nav-links a i,
    .nav-dropdown-content a i {
        font-size: 1.5rem;
        /* Icon size */
    }

    .nav-links a::before {
        display: none;
    }

    .nav-links a:hover,
    .nav-links a.active,
    .nav-dropdown-content a:hover,
    .nav-dropdown-content a.active {
        background: #ffffff;
        color: var(--primary);
        font-weight: 600;
        border-color: rgba(79, 70, 229, 0.25);
        box-shadow: 0 12px 20px -8px rgba(79, 70, 229, 0.2);
        /* lifted card shadow */
        transform: translateY(-4px) scale(1.02);
        /* floating animation */
    }

    .nav-links a:hover::before,
    .nav-links a.active::before {
        display: none;
    }

    .nav-dropdown-content {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        width: 100%;
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        box-shadow: none;
        border: none;
        padding: 0;
        /* Removed padding */
        grid-template-columns: 1fr;
        margin-top: 0;
        /* Removed top margin */
        pointer-events: auto;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .nav-dropdown::after {
        display: none;
    }

    .nav-dropdown:hover .nav-dropdown-btn i {
        transform: none;
    }

    .nav-dropdown {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }

    .nav-dropdown-btn {
        display: none;
        /* Hide the 'All Tools' button completely on mobile */
    }

    /* Overlay for mobile menu */
    .mobile-menu-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.2);
        backdrop-filter: blur(2px);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .nav-active~.mobile-menu-overlay,
    .nav-active+.mobile-menu-overlay {
        opacity: 1;
        visibility: visible;
    }

    .app-container {
        padding: 12px;
    }

    .file-item {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 12px;
    }

    .file-info {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }

    .file-name {
        max-width: 90vw;
        white-space: normal;
        word-break: break-all;
    }

    .file-controls {
        align-self: center;
        width: 100%;
        justify-content: center;
        padding-top: 8px;
        border-top: 1px solid var(--border);
    }

    .controls-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
    }

    .control-group {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .control-group>div {
        flex-direction: column;
        align-items: flex-start !important;
        width: 100%;
        gap: 4px !important;
    }

    .custom-dropdown,
    .range-input,
    #pages-input {
        width: 100% !important;
    }

    .action-buttons {
        flex-direction: column;
        width: 100%;
    }

    .action-buttons button {
        width: 100%;
        justify-content: center;
    }

    .actions {
        flex-direction: column;
    }

    .range-input-group {
        flex-direction: column;
        align-items: flex-start;
    }

    .range-input-group label {
        margin-bottom: 4px;
        line-height: 1.4;
    }
}

/* ═══════════════════════════════════════════════════
   DARK MODE
═══════════════════════════════════════════════════ */
html.dark {
    --bg-color: #0f1117;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --surface: rgba(22, 25, 37, 0.95);
    --border: rgba(51, 65, 85, 0.8);
    --border-action: #334155;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.4);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}

html.dark body {
    background: linear-gradient(135deg, #0f1117, #1a1f2e);
    color: var(--text-main);
}

html.dark .btn-secondary {
    background: #1e2433;
    color: var(--text-main);
    border-color: var(--border-action);
}

html.dark .btn-secondary:hover {
    background: #252d40;
}

html.dark .navbar {
    background: rgba(15, 17, 23, 0.95);
    border-color: var(--border);
}

html.dark .nav-dropdown-content {
    background: rgba(22, 25, 37, 0.98);
    border-color: var(--border);
}

/* Mobile nav panel in dark mode */
@media (max-width: 768px) {
    html.dark .nav-links {
        background: rgba(15, 17, 23, 0.98) !important;
        border-left-color: var(--border);
    }
}


html.dark .nav-links a {
    color: var(--text-muted);
}

html.dark .nav-links a:hover,
html.dark .nav-links a.active {
    color: var(--primary);
    background: rgba(129, 140, 248, 0.08);
}

html.dark .drop-zone {
    background: rgba(22, 25, 37, 0.6);
    border-color: var(--border-action);
}

html.dark .drop-zone:hover {
    background: rgba(30, 36, 51, 0.8);
}

html.dark .file-item,
html.dark .split-options,
html.dark .file-list {
    background: #1e2433;
    border-color: var(--border);
}

html.dark .custom-dropdown .dropdown-selected,
html.dark .custom-dropdown .dropdown-options {
    background: #1e2433;
    border-color: var(--border);
}

html.dark .dropdown-option:hover,
html.dark .dropdown-option.selected {
    background: rgba(129, 140, 248, 0.1);
    color: var(--primary);
}

html.dark input[type="text"],
html.dark input[type="number"],
html.dark input[type="email"],
html.dark input[type="password"],
html.dark textarea,
html.dark select {
    background: #1e2433;
    color: var(--text-main);
    border-color: var(--border-action);
}

html.dark .range-input {
    background: #1e2433;
    color: var(--text-main);
}

html.dark footer {
    color: var(--text-muted);
}

html.dark footer a {
    color: var(--text-muted);
}

/* Cards in dark mode (inline white backgrounds) */
html.dark [style*="background: white"],
html.dark [style*="background:white"],
html.dark [style*="background:#fff"],
html.dark [style*="background: #f8fafc"],
html.dark [style*="background:#f8fafc"],
html.dark [style*="background: #e2e8f0"],
html.dark [style*="background:#e2e8f0"] {
    background: #1e2433 !important;
    color: var(--text-main);
}

html.dark [style*="color: var(--text-muted)"],
html.dark [style*="color:var(--text-muted)"] {
    color: var(--text-muted) !important;
}

/* ── Homepage tool cards ── */
html.dark .tool-card {
    background: rgba(30, 36, 51, 0.85) !important;
    border-color: var(--border);
    color: var(--text-main);
}

html.dark .tool-card:hover {
    background: #252d40 !important;
    border-color: var(--primary);
}

html.dark .tool-card h3 {
    color: var(--text-main);
}

html.dark .tool-card p {
    color: var(--text-muted);
}

/* ── Upload / drop zone area ── */
html.dark .upload-section {
    background: transparent;
}

/* ── Workspace / split-options ── */
html.dark .workspace {
    background: #1a1f2e;
    border: 1px solid var(--border);
    color: var(--text-main);
}

html.dark .file-item,
html.dark .controls-bar,
html.dark .target-input-wrapper {
    background: #252d40 !important;
    border-color: var(--border) !important;
}

html.dark .file-item:hover {
    background: rgba(129, 140, 248, 0.08);
}

html.dark .dropdown-selected,
html.dark .dropdown-options {
    background-color: #1a1f2e;
    border-color: var(--border);
    color: var(--text-main);
}

html.dark .dropdown-option {
    color: var(--text-main);
}

html.dark .dropdown-option:hover {
    background-color: #252d40;
    color: var(--primary);
}

html.dark .dropdown-option.selected {
    background-color: rgba(79, 70, 229, 0.2);
    color: var(--primary);
}

/* ── Hero text ── */
html.dark .hero h1 {
    color: var(--text-main);
}

html.dark .hero p {
    color: var(--text-muted);
}

/* ── Page-specific card wrappers ── */
html.dark .about-card,
html.dark .policy-card,
html.dark .contact-card,
html.dark .contact-option,
html.dark .reasons-card,
html.dark .faq-item,
html.dark .highlight-box,
html.dark .bookmark-item {
    background: #1e2433 !important;
    border-color: var(--border) !important;
    color: var(--text-main);
}

html.dark .about-card h2,
html.dark .policy-card h2,
html.dark .contact-card h2 {
    color: var(--text-main);
}

html.dark .feature-item {
    background: #252d40 !important;
    border-color: var(--border) !important;
}

html.dark .feature-item strong {
    color: var(--text-main);
}

html.dark .tool-badge {
    background: #252d40 !important;
    border-color: var(--border) !important;
    color: var(--text-muted);
}

html.dark .faq-q span {
    color: var(--text-main);
}

html.dark .faq-a {
    color: var(--text-muted);
    border-color: var(--border);
}

html.dark .faq-category-title {
    color: var(--text-muted);
}

html.dark .contact-option .text-wrap strong {
    color: var(--text-main);
}

html.dark .contact-option .text-wrap span {
    color: var(--text-muted);
}

/* ── Image watermark preview ── */
html.dark #image-preview-wrap>div {
    background: #252d40 !important;
    border-color: var(--border) !important;
}

/* ── Color picker palette ── */
html.dark #color-palette {
    background: #252d40 !important;
    border-color: var(--border) !important;
}

/* ── Loading overlay ── */
html.dark .loading-overlay {
    background: rgba(15, 17, 23, 0.85);
}

/* ── Page thumbnail cards (organize tool) ── */
html.dark .page-card {
    background: #1e2433 !important;
    border-color: var(--border) !important;
}

/* ── Icon circles on upload screens ── */
html.dark .icon-circle {
    filter: brightness(0.85);
}

html.dark .drop-content h2 {
    color: var(--text-main);
}

html.dark .drop-content p {
    color: var(--text-muted);
}


/* ═══════════════════════════════════════════════════
   NAVBAR ACTION BUTTONS (Search + Theme Toggle)
═══════════════════════════════════════════════════ */
.navbar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 12px;
    flex-shrink: 0;
}

.nav-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    transition: background 0.18s, color 0.18s, transform 0.15s;
    flex-shrink: 0;
}

.nav-icon-btn:hover {
    background: rgba(79, 70, 229, 0.08);
    color: var(--primary);
    transform: scale(1.1);
}

html.dark .nav-icon-btn:hover {
    background: rgba(129, 140, 248, 0.1);
    color: var(--primary);
}

/* ═══════════════════════════════════════════════════
   SEARCH MODAL
═══════════════════════════════════════════════════ */
.search-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: flex-start;
    justify-content: center;
    padding-top: clamp(60px, 12vh, 120px);
    padding-inline: 16px;
}

.search-modal.open {
    display: flex;
}

.search-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: fadeIn 0.15s ease;
}

.search-box {
    position: relative;
    width: 100%;
    max-width: 580px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    animation: slideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1;
}

html.dark .search-box {
    background: #1a1f2e;
    border: 1px solid var(--border);
}

.search-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.search-icon-lead {
    font-size: 1.2rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-input-row input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    font-family: var(--font-family);
    background: transparent;
    color: var(--text-main);
    min-width: 0;
}

.search-input-row input::placeholder {
    color: var(--text-muted);
}

.search-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1rem;
    padding: 4px;
    border-radius: 6px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.search-close-btn:hover {
    background: var(--border);
}

.search-results {
    max-height: min(400px, 55vh);
    overflow-y: auto;
    padding: 8px 8px;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-main);
    transition: background 0.15s;
    cursor: pointer;
}

.search-result-item:hover,
.search-result-item:focus {
    background: rgba(79, 70, 229, 0.06);
    outline: none;
}

html.dark .search-result-item:hover,
html.dark .search-result-item:focus {
    background: rgba(129, 140, 248, 0.08);
}

.sri-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.sri-text {
    flex: 1;
    min-width: 0;
}

.sri-text strong {
    font-size: 0.9rem;
    font-weight: 600;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sri-text span {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sri-arrow {
    color: var(--text-muted);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.search-results mark {
    background: rgba(79, 70, 229, 0.15);
    color: var(--primary);
    border-radius: 3px;
    padding: 0 1px;
}

html.dark .search-results mark {
    background: rgba(129, 140, 248, 0.2);
}

.search-footer {
    display: flex;
    gap: 16px;
    padding: 10px 18px;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.search-footer kbd {
    background: var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 0.72rem;
    font-family: monospace;
    margin-right: 3px;
}

html.dark .search-footer kbd {
    background: #2d3748;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-16px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: none;
    }
}