/* Dictation Pro - Complete CSS with 50 Templates */
:root {
    --primary: #6C63FF; --primary-dark: #5A52D5; --primary-gradient: linear-gradient(135deg,#6C63FF,#5A52D5);
    --success: #10b981; --error: #ef4444; --warning: #f59e0b; --info: #3b82f6;
    --bg: #f7fafc; --surface: #fff; --text: #2d3748; --text-muted: #718096;
    --border: #e2e8f0; --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,.1); --shadow-lg: 0 10px 15px rgba(0,0,0,.1);
}
.dark-mode { --bg: #1a202c; --surface: #2d3748; --text: #f7fafc; --text-muted: #a0aec0; --border: #4a5568; }

* { margin:0; padding:0; box-sizing:border-box; }
body { font-family: 'Cairo','Inter',sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; transition: background .3s, color .3s; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

/* Header */
.header { background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-sm); position: sticky; top: 0; z-index: 100; }
.header-inner { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; display: flex; justify-content: space-between; align-items: center; height: 64px; gap: 1rem; }
.logo { display: flex; align-items: center; gap: .75rem; color: var(--text); text-decoration: none; flex-shrink: 0; }
.logo-icon { width: 40px; height: 40px; background: var(--primary-gradient); border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.25rem; }
.logo-text { font-size: 1.125rem; font-weight: 800; }
.header-actions { display: flex; align-items: center; gap: .75rem; flex-shrink: 0; }

/* V21: Main top navigation (Home / Blog / Contact Us) */
.main-nav {
    display: flex;
    align-items: center;
    gap: .25rem;
    flex: 1 1 auto;
    justify-content: center;
}
.nav-link {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem .875rem;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 600;
    transition: all .2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    white-space: nowrap;
}
.nav-link i { font-size: .875rem; }
.nav-link:hover {
    color: var(--primary);
    background: rgba(108,99,255,.08);
    text-decoration: none;
}
.nav-link.active {
    color: var(--primary);
    background: rgba(108,99,255,.12);
}

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .5rem; padding: .5rem 1rem; border: none; border-radius: 8px; font-size: .875rem; font-weight: 600; cursor: pointer; text-decoration: none; transition: all .2s; font-family: inherit; }
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn-primary { background: var(--primary-gradient); color: #fff; }
.btn-primary:hover { box-shadow: 0 4px 12px rgba(108,99,255,.4); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--error); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: .25rem .625rem; font-size: .75rem; }

/* Dark mode toggle */
.theme-toggle { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text); transition: all .2s; }
.theme-toggle:hover { border-color: var(--primary); color: var(--primary); }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: .375rem; color: var(--text); }
.form-control { width: 100%; padding: .625rem .875rem; border: 1px solid var(--border); border-radius: 8px; font-size: .875rem; font-family: inherit; background: var(--surface); color: var(--text); transition: all .15s; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108,99,255,.1); }
.form-select { width: 100%; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: 8px; font-size: .875rem; background: var(--surface); color: var(--text); cursor: pointer; }

/* Editor */
.editor-card { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; border: 1px solid var(--border); display: flex; flex-direction: column; min-height: 700px; }
.editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; padding: .75rem; background: var(--bg); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.editor-toolbar select, .editor-toolbar button { padding: .375rem .625rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; font-size: .875rem; transition: all .15s; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.editor-toolbar button:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.editor-toolbar select:hover { border-color: var(--primary); }
.toolbar-divider { width: 1px; height: 24px; background: var(--border); margin: 0 .25rem; }

/* CRITICAL: Paper area must inherit styles properly */
/* V19 FIX #2: Increased min-height from 400px → 600px and added flex-grow so the paper
   always fills the editor-card. Combined with editor-card's min-height: 700px,
   templates now visually fill the entire editor area instead of leaving white space
   at the top/bottom (the SVG background was previously cropped to a 400px-tall window
   while the SVG itself is 600+px tall, showing only the blank top portion).
   V20 FIX #2: Added height:100% so the paper-area ALWAYS stretches to the full
   available editor-card height (no white space below the paper area either). */
.paper-area {
    flex: 1 1 auto;
    min-height: 600px;
    height: 100%;
    padding: 2.5rem 3rem;
    outline: none;
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    transition: background-color .3s, color .3s;
    font-size: 1.0625rem;
    line-height: 1.85;
    font-family: 'Inter', 'Cairo', sans-serif;
    color: var(--text);
    background-color: var(--surface);
    direction: ltr;
    text-align: left;
    position: relative;  /* V16: for ::before pseudo-element positioning */
    background-origin: padding-box;     /* V19: SVG fills the padding box (so it covers under the text padding) */
    background-clip: padding-box;
}

/* ============================================================
   V20 FIX #2 — Native CSS background generators for tiled templates
   ------------------------------------------------------------
   PROBLEM: The original SVG templates (lined, grid, dotted, etc.) are 800×600
   with blank strips at top (0..60 SVG units) and bottom (570..600). When
   tiled with background-repeat:repeat, those blank strips appeared as visible
   white bands every ~648px (one SVG tile). Half the editor looked "unlined".

   SOLUTION: For tiled patterns (lined, journal, grid, dotted, memo, idea,
   calligraphy, checklist, timeline, staff, course), we now draw the
   background using pure CSS repeating-linear-gradient / radial-gradient that
   fill 100% of the paper-area with NO gaps. The SVG file is still loaded as
   a fallback (so custom template colors keep working) but the CSS background
   is painted on top via a second layer.
   ============================================================ */

/* V20: Tiled line patterns — fill 100% of paper-area, no white gaps */
.paper-area[data-style="lined"],
.paper-area[data-style="journal"] {
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent calc(var(--line-h, 32px) - 1px),
        currentColor calc(var(--line-h, 32px) - 1px),
        currentColor var(--line-h, 32px)
    ) !important;
    background-size: 100% var(--line-h, 32px) !important;
    background-repeat: repeat !important;
    background-position: 0 0 !important;
}

