/* =========================================
   1. VARIABLES & THEME
   ========================================= */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;

    --bg: #f3f4f6;
    --card-bg: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;

    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    --input-bg: #ffffff;
    --pdf-brightness: 1.0;

    --header-height: 60px;
    --sidebar-width: 340px;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --input-bg: #0f172a;
    --pdf-brightness: 0.85;
}

/* =========================================
   2. GLOBAL RESET
   ========================================= */
html {
    box-sizing: border-box;
}

*,
*:before,
*:after {
    box-sizing: inherit;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    overflow-y: auto;
}

/* APP MODE (Editor Only) */
body.app-mode {
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #e2e8f0;
}

[data-theme="dark"] body.app-mode {
    background-color: #020617;
}

a {
    text-decoration: none;
    color: var(--primary);
}

/* Standard Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* NEW: Wide Container for Generator */
.container-wide {
    max-width: 96%;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* =========================================
   3. SECTIONS GRID LAYOUT (THE REQUEST)
   ========================================= */
/* Wrapper to hold sections side-by-side */
.sections-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* 2 Columns */
    gap: 1.5rem;
    align-items: start;
    /* Align tops */
}

/* Make sections stack on laptop screens or smaller (prevent breaking) */
@media (max-width: 1100px) {
    .sections-wrapper {
        grid-template-columns: 1fr;
    }
}

/* Section Card */
.accordion-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.accordion-header {
    background: var(--bg);
    padding: 15px 20px;
    cursor: pointer;
    font-weight: 700;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.accordion-body {
    display: none;
    padding: 20px;
    background: var(--card-bg);
}

.accordion-body.open {
    display: block;
}

/* Inside the Section: Stack fields vertically for better space */
.form-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* =========================================
   4. GLOBAL UI COMPONENTS
   ========================================= */
.header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    flex-wrap: wrap;
    gap: 1rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Inputs */
input,
select,
textarea,
.editor-input,
.custom-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--input-bg);
    color: var(--text);
    box-sizing: border-box;
    font-size: 0.9rem;
    transition: 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Custom Select Arrow */
.custom-select,
.lang-select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 0.8em;
    padding-right: 30px;
    cursor: pointer;
}

.lang-select {
    width: auto !important;
    padding: 8px 35px 8px 12px !important;
    font-weight: 600;
}

/* Buttons */
.btn,
.tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary);
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    transition: 0.2s;
    white-space: nowrap;
}

.btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 2px 6px;
    font-size: 0.8rem;
}

.btn-success {
    background-color: var(--success);
}

.btn-danger {
    background-color: var(--danger);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg);
}

.tool-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 14px;
}

.tool-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}


/* =========================================
   MODERN DASHBOARD (CARD GRID) - COMPACT
   ========================================= */
.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

.doc-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.doc-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.06);
    border-color: var(--primary);
}

.doc-visual {
    height: 70px;
    background: linear-gradient(135deg, var(--bg) 0%, var(--border) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: var(--text-muted);
    opacity: 0.7;
}

.doc-card:hover .doc-visual {
    color: var(--primary);
    opacity: 1;
}

.doc-body {
    padding: 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.doc-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    flex: 1;
}

.doc-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.btn-fill {
    width: 100%;
    padding: 6px;
    background: var(--primary);
    color: white;
    border-radius: 5px;
    text-align: center;
    font-weight: 600;
    font-size: 0.8rem;
    display: block;
    border: none;
    cursor: pointer;
}

.btn-fill:hover {
    background: var(--primary-hover);
}

.admin-tools {
    display: flex;
    justify-content: center;
    gap: 4px;
    border-top: 1px dashed var(--border);
    padding-top: 6px;
    margin-top: 6px;
    opacity: 0.6;
    transition: 0.2s;
    flex-wrap: wrap;
}

.doc-card:hover .admin-tools {
    opacity: 1;
}

.card-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 0.6rem;
    font-weight: 800;
    text-transform: uppercase;
    z-index: 2;
    letter-spacing: 0.5px;
}

.bg-free {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.bg-paid {
    background: #e0f2fe;
    color: #075985;
    border: 1px solid #7dd3fc;
}

/* =========================================
   5. EDITOR LAYOUT (APP MODE)
   ========================================= */
.editor-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

.editor-header {
    height: var(--header-height);
    flex-shrink: 0;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 20px;
    z-index: 50;
}

.editor-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.editor-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    margin: 15px 0 15px 15px;
    border-radius: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 40;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.panel-box {
    padding: 20px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg);
}

.editor-canvas {
    flex: 1;
    overflow: auto;
    background: #525659;
    display: flex;
    justify-content: center;
    padding: 40px;
    cursor: crosshair;
}

