/* =====================================================
   SIMULIZI — ADMIN STYLES
   ===================================================== */
:root {
    --brand: #0f766e;
    --brand-600: #0d9488;
    --brand-50: #f0fdfa;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --bg: #f4f6f8;
    --sidebar: #0b1f1d;
    --sidebar-w: 260px;
    --radius: 16px;
    --story-preview-width: 620px;

    --bs-primary: var(--brand);
    --bs-primary-rgb: 15, 118, 110;
    --bs-body-font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --bs-body-color: var(--ink);
    --bs-link-color: var(--brand);
    --bs-link-color-rgb: 15, 118, 110;
}

body.admin-body { background: var(--bg); font-size: .95rem; }

.btn { font-weight: 600; }
.btn-primary {
    --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: #115e59; --bs-btn-hover-border-color: #115e59;
    --bs-btn-active-bg: #134e4a; --bs-btn-active-border-color: #134e4a;
    --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
}
.btn-outline-primary {
    --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--brand); --bs-btn-active-border-color: var(--brand);
    --bs-btn-disabled-color: var(--brand); --bs-btn-disabled-border-color: var(--brand);
}
.btn-check:checked + .btn-outline-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-whatsapp { background: #25d366; color: #fff; border: 0; }
.btn-whatsapp:hover { background: #1ebe5a; color: #fff; }
.btn-instagram { background: linear-gradient(45deg, #f58529, #dd2a7b 50%, #8134af); color: #fff; border: 0; }
.btn-instagram:hover { color: #fff; filter: brightness(1.08); }
.btn.copied { background: var(--brand) !important; color: #fff !important; border-color: var(--brand) !important; }
.form-control:focus, .form-select:focus { border-color: var(--brand-600); box-shadow: 0 0 0 .25rem rgba(13, 148, 136, .15); }

/* ---------- Sidebar ---------- */
.admin-sidebar {
    background: var(--sidebar);
    color: #cbd5e1;
    width: var(--sidebar-w);
}
@media (min-width: 992px) {
    /* Bootstrap's .offcanvas-lg forces these with !important on desktop */
    .admin-sidebar.offcanvas-lg {
        position: fixed; inset: 0 auto 0 0; z-index: 1030;
        overflow-y: auto; display: flex; flex-direction: column;
        width: var(--sidebar-w) !important;
        background-color: var(--sidebar) !important;
    }
}
@media (max-width: 991.98px) {
    .admin-sidebar { --bs-offcanvas-width: var(--sidebar-w); --bs-offcanvas-bg: var(--sidebar); }
}
.sidebar-brand {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.3rem 1.25rem; border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.sidebar-brand span { color: #fff; font-weight: 800; font-size: 1.2rem; }
.sidebar-brand small { font-weight: 600; font-size: .7rem; color: #5eead4; text-transform: uppercase; letter-spacing: .1em; margin-left: .2rem; }
.sidebar-nav { padding: 1rem .85rem 2rem; }
.sidebar-label {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .12em;
    color: #64748b; font-weight: 700; padding: 1.1rem .75rem .4rem;
}
.sidebar-link {
    display: flex; align-items: center; gap: .8rem;
    padding: .65rem .8rem; margin-bottom: 2px; border-radius: 10px;
    color: #cbd5e1; text-decoration: none; font-weight: 500;
    background: none; border: 0; text-align: left;
    transition: background .15s, color .15s;
}
.sidebar-link i { width: 18px; text-align: center; opacity: .85; }
.sidebar-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-link.active { background: var(--brand); color: #fff; box-shadow: 0 6px 16px -8px rgba(13, 148, 136, .8); }
.sidebar-count {
    margin-left: auto; font-size: .72rem; font-weight: 700;
    background: rgba(255, 255, 255, .08); padding: .15rem .55rem; border-radius: 999px;
}
.sidebar-count.is-alert { background: #f59e0b; color: #1c1917; }
.sidebar-link.active .sidebar-count { background: rgba(255, 255, 255, .22); color: #fff; }
.sidebar-logout { color: #fca5a5; }
.sidebar-logout:hover { background: rgba(239, 68, 68, .12); color: #fecaca; }

/* ---------- Main area ---------- */
@media (min-width: 992px) { .admin-main { margin-left: var(--sidebar-w); } }
.admin-topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: .8rem;
    background: rgba(255, 255, 255, .9); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    padding: .85rem 1.5rem;
}
.admin-page-title { font-size: 1.2rem; font-weight: 800; margin: 0; letter-spacing: -.01em; }
.admin-user { font-weight: 600; color: var(--muted); font-size: .9rem; }
.admin-content { padding: 1.5rem; max-width: 1400px; }

/* Incoming story notifications. */
.admin-notifications { position: relative; flex-shrink: 0; }
.admin-notification-bell { position: relative; width: 40px; height: 40px; padding: 0; }
.admin-notification-count { position: absolute; top: -5px; right: -6px; min-width: 19px; padding: 2px 5px; border-radius: 99px; background: #dc2626; color: #fff; font-size: .65rem; line-height: 1.4; font-weight: 800; }
.admin-notifications [hidden], .admin-message-toast[hidden] { display: none !important; }
.admin-notification-panel { position: absolute; right: 0; top: calc(100% + .75rem); width: min(360px, calc(100vw - 2rem)); max-height: calc(100dvh - 5.5rem); display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; background: var(--bs-body-bg, #fff); box-shadow: 0 12px 35px rgba(15,23,42,.18); overflow: hidden; }
.admin-notification-heading { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1rem .4rem; gap: .7rem; }
.admin-notification-heading button { border: 0; background: transparent; color: var(--brand); font-size: .75rem; padding: .4rem; }
.admin-notification-heading button:disabled { opacity: .4; }
.admin-notification-status { margin: 0; padding: .3rem 1rem .65rem; color: var(--muted); font-size: .78rem; }
.admin-notification-list { list-style: none; margin: 0; padding: 0; min-height: 0; max-height: 350px; overflow-y: auto; }
.admin-notification-list a { display: block; padding: .8rem 1rem; border-top: 1px solid var(--line); color: inherit; text-decoration: none; overflow-wrap: anywhere; }
.admin-notification-list a:hover, .admin-notification-list a:focus-visible { background: rgba(13,148,136,.12); }
.admin-notification-heading, .admin-notification-status, .admin-notification-all { flex-shrink: 0; }
.admin-notification-list strong { display: block; font-size: .82rem; }
.admin-notification-list small { display: block; margin-top: .2rem; color: var(--muted); font-size: .72rem; }
.admin-notification-all { display: block; padding: .85rem 1rem; border-top: 1px solid var(--line); font-size: .8rem; font-weight: 700; color: var(--brand); text-decoration: none; }
.admin-message-toast { position: fixed; right: max(1rem, env(safe-area-inset-right)); bottom: max(1rem, env(safe-area-inset-bottom)); z-index: 1040; display: flex; align-items: flex-start; gap: .85rem; width: min(380px, calc(100vw - 2rem)); padding: 1rem; border: 1px solid #99f6e4; border-left: 5px solid var(--brand); border-radius: 14px; background: var(--bs-body-bg, #fff); box-shadow: 0 8px 32px rgba(15,23,42,.2); }
.admin-message-toast > i { color: var(--brand); font-size: 1.5rem; padding-top: .2rem; }
.admin-message-toast strong { font-size: .9rem; }
.admin-message-toast p { margin: .3rem 0; color: var(--muted); font-size: .8rem; }
.admin-message-toast a { color: var(--brand); font-weight: 700; font-size: .8rem; }
.admin-message-toast button { margin-left: auto; border: 0; background: transparent; color: var(--muted); min-width: 30px; min-height: 30px; }
[data-theme="dark"] .admin-notification-panel, [data-theme="dark"] .admin-message-toast { --brand: #5eead4; --line: #2f4742; --muted: #a6bdb9; color: #e7f5f2; background: #10211e; }
@media (max-width: 767.98px) {
    .admin-notifications { position: static; }
    .admin-notification-panel { left: .75rem; right: .75rem; width: auto; }
    .admin-page-title { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
}

.admin-card {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.4rem; box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.admin-card-header {
    display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    margin-bottom: 1rem;
}
.admin-card-header h2 { font-size: 1rem; font-weight: 700; margin: 0; }

/* Image template gallery */
.image-theme-form fieldset { min-width: 0; }
.image-theme-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 1.25rem; }
.image-theme-option { min-width: 0; }
.image-theme-card { display: block; height: 100%; overflow: hidden; border: 2px solid var(--line); border-radius: var(--radius); background: var(--bs-body-bg, #fff); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.image-theme-card:hover { border-color: var(--brand-600); }
.image-theme-choice:checked + .image-theme-card { border-color: var(--brand-600); box-shadow: 0 0 0 3px rgba(13,148,136,.16); }
.image-theme-choice:focus-visible + .image-theme-card { outline: 3px solid var(--brand-600); outline-offset: 4px; }
.image-theme-preview { display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; }
.image-theme-info { display: grid; gap: .4rem; padding: 1rem; }
.image-theme-check { visibility: hidden; color: var(--brand-600); }
.image-theme-choice:checked + .image-theme-card .image-theme-check { visibility: visible; }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat-card {
    position: relative; overflow: hidden;
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.3rem 1.4rem; text-decoration: none; color: var(--ink);
    transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 12px 24px -14px rgba(15, 23, 42, .3); color: var(--ink); }
.stat-icon {
    width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
    font-size: 1.1rem; margin-bottom: .9rem;
}
.stat-value { font-size: 2rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.stat-label { color: var(--muted); font-weight: 600; font-size: .85rem; margin-top: .35rem; text-transform: uppercase; letter-spacing: .04em; }
.stat-all .stat-icon       { background: #e0f2fe; color: #0369a1; }
.stat-pending .stat-icon   { background: #fef3c7; color: #b45309; }
.stat-published .stat-icon { background: #dcfce7; color: #15803d; }
.stat-hidden .stat-icon    { background: #f1f5f9; color: #475569; }
.stat-rejected .stat-icon  { background: #fee2e2; color: #b91c1c; }

.quick-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.quick-link {
    display: flex; flex-direction: column; align-items: center; gap: .4rem;
    padding: .9rem .5rem; border: 1px solid var(--line); border-radius: 12px;
    text-decoration: none; color: var(--ink); font-size: .82rem; font-weight: 600; text-align: center;
}
.quick-link i { color: var(--brand); font-size: 1.1rem; }
.quick-link:hover { background: var(--brand-50); border-color: #99f6e4; color: var(--ink); }

/* ---------- Tables / lists ---------- */
.stories-table thead th {
    font-size: .72rem; letter-spacing: .07em; color: var(--muted); font-weight: 700;
    background: #f8fafc; border-bottom-width: 1px; white-space: nowrap;
}
.stories-table .title-cell { max-width: 380px; min-width: 220px; }
.status-badge { font-weight: 600; font-size: .75rem; padding: .4em .7em; }
.story-actions { display: inline-flex; flex-wrap: wrap; gap: .3rem; justify-content: flex-end; }
.story-actions .btn-sm { padding: .3rem .55rem; }
.story-action-label { margin-left: .25rem; }
.admin-story-footer .story-action-label { margin-left: 0; }
.admin-story-list { display: grid; gap: 1rem; }
.story-batch { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; scroll-margin-top: 90px; }
.story-batch-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.15rem 1.25rem; background: var(--brand-50); border-bottom: 1px solid var(--line); }
.story-batch-number { color: var(--brand); font-weight: 800; font-size: .72rem; letter-spacing: .09em; margin-bottom: .3rem; }
.story-batch-header h2 { margin: 0; font-size: 1.15rem; font-weight: 800; overflow-wrap: anywhere; }
.story-batch-header { flex-wrap: wrap; }
.story-batch-header > div { flex: 1 1 180px; min-width: 0; }
.story-batch-record + .story-batch-record { border-top: 1px solid var(--line); }
.story-batch-record-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; padding: 1rem 1.25rem 0; color: var(--muted); font-size: .8rem; }
.story-batch-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 1.25rem; padding: 1rem 1.25rem 1.25rem; }
.story-picture { min-width: 0; max-width: 440px; width: 100%; }
.story-slider-track { display: flex; align-items: flex-start; gap: 1rem; position: relative; max-width: 520px; margin-inline: auto; padding: 1rem 1.25rem; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scroll-padding-inline: 1.25rem; scrollbar-width: thin; }
.story-slider-track > .story-picture { flex: 0 0 100%; max-width: none; scroll-snap-align: start; scroll-snap-stop: always; }
.admin-story-list .story-slider-track { max-width: calc(var(--story-preview-width) + 2rem); padding: 1rem; scroll-padding-inline: 1rem; }
.story-slider-track:focus-visible { outline: 2px solid var(--brand-600); outline-offset: -2px; border-radius: 12px; }
.story-slide-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .8rem; color: var(--muted); font-size: .75rem; }
.story-slide-actions { margin-top: .8rem; border: 1px solid var(--line); border-radius: 10px; padding: .75rem; }
.story-slider-controls { display: flex; justify-content: space-between; align-items: center; gap: .5rem; max-width: 520px; margin-inline: auto; padding: .5rem 1.25rem 1.25rem; }
.story-slider-controls[hidden] { display: none; }
.story-slider-counter { color: var(--muted); font-size: .8rem; font-weight: 700; text-align: center; }
.story-picture-label { font-size: .8rem; font-weight: 800; color: var(--muted); margin-bottom: .55rem; }
.story-picture-pages { display: grid; gap: 1rem; }
.story-picture-frame[hidden] { display: none !important; }
.story-picture-visual { position: relative; }
.all-stories-controls { display: none !important; }
.story-picture-link { display: block; border-radius: 12px; overflow: hidden; box-shadow: 0 6px 18px rgba(0,0,0,.1); transition: transform .15s; }
.story-picture-link:hover { transform: translateY(-3px); }
.story-picture-visual .story-picture-link:hover { transform: none; }
.story-picture-visual .story-picture-link { border-radius: inherit; box-shadow: none; }
.story-picture-link:focus-visible { outline: 3px solid var(--brand-600); outline-offset: 4px; }
.story-picture-link canvas { display: block; width: 100%; height: auto; cursor: pointer; }
.story-picture-fallback { display: flex; flex-direction: column; gap: 1.5rem; padding: 1.75rem; background: linear-gradient(135deg, #0b3734, #0f766e); color: #fff; border-radius: 12px; text-decoration: none; overflow-wrap: anywhere; }
.story-picture-fallback:hover { color: #fff; }
.story-picture-fallback strong { font-size: 1.25rem; }
.story-picture-fallback span { white-space: pre-wrap; font-family: 'Lora', Georgia, serif; line-height: 1.8; text-align: justify; text-align-last: left; }
.story-picture-fallback.is-untitled span { text-align: center; text-align-last: center; }
.admin-story-item { min-width: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.admin-story-body { padding: 1.15rem 1.25rem; }
.admin-story-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.admin-story-title { min-width: 0; flex: 1 1 220px; margin: 0; font-size: 1.05rem; font-weight: 800; line-height: 1.5; overflow-wrap: anywhere; }
.admin-story-title a { color: var(--ink); text-decoration: none; }
.admin-story-title a:hover { color: var(--brand); text-decoration: underline; }
.admin-story-meta { display: flex; flex-wrap: wrap; gap: .35rem 1rem; margin: .45rem 0 .85rem; color: var(--muted); font-size: .78rem; }
.admin-story-excerpt { margin: 0; line-height: 1.8; overflow-wrap: anywhere; }
.admin-story-footer { padding: .85rem 1.25rem; border-top: 1px solid var(--line); background: var(--brand-50); }
.admin-story-footer .story-actions { display: flex; justify-content: flex-start; gap: .5rem; }
.admin-story-footer .btn-sm { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 36px; padding: .4rem .8rem; }
.admin-story-footer a[title="Edit"] { color: #fff; background: var(--brand); border-color: var(--brand); }
.admin-story-footer a[title="Edit"]:hover { background: #115e59; border-color: #115e59; }
.admin-story-footer [data-bs-target="#deleteModal"] { margin-left: auto; }
.status-tabs { gap: .35rem; flex-wrap: nowrap; overflow-x: auto; padding-bottom: .2rem; }
.status-tabs .nav-link { color: var(--muted); font-weight: 600; border-radius: 999px; padding: .4rem .9rem; white-space: nowrap; }
.status-tabs .nav-link .badge { background: #e2e8f0; color: #334155; }
.status-tabs .nav-link.active { background: var(--brand); color: #fff; }
.status-tabs .nav-link.active .badge { background: rgba(255, 255, 255, .25); color: #fff; }
.pagination { --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); --bs-pagination-color: var(--brand); }
.min-w-0 { min-width: 0; }

/* ---------- View story ---------- */
.field-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: var(--muted); margin-bottom: .3rem; }
.story-view-title { font-size: 1.4rem; font-weight: 800; letter-spacing: -.01em; }
.story-view-body { font-family: 'Lora', Georgia, serif; font-size: 1.05rem; line-height: 1.85; color: #1e293b; }
.story-view-body p { margin-bottom: 1rem; }
.edited-card { border-left: 4px solid #0ea5e9; }
.info-list { display: grid; grid-template-columns: auto 1fr; gap: .55rem 1rem; }
.info-list dt { color: var(--muted); font-weight: 600; }
.info-list dd { margin: 0; text-align: right; }

/* ---------- Editor ---------- */
.picture-editor-card { top: 90px; }
.picture-font-control { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; padding: .65rem .8rem; margin-bottom: .75rem; border: 1px solid var(--line); border-radius: 12px; background: var(--bs-body-bg, #fff); font-size: .8rem; font-weight: 600; }
.picture-font-control label { margin: 0; }
.picture-font-control select { flex: 1; width: auto; min-width: 130px; }
.picture-font-control input { flex: 1 1 100px; min-width: 80px; min-height: 44px; accent-color: var(--brand); }
.picture-font-control output { min-width: 3.5em; text-align: right; font-variant-numeric: tabular-nums; }
#pictureEditLayout.picture-only > .picture-preview-column { width: 100%; order: 0 !important; }
.picture-only .picture-editor-card { max-width: var(--story-preview-width); margin-inline: auto; padding: 0; border: 0; box-shadow: none; background: transparent; position: static !important; }
.picture-only .picture-editor-copy { display: none; }
.picture-tools-column[hidden], #pictureExternalHeading[hidden], #pictureOriginalPanel[hidden], #pictureEditingStatus[hidden] { display: none !important; }
.picture-inline-actions { position: absolute; z-index: 2; top: .55rem; right: .55rem; display: flex; gap: .3rem; }
.picture-inline-actions button, .picture-inline-navigation button { width: 32px; height: 32px; display: inline-grid; place-items: center; border: 1px solid rgba(255,255,255,.3); border-radius: 8px; color: #fff; background: rgba(11,55,52,.88); }
.picture-inline-actions button:hover, .picture-inline-navigation button:hover { background: #0f766e; }
.picture-inline-actions button:disabled, .picture-inline-navigation button:disabled { opacity: .4; }
.picture-download-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin-top: .75rem; }
.picture-download-actions .btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 46px; padding: .6rem .45rem; border-radius: 12px; font-size: .78rem; }
.picture-download-actions .btn:focus-visible { outline: 3px solid var(--brand-600); outline-offset: 3px; }
@media (max-width: 359.98px) {
    .picture-download-actions { gap: .35rem; }
    .picture-download-actions .btn { gap: .25rem; padding-inline: .25rem; font-size: .7rem; }
}
.picture-inline-navigation { position: absolute; z-index: 2; inset: auto .55rem .55rem; color: #fff; font-size: .75rem; pointer-events: none; }
.picture-inline-navigation > * { pointer-events: auto; }
.picture-inline-navigation span { background: rgba(11,55,52,.88); padding: .25rem .6rem; border-radius: 99px; }
.picture-story-navigation { position: absolute; z-index: 3; top: 50%; left: .5rem; right: .5rem; display: flex; justify-content: space-between; align-items: center; transform: translateY(-50%); pointer-events: none; }
.picture-story-navigation[hidden] { display: none; }
.picture-story-navigation button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid rgba(255,255,255,.5); border-radius: 50%; background: rgba(15,23,42,.8); color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.2); cursor: pointer; pointer-events: auto; }
.picture-story-navigation button:hover { background: #0f766e; }
.picture-story-navigation button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.picture-story-navigation button:disabled { opacity: .3; cursor: default; }
@media (min-width: 900px) {
    #pictureEditLayout.picture-only.picture-tools-open > .picture-tools-column, #pictureEditLayout.picture-only.picture-tools-open > .picture-preview-column { width: 50%; }
    #pictureEditLayout.picture-only.picture-tools-open > .picture-preview-column { order: 1 !important; }
}
.editor-workspace-track { max-width: none; padding: 0; scroll-padding-inline: 0; overflow-y: hidden; }
.editor-workspace-slide { flex: 0 0 100%; min-width: 0; scroll-snap-align: start; scroll-snap-stop: always; padding-bottom: .5rem; }
.editor-workspace-controls { display: none !important; }
.story-editor-frame { display: block; width: 100%; height: 1100px; border: 0; background: var(--bg); }
.editor-frame-body { margin: 0; overflow-x: hidden; }
.editor-frame-content { padding: 1rem; }
.editor-frame-content .picture-editor-card { position: static !important; }
@media (min-width: 900px) {
    .editor-frame-content > .row > .col-xl-6 { width: 50%; }
    .editor-frame-content > .row > .order-first { order: 1 !important; }
}
.picture-editor-stage { position: relative; width: 100%; overflow: hidden; border-radius: 12px; background: #0b3734; }
.picture-editor-stage canvas { display: block; width: 100%; height: auto; cursor: text; }
.picture-editor-stage [hidden] { display: none; }
.picture-text-editor { position: absolute; z-index: 1; margin: 0; padding: 0; resize: none; border: 1px dashed #99f6e4; border-radius: 4px; outline: none; color: #fff; background: rgba(11,55,52,.2); overflow-wrap: anywhere; white-space: pre-wrap; }
.picture-text-editor:focus { box-shadow: 0 0 0 2px rgba(153,246,228,.3); }
.picture-editor-navigation { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.picture-editor-navigation[hidden] { display: none; }
.editor-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: .4rem;
    padding: .6rem; background: #f8fafc; border: 1px solid var(--line);
    border-bottom: 0; border-radius: 12px 12px 0 0;
}
.toolbar-sep { width: 1px; height: 24px; background: var(--line); margin: 0 .2rem; }
.find-hide { border-left: 1px solid var(--line); border-right: 1px solid var(--line); padding: .5rem .6rem; background: #f8fafc; }
.find-hide .form-control, .find-hide .input-group-text, .find-hide .btn { border-radius: 8px !important; }
.find-hide > * + * { margin-left: .3rem !important; }
textarea.editor-textarea {
    min-height: 480px; border-radius: 0 0 12px 12px !important; resize: vertical;
    font-family: 'Lora', Georgia, serif; font-size: 1.05rem; line-height: 1.8; padding: 1rem;
}
.original-preview {
    white-space: pre-wrap; max-height: 60vh; overflow-y: auto;
    font-family: 'Lora', Georgia, serif; font-size: .92rem; line-height: 1.7; color: #475569;
    background: #f8fafc; border: 1px dashed var(--line); border-radius: 10px; padding: .9rem;
}

/* ---------- Settings ---------- */
.preset-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.preset-grid .btn { min-width: 84px; }
.preview-counter { display: flex; align-items: center; gap: .6rem; background: var(--brand-50); border: 1px solid #99f6e4; padding: .8rem 1rem; border-radius: 10px; }

/* ---------- Social media ---------- */
.theme-swatches { display: flex; gap: .5rem; flex-wrap: wrap; }
.swatch { width: 40px; height: 40px; border-radius: 10px; border: 0; cursor: pointer; outline-offset: 3px; }
.swatch.active { outline: 3px solid var(--brand); }
.canvas-stage {
    background: repeating-conic-gradient(#f1f5f9 0% 25%, #fff 0% 50%) 50% / 20px 20px;
    border: 1px solid var(--line); border-radius: 12px; padding: 1rem;
    display: flex; justify-content: center;
}
.canvas-stage canvas { max-width: 100%; max-height: 640px; height: auto; width: auto; border-radius: 6px; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .35); }

/* ---------- Modal ---------- */
.delete-icon {
    width: 64px; height: 64px; margin: 0 auto; border-radius: 50%;
    display: grid; place-items: center; font-size: 1.5rem; background: #fee2e2; color: #dc2626;
}
.modal-content { border: 0; border-radius: 18px; }

/* ---------- Login ---------- */
.login-body {
    min-height: 100vh;
    background:
        radial-gradient(600px 300px at 10% 0%, rgba(20, 184, 166, .25), transparent 70%),
        radial-gradient(500px 300px at 100% 100%, rgba(245, 158, 11, .18), transparent 70%),
        #0b1f1d;
}
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-card {
    width: 100%; max-width: 420px; background: #fff; border-radius: 22px;
    padding: 2.25rem; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .5);
}

@media (max-width: 575.98px) {
    .admin-content { padding: 1rem; }
    .admin-card { padding: 1.1rem; }
    .admin-topbar { padding: .7rem 1rem; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-grid .stat-card:first-child { grid-column: span 2; }
    textarea.editor-textarea { min-height: 55vh; }
    .admin-story-body { padding: 1rem; }
    .story-batch-header { padding: 1rem; }
    .story-batch-grid { padding: 1rem; }
    .story-batch-record-meta { padding: 1rem 1rem 0; }
    .admin-story-footer { padding: .8rem 1rem; }
    .story-actions, .admin-story-footer .story-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; gap: .4rem; }
    .story-actions > * { min-width: 0; }
    .story-actions .story-action-label { display: none; }
    .story-actions .btn-sm, .admin-story-footer .story-actions .btn-sm { display: inline-flex; align-items: center; justify-content: center; width: 100%; min-height: 44px; padding: .4rem; font-size: 1rem; }
    .admin-story-list .story-slide-actions { padding: .65rem .5rem; }
    .admin-story-list .story-actions { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .3rem; }
    .admin-story-list .story-actions .btn-sm { padding-inline: .2rem; }
    .admin-story-footer [data-bs-target="#deleteModal"] { margin-left: 0; }
}

/* =====================================================
   THEME TOGGLE + DARK THEME (admin)
   ===================================================== */
.theme-toggle {
    width: 36px; height: 36px; border-radius: 50%;
    display: grid; place-items: center; font-size: .95rem;
    border: 1px solid var(--line); background: transparent; color: var(--ink);
    transition: transform .35s cubic-bezier(.2, 1.4, .4, 1);
}
.theme-toggle:hover { color: var(--brand); }
.theme-toggle:active { transform: rotate(-30deg) scale(.9); }
.theme-toggle .fa-sun { color: #fbbf24; }

[data-theme="dark"] {
    color-scheme: dark;
    --ink: #e6f1ef;
    --muted: #94a8a5;
    --line: #24302f;
    --bg: #0b1211;
    --brand-50: rgba(45, 212, 191, .1);
    --bs-body-bg: var(--bg);
    --bs-link-color: #2dd4bf;
    --bs-link-color-rgb: 45, 212, 191;
}
[data-theme="dark"] .admin-topbar { background: rgba(11, 18, 17, .88); }
[data-theme="dark"] .story-batch-number { color: #5eead4; }
[data-theme="dark"] .admin-card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .login-card,
[data-theme="dark"] .send-box { background: #121b1a; }
[data-theme="dark"] .stat-card:hover,
[data-theme="dark"] .quick-link:hover { color: var(--ink); }
[data-theme="dark"] .quick-link { color: var(--ink); }
[data-theme="dark"] .stories-table thead th,
[data-theme="dark"] .editor-toolbar,
[data-theme="dark"] .find-hide,
[data-theme="dark"] .original-preview { background: #0f1716; }
[data-theme="dark"] .status-tabs .nav-link .badge { background: #24302f; color: #cbd5e1; }
[data-theme="dark"] .story-view-body,
[data-theme="dark"] .original-preview { color: #cdd9d7; }
[data-theme="dark"] .canvas-stage { background: repeating-conic-gradient(#16201f 0% 25%, #0f1716 0% 50%) 50% / 20px 20px; }
[data-theme="dark"] .preview-counter { border-color: rgba(45, 212, 191, .3); }
[data-theme="dark"] .text-dark { color: var(--ink) !important; }
[data-theme="dark"] .btn-light { --bs-btn-bg: #1a2524; --bs-btn-border-color: #24302f; --bs-btn-color: var(--ink); --bs-btn-hover-bg: #22302e; --bs-btn-hover-color: #fff; }
[data-theme="dark"] .stat-all .stat-icon       { background: rgba(14, 165, 233, .15); color: #7dd3fc; }
[data-theme="dark"] .stat-pending .stat-icon   { background: rgba(245, 158, 11, .15); color: #fcd34d; }
[data-theme="dark"] .stat-published .stat-icon { background: rgba(34, 197, 94, .15); color: #86efac; }
[data-theme="dark"] .stat-hidden .stat-icon    { background: rgba(148, 163, 184, .15); color: #cbd5e1; }
[data-theme="dark"] .stat-rejected .stat-icon  { background: rgba(239, 68, 68, .15); color: #fca5a5; }
[data-theme="dark"] .delete-icon { background: rgba(239, 68, 68, .15); }

/* ---------- Admin slots ---------- */
.slot-list { display: grid; gap: .8rem; }
.slot {
    display: flex; align-items: center; gap: 1rem;
    padding: 1rem 1.1rem; border-radius: 14px; border: 1px solid var(--line);
}
.slot.is-free { border-style: dashed; opacity: .85; }
.slot-icon {
    width: 46px; height: 46px; border-radius: 12px; flex: 0 0 46px;
    display: grid; place-items: center; font-size: 1.15rem;
}
.slot.is-used .slot-icon { background: var(--brand-50); color: var(--brand); }
.slot.is-free .slot-icon { background: rgba(148, 163, 184, .15); color: var(--muted); }