/* V20: Grid pattern — fills 100% of paper-area */
.paper-area[data-style="grid"] {
    background-image:
        linear-gradient(to right,  color-mix(in srgb, currentColor 25%, transparent) 1px, transparent 1px),
        linear-gradient(to bottom, color-mix(in srgb, currentColor 25%, transparent) 1px, transparent 1px) !important;
    background-size: 24px 24px !important;
    background-repeat: repeat !important;
    background-position: 0 0 !important;
}

/* V20: Dotted pattern — fills 100% of paper-area */
.paper-area[data-style="dotted"] {
    background-image: radial-gradient(
        circle,
        color-mix(in srgb, currentColor 45%, transparent) 1px,
        transparent 1.5px
    ) !important;
    background-size: 22px 22px !important;
    background-repeat: repeat !important;
    background-position: 0 0 !important;
}

/* V20: Memo — horizontal ruled lines with a header band */
.paper-area[data-style="memo"] {
    background-image:
        repeating-linear-gradient(to bottom,
            transparent 0,
            transparent calc(var(--line-h, 32px) - 1px),
            color-mix(in srgb, currentColor 35%, transparent) calc(var(--line-h, 32px) - 1px),
            color-mix(in srgb, currentColor 35%, transparent) var(--line-h, 32px)
        ) !important;
    background-size: 100% var(--line-h, 32px) !important;
    background-repeat: repeat !important;
    background-position: 0 0 !important;
}

/* V20: Idea — dotted horizontal guides */
.paper-area[data-style="idea"] {
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent calc(var(--line-h, 32px) - 1px),
        color-mix(in srgb, currentColor 30%, transparent) calc(var(--line-h, 32px) - 1px),
        color-mix(in srgb, currentColor 30%, transparent) var(--line-h, 32px)
    ) !important;
    background-size: 100% var(--line-h, 32px) !important;
    background-repeat: repeat !important;
    background-position: 0 0 !important;
}

/* V20: Calligraphy — double guide lines (baseline + x-height) */
.paper-area[data-style="calligraphy"] {
    background-image:
        repeating-linear-gradient(to bottom,
            transparent 0,
            transparent calc(var(--line-h, 32px) * 0.65),
            color-mix(in srgb, currentColor 25%, transparent) calc(var(--line-h, 32px) * 0.65),
            color-mix(in srgb, currentColor 25%, transparent) calc(var(--line-h, 32px) * 0.70),
            transparent calc(var(--line-h, 32px) * 0.70),
            transparent calc(var(--line-h, 32px) - 1px),
            color-mix(in srgb, currentColor 50%, transparent) calc(var(--line-h, 32px) - 1px),
            color-mix(in srgb, currentColor 50%, transparent) var(--line-h, 32px)
        ) !important;
    background-size: 100% var(--line-h, 32px) !important;
    background-repeat: repeat !important;
    background-position: 0 0 !important;
}