#pdf-wrapper {
    position: relative;
    background: white;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    filter: brightness(var(--pdf-brightness));
    margin: auto;
}

/* =========================================
   6. EDITOR ITEMS
   ========================================= */
.field-card {
    display: grid;
    grid-template-columns: 24px 1fr auto;
    gap: 10px;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-user-select: none;
    user-select: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.field-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}

.field-card.active {
    background: #eef2ff;
    border-left: 4px solid var(--primary);
    border-color: var(--primary);
}

.field-marker {
    position: absolute;
    z-index: 100;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid var(--primary);
    color: var(--primary);
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    -webkit-user-select: none;
    user-select: none;
    border-radius: 2px;
    white-space: nowrap;
    overflow: visible;
}

.field-marker.selected {
    border: 2px solid var(--warning) !important;
    z-index: 300;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.7);
    color: #b45309;
}

.resizer {
    position: absolute;
    width: 9px;
    height: 9px;
    background: white;
    border: 1px solid var(--warning);
    bottom: -5px;
    right: -5px;
    cursor: se-resize;
    display: none;
    z-index: 400;
}

.field-marker.selected .resizer {
    display: block;
}

.coord-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.coord-input {
    text-align: center;
    font-family: monospace;
    font-weight: 600;
    padding: 6px;
}

/* =========================================
   7. MISC & TABLES
   ========================================= */
.badge-free {
    background: #dcfce7;
    color: #166534;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
}

.badge-paid {
    background: #e0f2fe;
    color: #0369a1;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
}

.pay-option {
    flex: 1;
    border: 1px solid var(--border);
    padding: 15px;
    border-radius: 8px;
    cursor: pointer;
    background: white;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
}

#theme-toggle-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 2px solid var(--border);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 99999 !important;
    transition: transform 0.3s;
}

#theme-toggle-btn:hover {
    transform: scale(1.1);
}

/* =========================================
   8. NEW SIDEBAR LAYOUT
   ========================================= */
.app-layout {
    display: flex;
    min-height: 100vh;
    background: var(--bg);
}

.sidebar {
    width: 280px;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
}

.logo-area {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary);
}

.nav-menu {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    list-style: none;
    margin: 0;
}

.nav-item {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
    color: var(--text);
}

.nav-item:hover {
    background: var(--bg);
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.badge {
    background: var(--bg);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.nav-item.active .badge {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.badge-primary {
    background: var(--primary);
    color: white;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.user-profile {
    padding: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.main-content {
    margin-left: 280px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-wrapper {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-wrapper input {
    width: 100%;
    padding: 0.6rem 0.75rem 0.6rem 2.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text);
}

.controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.icon-btn-group {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.icon-btn {
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: var(--bg);
}

/* =========================================
   RESTORED MISSING STYLES (Modals, Tables, Forms)
   ========================================= */

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text);
}

.form-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.modal-box {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border);
    animation: slideDown 0.2s ease-out;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

th,
td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:hover {
    background: var(--bg);
}

/* Alerts */
.alert-success {
    background: #dcfce7;
    color: #166534;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #86efac;
    margin-bottom: 1rem;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #fca5a5;
    margin-bottom: 1rem;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #fcd34d;
    margin-bottom: 1rem;
}

/* Utilities */
.flex {
    display: flex;
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-end {
    justify-content: flex-end;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--text-muted);
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

/* Admin Grid */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
}

[data-theme='dark'] .glass-input {
    background: rgba(15, 23, 42, 0.8) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: white !important;
}

.glass-input:focus {
    background: var(--card-bg) !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 0 0 2px var(--primary);
    transform: scale(1.01);
}

.doc-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px -5px rgba(99, 102, 241, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-color: var(--primary);
    z-index: 10;
}

.doc-visual {
    transition: all 0.3s ease;
}

/* =========================================
   RESTORED: HERO & ADMIN SECTIONS
   ========================================= */

/* Hero Section */
.hero-section {
    background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
    color: white;
    padding: 4rem 2rem;
    border-radius: 24px;
    margin-bottom: 3rem;
    box-shadow: 0 20px 40px -10px rgba(99, 102, 241, 0.3);
    position: relative;
    overflow: hidden;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 800px;
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0 0 1rem 0;
    line-height: 1.2;
}

.hero-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin: 0 0 2rem 0;
    max-width: 600px;
}

.hero-stats {
    display: flex;
    gap: 2rem;
    margin-top: 2rem;
}

.hero-stat-item {
    background: rgba(255, 255, 255, 0.1);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 140px;
}

.hero-stat-item .counter {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Admin Toolbar */
.admin-toolbar {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.admin-stats {
    display: flex;
    gap: 1.5rem;
}

.admin-stat {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text);
}

.admin-stat-icon {
    width: 40px;
    height: 40px;
    background: #eef2ff;
    color: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

/* Category Navigation */
.category-nav-container {
    position: sticky;
    top: 10px;
    z-index: 90;
    margin-bottom: 2rem;
    background: rgba(255, 255, 255, 0.8);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    padding: 10px;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 20px -5px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .category-nav-container {
    background: rgba(30, 41, 59, 0.8);
}

.category-nav {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 5px;
    scrollbar-width: none;
}

.category-nav::-webkit-scrollbar {
    display: none;
}

.nav-pill {
    padding: 8px 16px;
    background: var(--bg);
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.nav-pill:hover {
    background: var(--card-bg);
    color: var(--primary);
    border-color: var(--border);
}

.nav-pill.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Category Block */
.category-block {
    animation: fadeIn 0.5s ease-out;
}

/* Online Indicator */
.online-indicator {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #10b981;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.7);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .glass-panel {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(255, 255, 255, 0.1);
}

.blink {
    animation: blink 2s infinite;
}

@keyframes blink {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

/* =========================================
   9. MAGIC UPGRADE STYLES
   ========================================= */

/* Theme Toggle Button */
#theme-toggle-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#theme-toggle-btn:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
    border-color: var(--primary);
    color: var(--primary);
}

/* Command Palette (Ctrl+K) */
.cmd-palette-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
    animation: fadeIn 0.2s ease-out;
}

.cmd-palette-modal {
    width: 100%;
    max-width: 600px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    animation: slideDown 0.2s ease-out;
}

.cmd-input-wrapper {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.cmd-input {
    width: 100%;
    background: transparent;
    border: none;
    font-size: 1.1rem;
    color: var(--text);
    outline: none;
}

.cmd-results {
    max-height: 400px;
    overflow-y: auto;
    padding: 8px;
}

.cmd-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    transition: all 0.1s;
}

.cmd-item:hover,
.cmd-item.selected {
    background: var(--primary);
    color: white;
}

.cmd-item .icon {
    font-size: 1.2rem;
    opacity: 0.7;
}

.cmd-item:hover .icon,
.cmd-item.selected .icon {
    opacity: 1;
}

.cmd-shortcut {
    margin-left: auto;
    font-size: 0.75rem;
    opacity: 0.5;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    padding: 6px;
    min-width: 180px;
    z-index: 9998;
    display: none;
    animation: fadeIn 0.1s ease-out;
}

.ctx-item {
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-size: 0.9rem;
    transition: background 0.1s;
}

.ctx-item:hover {
    background: var(--bg);
    color: var(--primary);
}

.ctx-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* Favorites Star */
.fav-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 5;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .fav-btn {
    background: rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.1);
}

.doc-card:hover .fav-btn,
.fav-btn.active {
    opacity: 1;
}

.fav-btn.active {
    color: #f59e0b;
    background: var(--card-bg);
    border-color: #f59e0b;
    box-shadow: 0 2px 5px rgba(245, 158, 11, 0.2);
}

/* Animations */
@keyframes slideDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* =========================================
   10. SCAN AI STYLES
   ========================================= */
.scan-btn {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 30px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    z-index: 10;
}

.scan-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 25px rgba(168, 85, 247, 0.5);
}

.scan-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 60%);
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.3s, transform 0.3s;
}

.scan-btn:active::after {
    opacity: 1;
    transform: scale(1);
    transition: 0s;
}

.scan-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    display: none;
}

.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: #10b981;
    box-shadow: 0 0 15px #10b981, 0 0 30px #10b981;
    opacity: 0.8;
}

.scan-active .doc-card {
    transition: box-shadow 0.2s;
}

.scan-highlight {
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.6) !important;
    border-color: #10b981 !important;
    transform: scale(1.02);
}

.scan-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: rgba(15, 23, 42, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid #334155;
    padding: 2rem;
    border-radius: 16px;
    color: white;
    z-index: 10000;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    min-width: 300px;
}

.scan-modal.active {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.scan-result-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #10b981;
}

.scan-stat {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
}

.scan-stat:last-child {
    border-bottom: none;
}

.scan-stat span:first-child {
    color: #94a3b8;
}

.scan-stat span:last-child {
    font-weight: 700;
    color: #f8fafc;
}

/* =========================================
   9. GLASSMORPHISM SIDEBAR OVERRIDES
   ========================================= */
.sidebar {
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid rgba(255, 255, 255, 0.3) !important;
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.05);
}