/* V20: Checklist — checkbox guides every line */
.paper-area[data-style="checklist"] {
    background-image:
        /* checkbox outline */
        linear-gradient(to right,
            transparent 0,
            transparent 0px,
            color-mix(in srgb, currentColor 50%, transparent) 0px,
            color-mix(in srgb, currentColor 50%, transparent) 1px,
            transparent 1px,
            transparent 18px,
            color-mix(in srgb, currentColor 50%, transparent) 18px,
            color-mix(in srgb, currentColor 50%, transparent) 19px,
            transparent 19px),
        /* checkbox bottom */
        linear-gradient(to bottom,
            transparent 0,
            transparent 17px,
            color-mix(in srgb, currentColor 50%, transparent) 17px,
            color-mix(in srgb, currentColor 50%, transparent) 18px,
            transparent 18px),
        /* baseline */
        repeating-linear-gradient(to bottom,
            transparent 0,
            transparent calc(var(--line-h, 32px) - 1px),
            color-mix(in srgb, currentColor 35%, transparent) calc(var(--line-h, 32px) - 1px),
            color-mix(in srgb, currentColor 35%, transparent) var(--line-h, 32px)
        ) !important;
    background-size: 100% var(--line-h, 32px) !important;
    background-repeat: repeat !important;
    background-position: 0 0 !important;
}

/* V20: Timeline — vertical guide on the start side + horizontal ticks */
.paper-area[data-style="timeline"] {
    background-image:
        /* vertical line on start side */
        linear-gradient(to right,
            color-mix(in srgb, currentColor 50%, transparent) 0,
            color-mix(in srgb, currentColor 50%, transparent) 1px,
            transparent 1px,
            transparent 100%),
        /* horizontal tick every line-h */
        repeating-linear-gradient(to bottom,
            transparent 0,
            transparent calc(var(--line-h, 32px) - 1px),
            color-mix(in srgb, currentColor 50%, transparent) calc(var(--line-h, 32px) - 1px),
            color-mix(in srgb, currentColor 50%, transparent) calc(var(--line-h, 32px) - 6px),
            transparent calc(var(--line-h, 32px) - 6px),
            transparent var(--line-h, 32px)
        ) !important;
    background-size: 100% var(--line-h, 32px) !important;
    background-repeat: repeat !important;
    background-position: 0 0 !important;
}

/* V20: Staff — 5-line music staves stacked every 5 line-h */
.paper-area[data-style="staff"] {
    background-image:
        repeating-linear-gradient(to bottom,
            transparent 0,
            transparent 0,
            currentColor 0,
            currentColor 1px,
            transparent 1px,
            transparent calc(var(--line-h, 32px) - 1px),
            currentColor calc(var(--line-h, 32px) - 1px),
            currentColor var(--line-h, 32px),
            transparent var(--line-h, 32px),
            transparent calc(var(--line-h, 32px) * 2 - 1px),
            currentColor calc(var(--line-h, 32px) * 2 - 1px),
            currentColor calc(var(--line-h, 32px) * 2),
            transparent calc(var(--line-h, 32px) * 2),
            transparent calc(var(--line-h, 32px) * 3 - 1px),
            currentColor calc(var(--line-h, 32px) * 3 - 1px),
            currentColor calc(var(--line-h, 32px) * 3),
            transparent calc(var(--line-h, 32px) * 3),
            transparent calc(var(--line-h, 32px) * 4 - 1px),
            currentColor calc(var(--line-h, 32px) * 4 - 1px),
            currentColor calc(var(--line-h, 32px) * 4),
            transparent calc(var(--line-h, 32px) * 4),
            transparent calc(var(--line-h, 32px) * 5 - 1px),
            currentColor calc(var(--line-h, 32px) * 5 - 1px),
            currentColor calc(var(--line-h, 32px) * 5),
            transparent calc(var(--line-h, 32px) * 5),
            transparent calc(var(--line-h, 32px) * 7)
        ) !important;
    background-size: 100% calc(var(--line-h, 32px) * 7) !important;
    background-repeat: repeat !important;
    background-position: 0 0 !important;
}

/* V20: Course — sectioned horizontal blocks every 5 lines */
.paper-area[data-style="course"] {
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent calc(var(--line-h, 32px) * 5 - 1px),
        color-mix(in srgb, currentColor 50%, transparent) calc(var(--line-h, 32px) * 5 - 1px),
        color-mix(in srgb, currentColor 50%, transparent) calc(var(--line-h, 32px) * 5)
    ) !important;
    background-size: 100% calc(var(--line-h, 32px) * 5) !important;
    background-repeat: repeat !important;
    background-position: 0 0 !important;
}

/* V16: Vertical margin line for 'lined' templates — auto-flips for RTL.
   The line is drawn as a CSS pseudo-element using `inset-inline-start`
   (logical property) which automatically moves to the RIGHT side when
   the paper-area has dir="rtl". */
.paper-area[data-style="lined"]::before,
.paper-area[data-style="journal"]::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    inset-inline-start: 1.5cm;   /* 1.5cm from the start side (left in LTR, right in RTL) */
    border-inline-start: 2px solid currentColor;
    opacity: 0.4;
    pointer-events: none;
    z-index: 0;
}

/* Ensure text content stays above the pseudo-element */
.paper-area[data-style="lined"] > *,
.paper-area[data-style="journal"] > * {
    position: relative;
    z-index: 1;
}

/* RTL mode (Arabic, Hebrew, Persian, Urdu) */
.paper-area[dir="rtl"],
.paper-area.rtl {
    direction: rtl;
    text-align: right;
    font-family: 'Cairo', 'Tajawal', 'Amiri', sans-serif;
    padding: 2.5rem 3rem;
}

/* Placeholder text */
.paper-area:empty::before {
    content: attr(data-placeholder);
    color: #a0aec0;
    font-style: italic;
    pointer-events: none;
}

/* Focus state — subtle accent border */
.paper-area:focus {
    box-shadow: inset 0 0 0 2px rgba(108,99,255,.12);
    outline: none;
}

/* Recording state — pulsing red */
.paper-area.recording {
    box-shadow: inset 0 0 0 2px rgba(239,68,68,.25);
}

/* Interim transcript (lighter gray italic) */
.paper-area .interim {
    color: #94a3b8;
    font-style: italic;
    opacity: .85;
}

/* Highlight line — for emphasized/quoted text */
.paper-area .highlight-line,
.paper-area blockquote {
    border-inline-start: 4px solid var(--primary);
    padding-inline-start: 1rem;
    margin-block: .5rem;
    color: inherit;
    font-style: normal;
    background: rgba(108,99,255,.04);
    padding-block: .25rem;
    border-radius: 4px;
}

/* Fullscreen editor */
.paper-area.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    min-height: 100vh;
    border-radius: 0;
    max-width: none;
}

/* Preview mode (read-only) */
.paper-area.preview-mode {
    background: var(--bg);
    cursor: default;
    user-select: text;
}

/* Better paragraph spacing inside editor */
.paper-area p {
    margin: 0 0 1em 0;
    line-height: inherit;
}
.paper-area p:last-child { margin-bottom: 0; }

/* Headings inside editor — better hierarchy */
.paper-area h1 { font-size: 1.875rem; font-weight: 800; margin: 1rem 0 .75rem; line-height: 1.3; }
.paper-area h2 { font-size: 1.5rem; font-weight: 700; margin: .875rem 0 .5rem; line-height: 1.35; }
.paper-area h3 { font-size: 1.25rem; font-weight: 700; margin: .75rem 0 .5rem; line-height: 1.4; }
.paper-area h4, .paper-area h5, .paper-area h6 { font-weight: 600; margin: .5rem 0 .25rem; }

/* Lists inside editor */
.paper-area ul, .paper-area ol { margin: .5rem 0; padding-inline-start: 1.75rem; }
.paper-area li { margin: .25rem 0; line-height: inherit; }

/* Code blocks */
.paper-area pre {
    background: #1a202c;
    color: #68d391;
    padding: 1rem;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: .875rem;
    overflow-x: auto;
    margin: .5rem 0;
    direction: ltr;
    text-align: left;
}

/* Tables in editor */
.paper-area table {
    border-collapse: collapse;
    width: 100%;
    margin: .5rem 0;
    border: 1px solid var(--border);
}
.paper-area td, .paper-area th {
    border: 1px solid var(--border);
    padding: .5rem .75rem;
    text-align: start;
}

/* Toolbar buttons — better visual hierarchy */
.editor-toolbar button {
    min-width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .875rem;
}
.editor-toolbar button:active { transform: scale(.95); }

/* Toolbar group separator */
.toolbar-divider {
    width: 1px;
    height: 28px;
    background: var(--border);
    margin: 0 .375rem;
}

/* Status bar — better readability */
.status-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.25rem;
    padding: .625rem 1.25rem;
    background: var(--bg);
    border-top: 1px solid var(--border);
    font-size: .8125rem;
    color: var(--text-muted);
}
.status-item { display: flex; align-items: center; gap: .375rem; }
.status-item i { color: var(--primary); }
.status-divider { width: 1px; height: 16px; background: var(--border); }

/* RTL indicator badge */
.rtl-indicator {
    display: inline-block;
    padding: 2px 8px;
    background: #fef3c7;
    color: #92400e;
    border-radius: 4px;
    font-size: .6875rem;
    font-weight: 600;
    margin-inline-start: .5rem;
}

/* Recording */
.recording { border-color: var(--error) !important; box-shadow: 0 0 0 3px rgba(239,68,68,.2) !important; }
.recording-btn { animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.4); } 50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); } }

/* Template gallery */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .75rem; }
.tpl-card { border: 2px solid var(--border); border-radius: 10px; overflow: hidden; cursor: pointer; transition: all .2s; }
.tpl-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.tpl-card.active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108,99,255,.2); }
.tpl-preview { height: 60px; padding: .5rem; font-size: .75rem; overflow: hidden; }
.tpl-name { padding: .375rem; font-size: .75rem; font-weight: 600; text-align: center; background: var(--surface); color: var(--text); }