[data-theme='dark'] .sidebar {
    background: rgba(30, 41, 59, 0.85) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.logo-area {
    padding: 2rem 1.5rem !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

[data-theme='dark'] .logo-area {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

.nav-menu {
    padding: 1.5rem 1rem !important;
}

.nav-item {
    padding: 1rem 1.2rem !important;
    margin-bottom: 0.8rem !important;
    border-radius: 12px !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    color: var(--text-muted) !important;
    border: 1px solid transparent !important;
    font-weight: 600 !important;
}

.nav-item:hover {
    background: rgba(99, 102, 241, 0.08) !important;
    color: var(--primary) !important;
    transform: translateX(5px);
}

.nav-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    box-shadow: 0 8px 20px rgba(118, 75, 162, 0.4);
    border: none !important;
}

.nav-item span:first-child {
    font-size: 1.2rem;
    margin-right: 12px;
}

.badge {
    background: rgba(0, 0, 0, 0.05) !important;
    padding: 4px 10px !important;
}

.nav-item.active .badge {
    background: rgba(255, 255, 255, 0.25) !important;
    color: white !important;
}

.user-profile {
    padding: 1.5rem !important;
    border-top: 1px solid rgba(0, 0, 0, 0.05) !important;
    background: rgba(0, 0, 0, 0.02) !important;
}

[data-theme='dark'] .user-profile {
    border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
    background: rgba(255, 255, 255, 0.02) !important;
}

/* =========================================
   APP LAYOUT (Sidebar + Main Content)
   ========================================= */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 1.5rem;
    transition: transform 0.3s ease;
}

.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 2rem;
    background: var(--bg);
    min-height: 100vh;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar.active {
        transform: translateX(0);
    }
}

/* Sidebar Elements */
.logo-area {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
}

.nav-item {
    padding: 12px 15px;
    margin-bottom: 5px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--bg);
    color: var(--primary);
}

.nav-item.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

/* --- GLOBAL ADMIN HEADER --- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 1.5rem;
}

.page-title h1 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.025em;
}

.page-title p {
    margin: 5px 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* IMPROVED HEADER LAYOUT */
.editor-header {
    height: auto !important;
    min-height: var(--header-height);
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    padding: 10px 20px !important;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 150px;
}

.header-center {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
    flex: 1;
    min-width: 150px;
}


/* CUSTOM COUNTRY DROPDOWN */
.custom-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-trigger {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    min-width: 140px;
    justify-content: space-between;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 4px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: var(--bg);
}


/* FIX DROPDOWN OVERFLOW & SVG SIZING */
.custom-dropdown svg {
    width: 20px !important;
    height: auto !important;
    display: block;
    flex-shrink: 0;
}

.dropdown-menu {
    width: max-content;
    min-width: 100%;
    overflow: visible !important;
    /* Allow shadow/content to show */
}

.dropdown-item {
    white-space: nowrap;
    padding-right: 20px;
    /* Extra space for aesthetics */
}


/* --- MODALS --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.modal-box {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    transform: translateY(20px);
    animation: slideUp 0.3s ease-out forwards;
}

@keyframes slideUp {
    to {
        transform: translateY(0);
    }
}

/* --- MODAL FIXES --- */
.modal {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    transform: translateY(20px);
    animation: slideUp 0.3s ease-out forwards;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* --- FORM STYLES FOR MODALS --- */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

/* --- TOGGLE BUTTONS --- */
.toggle-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    font-weight: 500;
    color: var(--text);
}

.toggle-btn:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.toggle-btn.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary);
    color: var(--primary);
}

.toggle-btn .toggle-icon {
    margin-left: auto;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s;
}

.toggle-btn.active .toggle-icon {
    opacity: 1;
    transform: scale(1);
}

/* --- SIDEBAR LOGO AREA --- */
.logo-area {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.logo-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    display: inline-block;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.025em;
    margin-bottom: 0.25rem;
}