/* Admin */
.admin-layout { display: flex; min-height: 100vh; background: var(--bg); }
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #1a202c 0%, #2d3748 100%);
    color: #fff;
    position: fixed;
    top: 0; bottom: 0;
    inset-inline-start: 0;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 2px 0 12px rgba(0,0,0,.1);
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }
.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: .75rem;
}
.sidebar-menu { padding: 1rem 0; }
.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1.5rem;
    color: #cbd5e0;
    text-decoration: none;
    transition: all .2s;
    font-size: .875rem;
    font-weight: 500;
    border-inline-start: 3px solid transparent;
    margin: 2px 0;
}
.sidebar-menu a:hover {
    background: rgba(255,255,255,.06);
    color: #fff;
    text-decoration: none;
    border-inline-start-color: rgba(108,99,255,.4);
}
.sidebar-menu a.active {
    background: linear-gradient(90deg, rgba(108,99,255,.18) 0%, rgba(108,99,255,.08) 100%);
    color: #fff;
    border-inline-start-color: var(--primary);
    font-weight: 600;
}
.sidebar-menu a i { width: 20px; text-align: center; font-size: 1rem; }
.sidebar-divider { height: 1px; background: rgba(255,255,255,.08); margin: .75rem 1rem; }
.admin-content { flex: 1; margin-inline-start: 260px; padding: 2rem; min-height: 100vh; }
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.admin-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0;
    color: var(--text);
}

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--surface); border-radius: 12px; padding: 1.25rem; box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 1rem; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.25rem; flex-shrink: 0; }
.stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-label { font-size: .75rem; color: var(--text-muted); }

/* Tables */
.data-table { width: 100%; background: var(--surface); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-md); }
.data-table table { width: 100%; border-collapse: collapse; }
.data-table th { background: var(--bg); padding: .75rem 1rem; text-align: start; font-size: .75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.data-table td { padding: .75rem 1rem; border-top: 1px solid var(--border); font-size: .875rem; }
.data-table tr:hover { background: var(--bg); }

/* Badges */
.badge { display: inline-block; padding: .25rem .625rem; border-radius: 12px; font-size: .75rem; font-weight: 600; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-purple { background: #e9d5ff; color: #581c87; }

/* Flash */
.flash { padding: .875rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .875rem; }
.flash-success { background: #d1fae5; color: #065f46; }
.flash-error { background: #fee2e2; color: #991b1b; }

/* V23: .upload-zone rules removed — Upload Audio/Video section was deleted from the UI */

/* Tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; overflow-x: auto; }
.tab { padding: .75rem 1.25rem; border: none; background: none; cursor: pointer; font-size: .875rem; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; transition: all .15s; }
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================
   50 TEMPLATES - CSS Classes
   ============================================ */
.tpl-notebook-lined { background:#fff; color:#1a202c; font-family:"Caveat",cursive; font-size:20px; line-height:2.0; background-image:linear-gradient(to bottom,transparent 0%,transparent calc(2em - 1px),#3b82f633 calc(2em - 1px),#3b82f633 2em); background-size:100% 2em; }
.tpl-grid-notebook { background:#fff; color:#1a202c; font-family:"Kalam",cursive; font-size:18px; line-height:1.8; background-image:linear-gradient(to right,#10b98122 1px,transparent 1px),linear-gradient(to bottom,#10b98122 1px,transparent 1px); background-size:20px 20px; }
.tpl-classic-notebook { background:#fffbf0; color:#2d3748; font-family:Georgia,serif; font-size:18px; line-height:1.8; }
.tpl-college-notebook { background:#f0f9ff; color:#0c4a6e; font-family:"Tajawal",sans-serif; font-size:18px; line-height:1.9; background-image:linear-gradient(to bottom,transparent 0%,transparent calc(1.9em - 1px),#0284c733 calc(1.9em - 1px),#0284c733 1.9em); background-size:100% 1.9em; }
.tpl-music-notebook { background:#fff; color:#1a202c; font-family:Georgia,serif; font-size:18px; line-height:1.8; background-image:repeating-linear-gradient(to bottom,transparent 0,transparent 8px,#7c3aed22 8px,#7c3aed22 9px,transparent 9px,transparent 16px,#7c3aed22 16px,#7c3aed22 17px,transparent 17px,transparent 24px,#7c3aed22 24px,#7c3aed22 25px,transparent 25px,transparent 32px,#7c3aed22 32px,#7c3aed22 33px,transparent 33px,transparent 40px,#7c3aed22 40px,#7c3aed22 41px); background-size:100% 40px; }
.tpl-white-paper { background:#fff; color:#000; font-family:Arial,sans-serif; font-size:16px; line-height:1.6; }
.tpl-yellow-paper { background:#fef3c7; color:#451a03; font-family:"Comic Sans MS",cursive; font-size:18px; line-height:1.8; }
.tpl-sepia-paper { background:#f4ecd8; color:#5b4636; font-family:Georgia,serif; font-size:18px; line-height:1.9; }
.tpl-craft-paper { background:#d4a574; color:#3d2817; font-family:"Courier New",monospace; font-size:16px; line-height:1.7; background-image:radial-gradient(rgba(139,69,19,.1) 1px,transparent 1px); background-size:4px 4px; }
.tpl-patchwork-paper { background:#fce7f3; color:#831843; font-family:"Dancing Script",cursive; font-size:18px; line-height:1.9; }
.tpl-dark-mode { background:#1a202c; color:#e2e8f0; font-family:Arial,sans-serif; font-size:18px; line-height:1.8; }
.tpl-neon { background:#0a0a0a; color:#00ff88; font-family:"Courier New",monospace; font-size:18px; line-height:1.8; text-shadow:0 0 5px #00ff88,0 0 10px #00ff88; }
.tpl-glassmorphism { background:rgba(224,231,255,.7); backdrop-filter:blur(10px); color:#1e1b4b; font-family:Arial,sans-serif; font-size:18px; line-height:1.8; border:1px solid rgba(99,102,241,.2); }
.tpl-watercolor { background:linear-gradient(135deg,#fce7f3 0%,#e0e7ff 50%,#fef3c7 100%); color:#831843; font-family:"Sacramento",cursive; font-size:22px; line-height:2.0; }
.tpl-metallic { background:linear-gradient(135deg,#1f2937 0%,#374151 50%,#1f2937 100%); color:#d1d5db; font-family:Georgia,serif; font-size:18px; line-height:1.8; }
.tpl-typewriter { background:#f5f1e8; color:#2d2d2d; font-family:"Courier New",monospace; font-size:14px; line-height:1.6; }
.tpl-crt-screen { background:#0c0c0c; color:#33ff33; font-family:"Courier New",monospace; font-size:16px; line-height:1.5; text-shadow:0 0 2px #33ff33,0 0 5px #33ff3388; }
.tpl-legal-pad { background:#fef9c3; color:#1a202c; font-family:"Times New Roman",serif; font-size:16px; line-height:1.7; background-image:linear-gradient(to bottom,transparent 0%,transparent calc(1.7em - 1px),#dc262633 calc(1.7em - 1px),#dc262633 1.7em); background-size:100% 1.7em; }
.tpl-sticky-notes { background:#fef08a; color:#422006; font-family:"Indie Flower",cursive; font-size:18px; line-height:1.8; box-shadow:2px 2px 8px rgba(0,0,0,.1); }
.tpl-professional { background:#fff; color:#1f2937; font-family:"Trebuchet MS",sans-serif; font-size:16px; line-height:1.7; border-inline-start:4px solid #2563eb; }
/* Nature */
.tpl-forest-green { background:#f0fdf4; color:#14532d; font-family:Georgia,serif; font-size:18px; line-height:1.8; }
.tpl-ocean-blue { background:#f0f9ff; color:#0c4a6e; font-family:Arial,sans-serif; font-size:18px; line-height:1.8; }
.tpl-sunset-orange { background:#fff7ed; color:#7c2d12; font-family:"Trebuchet MS",sans-serif; font-size:18px; line-height:1.8; }
.tpl-lavender { background:#f5f3ff; color:#4c1d95; font-family:Georgia,serif; font-size:18px; line-height:1.8; }
.tpl-mint-green { background:#ecfdf5; color:#064e3b; font-family:Arial,sans-serif; font-size:18px; line-height:1.8; }
/* Artistic */
.tpl-watercolor-splash { background:#fdf2f8; color:#831843; font-family:"Great Vibes",cursive; font-size:24px; line-height:2.0; }
.tpl-oil-painting { background:#451a03; color:#fef3c7; font-family:Georgia,serif; font-size:18px; line-height:1.8; }
.tpl-sketch-paper { background:#fafafa; color:#1a202c; font-family:"Patrick Hand",cursive; font-size:18px; line-height:1.8; background-image:linear-gradient(to right,#73737322 1px,transparent 1px),linear-gradient(to bottom,#73737322 1px,transparent 1px); background-size:20px 20px; }
.tpl-canvas-texture { background:#f5f5dc; color:#2d2d2d; font-family:"Courier New",monospace; font-size:16px; line-height:1.7; }
.tpl-pastel-dream { background:#fce7f3; color:#4a044e; font-family:"Dancing Script",cursive; font-size:20px; line-height:1.9; }
/* Modern */
.tpl-neumorphism { background:#e0e5ec; color:#333; font-family:Arial,sans-serif; font-size:18px; line-height:1.8; box-shadow:inset 5px 5px 10px #b8bcc2,inset -5px -5px 10px #fff; }
.tpl-gradient-flow { background:linear-gradient(135deg,#f0f0f0,#e0e0e0); color:#1a1a2e; font-family:Arial,sans-serif; font-size:18px; line-height:1.8; }
.tpl-cyberpunk { background:#0a0a0a; color:#f0abfc; font-family:"Courier New",monospace; font-size:16px; line-height:1.6; text-shadow:0 0 5px #e879f9; }
.tpl-minimal-dark { background:#18181b; color:#fafafa; font-family:Arial,sans-serif; font-size:18px; line-height:1.8; }
.tpl-frosted-glass { background:rgba(255,255,255,.7); backdrop-filter:blur(15px); color:#1e293b; font-family:Arial,sans-serif; font-size:18px; line-height:1.8; }
/* Classic */
.tpl-vintage-paper { background:#f4ecd8; color:#5b4636; font-family:"Times New Roman",serif; font-size:16px; line-height:1.7; }
.tpl-parchment { background:#f7e4c4; color:#3d2817; font-family:Georgia,serif; font-size:18px; line-height:1.8; }
.tpl-old-book { background:#f5f1e8; color:#2d2d2d; font-family:Georgia,serif; font-size:16px; line-height:1.7; }
.tpl-letter-paper { background:#fff; color:#1a202c; font-family:"Times New Roman",serif; font-size:16px; line-height:1.8; background-image:linear-gradient(to bottom,transparent 0%,transparent calc(1.8em - 1px),#3b82f633 calc(1.8em - 1px),#3b82f633 1.8em); background-size:100% 1.8em; }
.tpl-royal-gold { background:#1a1a1a; color:#fbbf24; font-family:Georgia,serif; font-size:18px; line-height:1.8; text-shadow:0 1px 0 #f59e0b44; }
/* Specialized */
.tpl-coding-dark { background:#1e1e1e; color:#d4d4d4; font-family:"Courier New",monospace; font-size:14px; line-height:1.5; }
.tpl-terminal-green { background:#000; color:#0f0; font-family:"Courier New",monospace; font-size:14px; line-height:1.5; }
.tpl-newspaper { background:#f5f5f5; color:#1a1a1a; font-family:"Times New Roman",serif; font-size:14px; line-height:1.6; }
.tpl-magazine { background:#fff; color:#1a1a1a; font-family:"Trebuchet MS",sans-serif; font-size:16px; line-height:1.7; }
.tpl-storyboard { background:#fff; color:#1a1a1a; font-family:Arial,sans-serif; font-size:16px; line-height:1.7; background-image:linear-gradient(to right,#3b82f622 1px,transparent 1px),linear-gradient(to bottom,#3b82f622 1px,transparent 1px); background-size:20px 20px; }
/* Comfort */
.tpl-warm-yellow { background:#fef9c3; color:#422006; font-family:"Comic Sans MS",cursive; font-size:18px; line-height:1.8; }
.tpl-soft-pink { background:#fce7f3; color:#831843; font-family:"Dancing Script",cursive; font-size:18px; line-height:1.9; }
.tpl-cool-gray { background:#f3f4f6; color:#1f2937; font-family:Arial,sans-serif; font-size:18px; line-height:1.8; }
.tpl-cream-white { background:#fffbeb; color:#451a03; font-family:Georgia,serif; font-size:18px; line-height:1.8; }
.tpl-eye-care { background:#c7edcc; color:#1a202c; font-family:Arial,sans-serif; font-size:18px; line-height:1.8; }

/* ============================================================
   V21: Blog section on homepage (3 cards below templates)
   These rules are scoped to .blog-section so they don't conflict
   with the existing .blog-* rules used on /blog.php.
   ============================================================ */
.blog-section {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}
.blog-section-header {
    text-align: center;
    margin-bottom: 1.25rem;
    position: relative;
}
.blog-section-header h3 {
    font-size: 1.375rem;
    font-weight: 700;
    margin: 0 0 .375rem;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: .5rem;
}
.blog-section-header p {
    color: var(--text-muted);
    font-size: .875rem;
    margin: 0 auto;
    max-width: 520px;
}
.blog-section-viewall {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    color: var(--primary);
    font-size: .8125rem;
    font-weight: 700;
    text-decoration: none;
    margin-top: .625rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    transition: gap .2s;
}
.blog-section-viewall:hover { gap: .625rem; text-decoration: none; }

.blog-section .blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
}

.blog-section .blog-card {
    background: var(--surface);
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
    transition: transform .25s, box-shadow .25s, border-color .25s;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    height: 100%;
}
.blog-section .blog-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 24px rgba(0,0,0,.10);
    border-color: var(--primary);
    text-decoration: none;
}

.blog-section .blog-cover {
    height: 160px;
    width: 100%;
    background-size: cover;
    background-position: center;
    background-color: var(--bg);
    position: relative;
    overflow: hidden;
}
.blog-section .blog-cover-fallback {
    background: linear-gradient(135deg, #6C63FF 0%, #5A52D5 50%, #4F46E5 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,.45);
    font-size: 3rem;
}
.blog-section .blog-category-badge {
    position: absolute;
    top: .75rem;
    inset-inline-start: .75rem;
    background: rgba(255,255,255,.95);
    color: var(--text);
    padding: .2rem .625rem;
    border-radius: 12px;
    font-size: .6875rem;
    font-weight: 700;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.blog-section .blog-body {
    padding: 1rem 1.125rem 1.125rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}
.blog-section .blog-meta {
    display: flex;
    align-items: center;
    gap: .875rem;
    font-size: .75rem;
    color: var(--text-muted);
    margin-bottom: .5rem;
    flex-wrap: wrap;
}
.blog-section .blog-meta-item {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
}
.blog-section .blog-meta i { color: var(--primary); opacity: .8; }
.blog-section .blog-title {
    font-weight: 700;
    font-size: 1.0625rem;
    line-height: 1.4;
    margin: 0 0 .5rem;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color .2s;
}
.blog-section .blog-card:hover .blog-title { color: var(--primary); }
.blog-section .blog-excerpt {
    font-size: .875rem;
    color: var(--text-muted);
    line-height: 1.55;
    margin: 0 0 .875rem;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.blog-section .blog-read-more {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    color: var(--primary);
    font-size: .8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    transition: gap .2s;
}
.blog-section .blog-card:hover .blog-read-more { gap: .625rem; }

.blog-section .blog-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
}
.blog-section .blog-empty i {
    font-size: 2.5rem;
    opacity: .35;
    display: block;
    margin-bottom: .5rem;
}
.blog-section .blog-empty p {
    font-size: .875rem;
    margin: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    [dir="rtl"] .sidebar { transform: translateX(100%); }
    .sidebar.show { transform: translateX(0); }
    .admin-content { margin-inline-start: 0 !important; padding: 1rem; }
    .editor-toolbar button span { display: none; }

    /* V21: Mobile-friendly header — hide nav text, keep icons */
    .nav-link span { display: none; }
    .nav-link { padding: .5rem .625rem; }
    .main-nav { gap: .125rem; }

    /* V21: Mobile-friendly blog section */
    .blog-section .blog-grid { grid-template-columns: 1fr; }
    .blog-section-header h3 { font-size: 1.125rem; }
}

@media (max-width: 480px) {
    .header-inner { padding: 0 .75rem; gap: .5rem; }
    .logo-text { font-size: 1rem; }
    .header-actions .btn-sm { padding: .25rem .5rem; font-size: .6875rem; }
}

/* ============================================================
   V22: Ad slot styling
   ------------------------------------------------------------
   These rules apply to every ad rendered by render_ad() on the
   public-facing pages (top banner, inline, bottom, sidebar).
   The container is a subtle grey box with an "Advertisement"
   label so users can clearly distinguish ad slots from content.
   ============================================================ */
.ad-slot {
    margin: 1.25rem auto;
    padding: .5rem;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 10px;
    text-align: center;
    overflow: hidden;
    max-width: 100%;
    position: relative;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.ad-slot .ad-label {
    display: block;
    font-size: .625rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: .375rem;
    opacity: .75;
    font-weight: 600;
}
.ad-slot .ad-content {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 60px;
}
.ad-slot .ad-content > * {
    max-width: 100%;
}
.ad-slot .ad-content ins.adsbygoogle,
.ad-slot .ad-content iframe,
.ad-slot .ad-content ins {
    display: block;
    margin: 0 auto;
    max-width: 100%;
}

/* Position-specific tweaks */
.ad-slot-top {
    margin-top: 0;
    border-top: none;
}
.ad-slot-bottom {
    margin-bottom: 0;
}
.ad-slot-inline {
    margin: 1.5rem auto;
}
.ad-slot-sidebar {
    margin: 0;
    min-height: 250px;
}

/* Custom ad wrapper */
.ad-custom {
    width: 100%;
    text-align: center;
}

/* Dark mode: subtle contrast for ad slots */
.dark-mode .ad-slot {
    background: rgba(255,255,255,.03);
    border-color: rgba(255,255,255,.15);
}

/* Responsive ad slots */
@media (max-width: 768px) {
    .ad-slot {
        margin: 1rem auto;
        min-height: 70px;
    }
}
@media (max-width: 480px) {
    .ad-slot {
        margin: .75rem auto;
        padding: .375rem;
    }
    .ad-slot .ad-label {
        font-size: .5625rem;
    }
}