.logo-subtext {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--primary);
    font-weight: 700;
    opacity: 0.8;
}/ *   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
       9 .   I M P R O V E D   F O R M   L A Y O U T   &   C H E C K B O X E S  
       = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =   * /  
  
 / *   O v e r r i d e   . f o r m - g r i d   t o   u s e   G r i d   L a y o u t   * /  
 . f o r m - g r i d   {  
         d i s p l a y :   g r i d   ! i m p o r t a n t ;  
         g r i d - t e m p l a t e - c o l u m n s :   r e p e a t ( a u t o - f i l l ,   m i n m a x ( 2 8 0 p x ,   1 f r ) ) ;  
         g a p :   1 2 p x ;  
         p a d d i n g :   5 p x ;  
 }  
  
 / *   C o m p a c t   F i e l d   W r a p p e r   * /  
 . f i e l d - w r a p p e r   {  
         m a r g i n - b o t t o m :   0 ;  
         p a d d i n g :   8 p x   1 2 p x ;  
         b a c k g r o u n d :   v a r ( - - b g - s e c o n d a r y ) ;  
         b o r d e r - r a d i u s :   8 p x ;  
         b o r d e r :   1 p x   s o l i d   t r a n s p a r e n t ;  
         t r a n s i t i o n :   a l l   0 . 2 s ;  
 }  
  
 . f i e l d - w r a p p e r : f o c u s - w i t h i n   {  
         b a c k g r o u n d :   v a r ( - - c a r d - b g ) ;  
         b o r d e r - c o l o r :   v a r ( - - p r i m a r y ) ;  
         b o x - s h a d o w :   0   2 p x   8 p x   r g b a ( 0 ,   0 ,   0 ,   0 . 0 5 ) ;  
 }  
  
 . f i e l d - w r a p p e r   l a b e l   {  
         f o n t - s i z e :   0 . 8 5 r e m ;  
         c o l o r :   v a r ( - - t e x t - m u t e d ) ;  
         m a r g i n - b o t t o m :   4 p x ;  
         d i s p l a y :   b l o c k ;  
 }  
  
 . f i e l d - i n p u t   {  
         f o n t - s i z e :   0 . 9 5 r e m ;  
         p a d d i n g :   8 p x   1 0 p x ;  
 }  
  
 / *   C u s t o m   C h e c k b o x   S t y l i n g   * /  
 . f i e l d - w r a p p e r . i s - c h e c k b o x   {  
         g r i d - c o l u m n :   s p a n   1 ;  
         d i s p l a y :   f l e x ;  
         a l i g n - i t e m s :   c e n t e r ;  
         b a c k g r o u n d :   v a r ( - - c a r d - b g ) ;  
         b o r d e r :   1 p x   s o l i d   v a r ( - - b o r d e r ) ;  
         c u r s o r :   p o i n t e r ;  
         p a d d i n g :   0 ;  
 }  
  
 . f i e l d - w r a p p e r . i s - c h e c k b o x   l a b e l   {  
         d i s p l a y :   f l e x ;  
         a l i g n - i t e m s :   c e n t e r ;  
         w i d t h :   1 0 0 % ;  
         h e i g h t :   1 0 0 % ;  
         p a d d i n g :   1 0 p x   1 2 p x ;  
         m a r g i n :   0 ;  
         c u r s o r :   p o i n t e r ;  
         g a p :   1 0 p x ;  
 }  
  
 . f i e l d - w r a p p e r . i s - c h e c k b o x   i n p u t [ t y p e = " c h e c k b o x " ]   {  
         a p p e a r a n c e :   n o n e ;  
         - w e b k i t - a p p e a r a n c e :   n o n e ;  
         w i d t h :   2 0 p x ;  
         h e i g h t :   2 0 p x ;  
         b o r d e r :   2 p x   s o l i d   v a r ( - - t e x t - m u t e d ) ;  
         b o r d e r - r a d i u s :   4 p x ;  
         b a c k g r o u n d :   w h i t e ;  
         p o s i t i o n :   r e l a t i v e ;  
         t r a n s i t i o n :   a l l   0 . 2 s ;  
         f l e x - s h r i n k :   0 ;  
         m a r g i n :   0 ;  
 }  
  
 . f i e l d - w r a p p e r . i s - c h e c k b o x   i n p u t [ t y p e = " c h e c k b o x " ] : c h e c k e d   {  
         b a c k g r o u n d :   v a r ( - - p r i m a r y ) ;  
         b o r d e r - c o l o r :   v a r ( - - p r i m a r y ) ;  
 }  
  
 . f i e l d - w r a p p e r . i s - c h e c k b o x   i n p u t [ t y p e = " c h e c k b o x " ] : c h e c k e d : : a f t e r   {  
         c o n t e n t :   ' “£ ô ' ;  
         p o s i t i o n :   a b s o l u t e ;  
         c o l o r :   w h i t e ;  
         f o n t - s i z e :   1 4 p x ;  
         f o n t - w e i g h t :   b o l d ;  
         l e f t :   5 0 % ;  
         t o p :   5 0 % ;  
         t r a n s f o r m :   t r a n s l a t e ( - 5 0 % ,   - 5 0 % ) ;  
 }  
  
 . f i e l d - w r a p p e r . i s - c h e c k b o x : h o v e r   {  
         b o r d e r - c o l o r :   v a r ( - - p r i m a r y ) ;  
 }  
 