/* ================================================================
   SMART-HEAD Backoffice — Custom Styles
================================================================ */

:root {
    --primary:      #0f8b6c;
    --primary-light:#e8f5f1;
    --sidebar-bg:   #1a1e23;
    --sidebar-w:    240px;
    --topnav-h:     56px;
    --content-bg:   #f4f6f8;
    --card-shadow:  0 1px 4px rgba(0,0,0,.07), 0 0 0 1px rgba(0,0,0,.04);
}

/* ---- BASE ---- */
*, *::before, *::after { box-sizing: border-box; }
body { background: var(--content-bg); font-family: 'Inter', system-ui, sans-serif; font-size: 0.9rem; color: #212529; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: #0a6b53; }

/* ---- LAYOUT ---- */
.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w); background: var(--sidebar-bg);
    display: flex; flex-direction: column; overflow: visible; z-index: 1000;
}
.main-wrapper { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topnav {
    position: sticky; top: 0; z-index: 900; background: #fff;
    border-bottom: 1px solid #e2e8f0; padding: 0 1.5rem;
    height: var(--topnav-h); flex-shrink: 0;
}
.content-area { padding: 1.5rem; flex: 1; }

/* ---- SIDEBAR BRAND ---- */
.sidebar-brand { padding: 1.1rem 1rem; border-bottom: 1px solid rgba(255,255,255,.07); flex-shrink: 0; }
.sidebar-logo { max-width: 148px; height: auto; display: block; filter: brightness(0) invert(1); }
.brand-icon {
    width: 34px; height: 34px; background: var(--primary); border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.05rem; flex-shrink: 0;
}
.brand-name { color: #fff; font-size: 0.9rem; font-weight: 700; line-height: 1.1; }
.brand-sub  { color: rgba(255,255,255,.38); font-size: 0.65rem; }

/* ---- SIDEBAR NAV ---- */
.sidebar-nav {
    flex: 1; padding: 0.5rem 0;
    overflow-y: auto; min-height: 0;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.1) transparent;
}
.sidebar-section {
    font-size: 0.62rem; letter-spacing: .1em; text-transform: uppercase;
    color: rgba(255,255,255,.3); padding: .75rem 1rem .25rem; font-weight: 600;
}
.sidebar-nav .nav-link {
    color: rgba(255,255,255,.65); padding: .45rem 1rem;
    display: flex; align-items: center; gap: .6rem;
    border-radius: 0; font-size: 0.84rem; transition: all .15s;
    white-space: nowrap;
}
.sidebar-nav .nav-link:hover  { color: #fff; background: rgba(255,255,255,.07); }
.sidebar-nav .nav-link.active { color: #fff; background: var(--primary); }
.sidebar-nav .nav-link .bi   { font-size: .95rem; flex-shrink: 0; }
.sidebar-nav .nav-link span  { flex: 1; }

/* ---- SIDEBAR FOOTER ---- */
.sidebar-footer {
    padding: .875rem 1rem; border-top: 1px solid rgba(255,255,255,.07);
    display: flex; align-items: center; gap: .625rem; flex-shrink: 0;
    position: relative; cursor: pointer; user-select: none;
    transition: background .15s;
}
.sidebar-footer:hover { background: rgba(255,255,255,.05); }
.user-name { color: #fff; font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: rgba(255,255,255,.4); font-size: .65rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu-chevron {
    font-size: .65rem; color: rgba(255,255,255,.3); flex-shrink: 0;
    transition: transform .2s;
}

/* ---- USER POPUP MENU ---- */
.user-popup {
    position: absolute; bottom: calc(100% + 4px); left: 0; right: 0;
    background: #252a31; border: 1px solid rgba(255,255,255,.12);
    border-radius: 10px; padding: .375rem 0;
    box-shadow: 0 -8px 28px rgba(0,0,0,.35);
    z-index: 1050; display: none;
    animation: slideUp .15s ease;
}
.user-popup.open { display: block; }
@keyframes slideUp {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.user-popup-header {
    padding: .6rem 1rem .5rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    margin-bottom: .25rem;
}
.user-popup-header .fw-600 { color: #fff; font-size: .82rem; }
.user-popup-sub { color: rgba(255,255,255,.4); font-size: .68rem; margin-top: 1px; }
.user-popup-divider { height: 1px; background: rgba(255,255,255,.07); margin: .25rem 0; }
.user-popup-item {
    display: flex; align-items: center; gap: .6rem;
    padding: .5rem 1rem; color: rgba(255,255,255,.72);
    font-size: .83rem; text-decoration: none; transition: all .15s;
}
.user-popup-item:hover { color: #fff; background: rgba(255,255,255,.07); }
.user-popup-item .bi { font-size: .9rem; flex-shrink: 0; }
.user-popup-item.danger { color: rgba(220,53,69,.85); }
.user-popup-item.danger:hover { color: #fc8b92; background: rgba(220,53,69,.1); }

/* ---- TOPNAV EXTRAS ---- */
.topnav .breadcrumb { font-size: .82rem; }
.topnav .breadcrumb-item.active { color: #6c757d; }
.demo-badge {
    font-size: .72rem; background: #fff8e1; color: #856404;
    border: 1px solid #ffc10740; border-radius: 20px; padding: .2rem .65rem; font-weight: 500;
}
.topnav-notif { position: relative; color: #6c757d; font-size: 1.1rem; }
.topnav-notif:hover { color: #212529; }
.notif-dot {
    position: absolute; top: -4px; right: -6px;
    background: #dc3545; color: #fff; font-size: .58rem;
    border-radius: 10px; padding: 0 4px; min-width: 16px; text-align: center; line-height: 16px;
}

/* ---- AVATAR ---- */
.avatar-sm {
    width: 32px; height: 32px; border-radius: 50%; background: var(--primary);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: .72rem; font-weight: 700; flex-shrink: 0;
}
.avatar-md {
    width: 40px; height: 40px; border-radius: 50%; background: var(--primary);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: .85rem; font-weight: 700; flex-shrink: 0;
}

/* ---- PAGE HEADERS ---- */
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.35rem; font-weight: 700; margin: 0; }
.page-header p  { color: #6c757d; font-size: .85rem; margin: .25rem 0 0; }

/* ---- KPI CARDS ---- */
.kpi-card {
    background: #fff; border-radius: 10px; padding: 1.1rem 1.25rem;
    box-shadow: var(--card-shadow); border: 1px solid #e9ecef;
    display: flex; align-items: center; gap: 1rem;
}
.kpi-icon {
    width: 46px; height: 46px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 1.3rem;
}
.kpi-value { font-size: 1.7rem; font-weight: 800; line-height: 1; color: #212529; }
.kpi-label { font-size: .75rem; color: #6c757d; margin-top: .2rem; }
.kpi-change { font-size: .72rem; font-weight: 500; margin-top: .25rem; }
.kpi-change.up   { color: #198754; }
.kpi-change.down { color: #dc3545; }

/* ---- CHART / CONTENT CARDS ---- */
.card {
    border: 1px solid #e9ecef; border-radius: 10px;
    box-shadow: var(--card-shadow);
}
.card-header { background: transparent; border-bottom: 1px solid #f0f0f0; padding: .875rem 1.25rem; font-weight: 600; font-size: .88rem; }

/* ---- SDG BADGE ---- */
.sdg-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 6px;
    font-size: .65rem; font-weight: 800; color: #fff; flex-shrink: 0;
}
.sdg-badge-lg {
    width: 36px; height: 36px; border-radius: 8px; font-size: .8rem;
}

/* ---- STATUS CHIPS ---- */
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: 20px; font-size: .72rem; font-weight: 500; }
.chip-draft     { background: #f0f0f0;  color: #6c757d; }
.chip-scheduled { background: #cff4fc;  color: #055160; }
.chip-live      { background: #d1f0e4;  color: #0a5132; }
.chip-archived  { background: #e9ecef;  color: #495057; }
.chip-active     { background: #d1f0e4;  color: #0a5132; }
.chip-inactive   { background: #fff3cd;  color: #664d03; }
.chip-completed  { background: #dce8ff;  color: #1a56a0; }

/* ── Course tab bar (shared: course-setup / topic-content / course-runs) ── */
.course-tabs { display:flex; gap:0; margin-bottom:1.5rem; }
.course-tab {
    display:flex; align-items:center; gap:.5rem;
    padding:.55rem 1.1rem .55rem .8rem;
    background:#f8f9fa; color:#6c757d;
    font-size:.8rem; font-weight:600; text-decoration:none; user-select:none;
    clip-path:polygon(0 0,calc(100% - 12px) 0,100% 50%,calc(100% - 12px) 100%,0 100%);
    flex:1; cursor:pointer; transition:background .12s, color .12s;
}
.course-tab:last-child { clip-path:none; border-radius:0 8px 8px 0; }
.course-tab:first-child { border-radius:8px 0 0 8px; padding-left:1.1rem; }
.course-tab .tab-num {
    width:20px; height:20px; border-radius:50%;
    background:#dee2e6; color:#6c757d;
    display:flex; align-items:center; justify-content:center;
    font-size:.72rem; font-weight:700; flex-shrink:0;
}
.course-tab.active { background:var(--primary); color:#fff; }
.course-tab.active .tab-num { background:rgba(255,255,255,.3); color:#fff; }
.course-tab:hover:not(.active):not(.locked) { background:#e9ecef; color:#333; }
.course-tab.locked { opacity:.4; pointer-events:none; cursor:default; }
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---- TABLES ---- */
.data-table { width: 100%; }
.data-table thead th {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
    color: #6c757d; font-weight: 600; border-bottom: 2px solid #e9ecef;
    padding: .625rem .875rem; background: transparent; white-space: nowrap;
}
.data-table tbody td { padding: .75rem .875rem; vertical-align: middle; border-bottom: 1px solid #f4f4f4; font-size: .86rem; }
.data-table tbody tr:hover { background: #fafafa; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ---- TOOLBAR ---- */
.toolbar { display: flex; align-items: center; gap: .625rem; flex-wrap: wrap; padding: .875rem 1.25rem; border-bottom: 1px solid #f0f0f0; background: #fff; border-radius: 10px 10px 0 0; }
.toolbar .form-select, .toolbar .form-control { font-size: .82rem; padding: .375rem .65rem; height: 34px; }
.toolbar-spacer { flex: 1; }

/* ---- PHONE MOCKUP ---- */
.phone-wrapper { display: flex; justify-content: center; align-items: center; padding: 1.5rem 0; }
.phone-frame {
    width: 210px; height: 420px;
    background: #111; border-radius: 34px; padding: 12px;
    box-shadow: 0 0 0 2px #333, 0 24px 64px rgba(0,0,0,.45);
    position: relative;
}
.phone-notch {
    position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
    width: 56px; height: 6px; background: #333; border-radius: 3px; z-index: 2;
}
.phone-screen {
    background: #fff; border-radius: 24px; height: 100%;
    overflow: hidden; display: flex; flex-direction: column;
}
.phone-status-bar {
    display: flex; justify-content: space-between; padding: .35rem .6rem .15rem;
    font-size: .5rem; color: #aaa; background: #fff; flex-shrink: 0;
}
.phone-card-top {
    flex: 1; display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden; min-height: 0;
    background: linear-gradient(135deg, #e8f5f1, #c8ebe0);
}
.phone-card-top img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.phone-card-top .no-image {
    text-align: center; color: #bbb; font-size: .65rem; padding: 1rem;
    z-index: 1; position: relative;
}
.phone-card-top .no-image .bi { font-size: 1.5rem; display: block; margin-bottom: .25rem; }
.phone-sdg-badge {
    position: absolute; top: 7px; right: 7px; z-index: 2;
    width: 24px; height: 24px; border-radius: 5px;
    display: flex; align-items: center; justify-content: center;
    font-size: .6rem; font-weight: 800; color: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.phone-card-bottom {
    background: #fff; padding: .6rem .7rem;
    border-top: 1px solid #f0f0f0; flex-shrink: 0;
}
.phone-card-title {
    font-size: .7rem; font-weight: 700; color: #212529; line-height: 1.25;
    min-height: 1em; margin-bottom: .3rem;
}
.phone-card-question {
    font-size: .6rem; color: #6c757d; line-height: 1.35; min-height: .9em;
}
.phone-app-bar {
    background: #f8f9fa; border-top: 1px solid #eee;
    display: flex; justify-content: space-around; padding: .4rem 0; flex-shrink: 0;
}
.phone-app-bar .bi { font-size: .9rem; color: #adb5bd; }
.phone-app-bar .bi.active { color: var(--primary); }

/* ---- FILE DROP ZONE ---- */
.drop-zone {
    border: 2px dashed #dee2e6; border-radius: 8px; padding: 1.5rem;
    text-align: center; cursor: pointer; transition: all .2s;
    background: #fafafa; position: relative;
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--primary); background: var(--primary-light); }
.drop-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-zone .drop-label { font-size: .8rem; color: #6c757d; margin-top: .4rem; }
.drop-zone .preview-thumb { max-height: 100px; max-width: 100%; border-radius: 6px; }

/* ---- AI QUEUE ---- */
.ai-item {
    background: #fff; border: 1px solid #e9ecef; border-radius: 10px;
    padding: 1.1rem 1.25rem; margin-bottom: .875rem;
    transition: box-shadow .2s, border-color .2s;
}
.ai-item:hover { box-shadow: 0 4px 16px rgba(0,0,0,.09); border-color: #d0d7de; }
.ai-item.approved { border-left: 4px solid #198754; opacity: .6; }
.ai-item.rejected { border-left: 4px solid #dc3545; opacity: .5; }

.ai-source-card {
    display: flex; align-items: center; gap: .75rem;
    background: #f8f9fa; border-radius: 6px; padding: .55rem .75rem;
    margin-bottom: .875rem; font-size: .82rem;
}
.ai-content {
    font-size: .85rem; color: #495057; line-height: 1.65;
    max-height: 110px; overflow-y: auto; padding-right: .375rem;
    border-left: 3px solid var(--primary); padding-left: .75rem;
    margin-bottom: .875rem;
    scrollbar-width: thin;
}
.ai-meta { display: flex; align-items: center; gap: .625rem; flex-wrap: wrap; margin-bottom: .875rem; }
.confidence-badge { font-size: .72rem; padding: .2rem .55rem; border-radius: 20px; font-weight: 600; }
.conf-high { background: #d1f0e4; color: #0a5132; }
.conf-mid  { background: #fff3cd; color: #664d03; }
.conf-low  { background: #fde8ea; color: #842029; }
.flag-chip { font-size: .72rem; padding: .2rem .55rem; border-radius: 20px; background: #fff3cd; color: #664d03; display: inline-flex; align-items: center; gap: .25rem; }
.deadline-tag { font-size: .72rem; color: #6c757d; }
.deadline-urgent { color: #dc3545; font-weight: 600; }
.ai-actions { display: flex; gap: .5rem; }
.ai-actions .btn { font-size: .82rem; padding: .35rem .875rem; }

/* ---- COURSE CARDS ---- */
.course-card {
    background: #fff; border: 1px solid #e9ecef; border-radius: 10px;
    padding: 1.25rem; box-shadow: var(--card-shadow); transition: box-shadow .2s;
    height: 100%; display: flex; flex-direction: column;
}
.course-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.1); }
.course-card .course-name { font-size: .95rem; font-weight: 700; color: #212529; margin-bottom: .2rem; }
.course-card .course-meta { font-size: .78rem; color: #6c757d; margin-bottom: .875rem; }
.course-card .course-stats { display: flex; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.course-stat { text-align: center; }
.course-stat .stat-val { font-size: 1.1rem; font-weight: 700; color: #212529; line-height: 1; }
.course-stat .stat-lbl { font-size: .68rem; color: #6c757d; }
.course-card .card-footer-actions { margin-top: auto; padding-top: .875rem; border-top: 1px solid #f0f0f0; display: flex; gap: .5rem; }

/* ---- WIZARD ---- */
.wizard-steps { display: flex; margin-bottom: 2rem; border-radius: 8px; overflow: hidden; border: 1px solid #e9ecef; background: #fff; }
.wizard-step {
    flex: 1; padding: .875rem 1rem; text-align: center; font-size: .82rem;
    color: #6c757d; border-bottom: 3px solid transparent; transition: all .2s;
    background: transparent;
}
.wizard-step.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; background: var(--primary-light); }
.wizard-step.done   { color: #198754; border-bottom-color: #198754; }
.wizard-step .step-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 50%; border: 2px solid currentColor;
    font-size: .72rem; font-weight: 700; margin-right: .4rem;
}
.wizard-step.done .step-num { background: #198754; border-color: #198754; color: #fff; }
.wizard-pane { display: none; }
.wizard-pane.active { display: block; }

/* ---- SDG MAPPING ---- */
.sdg-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.sdg-tile {
    border-radius: 8px; padding: .5rem .4rem; text-align: center;
    font-size: .6rem; font-weight: 700; color: #fff; min-height: 64px;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
    cursor: default; position: relative; transition: transform .15s;
}
.sdg-tile.drop-target { box-shadow: 0 0 0 3px rgba(255,255,255,.7); transform: scale(1.04); }
.sdg-tile .sdg-num { font-size: 1rem; font-weight: 900; line-height: 1; }
.sdg-tile .sdg-lbl { font-size: .52rem; opacity: .85; line-height: 1.15; margin-top: 2px; }
.sdg-tile .mapped-topics { display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; margin-top: 4px; }
.mapped-chip {
    background: rgba(255,255,255,.3); border-radius: 3px;
    padding: 1px 4px; font-size: .52rem; color: #fff; line-height: 1.3;
}

.topic-list { display: flex; flex-direction: column; gap: .375rem; max-height: 340px; overflow-y: auto; }
.topic-item {
    background: #fff; border: 1px solid #dee2e6; border-radius: 6px;
    padding: .45rem .75rem; font-size: .82rem; cursor: grab;
    display: flex; align-items: center; gap: .5rem; transition: all .15s;
    user-select: none;
}
.topic-item:hover  { border-color: var(--primary); box-shadow: 0 2px 6px rgba(15,139,108,.15); }
.topic-item.mapped { border-color: #198754; background: #f0fff8; color: #0a5132; }
.topic-item .drag-handle { color: #adb5bd; cursor: grab; }

/* ---- AI SEED CARDS ---- */
.seed-card {
    background: #fff; border: 1px solid #e9ecef; border-radius: 10px;
    padding: 1.1rem; margin-bottom: .75rem; transition: all .2s;
}
.seed-card.accepted { border-color: #198754; background: #f0fff8; }
.seed-card.discarded { opacity: .4; }

/* ---- ANALYTICS ---- */
.sdg-heatmap { display: grid; grid-template-columns: repeat(6, 1fr); gap: .375rem; }
.heat-tile {
    border-radius: 6px; padding: .5rem .4rem; text-align: center;
    font-size: .58rem; font-weight: 700; color: #fff; aspect-ratio: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    position: relative; overflow: hidden;
}
.heat-tile .heat-num { font-size: .9rem; font-weight: 900; line-height: 1; }
.heat-tile .heat-pct { font-size: .55rem; opacity: .85; }
.heat-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.3); }

/* ---- MISC ---- */
.page-section { margin-bottom: 1.5rem; }
.section-title { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: #6c757d; margin-bottom: .75rem; }
.empty-state { text-align: center; padding: 3rem 1rem; color: #adb5bd; }
.empty-state .bi { font-size: 2.5rem; display: block; margin-bottom: .75rem; }
.country-flag { font-size: .8rem; margin: 0 1px; }

/* ---- ACTIVITY FEED ---- */
.activity-item { display: flex; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid #f4f4f4; font-size: .83rem; }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: .35rem; flex-shrink: 0; }
.activity-time { font-size: .72rem; color: #adb5bd; white-space: nowrap; }

/* ---- SPECIALIZATION CYCLE BADGES ---- */
.spec-cycle { font-size:.72rem; font-weight:600; padding:2px 9px; border-radius:10px; display:inline-block; white-space:nowrap; }
.spec-cycle-bachelor     { background:#e3f2fd; color:#1565c0; }
.spec-cycle-master       { background:#e8f5e9; color:#2e7d32; }
.spec-cycle-phd          { background:#f3e5f5; color:#6a1b9a; }
.spec-cycle-postgraduate { background:#fff3e0; color:#e65100; }

/* ---- LOGIN PAGE ---- */
.login-page { min-height: 100vh; background: var(--sidebar-bg); display: flex; align-items: center; justify-content: center; }
.login-card { background: #fff; border-radius: 16px; padding: 2.5rem; width: 100%; max-width: 520px; box-shadow: 0 24px 64px rgba(0,0,0,.3); }
.login-brand { text-align: center; margin-bottom: 2rem; }
.login-brand .brand-icon { width: 52px; height: 52px; border-radius: 14px; font-size: 1.5rem; margin: 0 auto 1rem; }
.login-brand h1 { font-size: 1.5rem; font-weight: 800; color: #212529; }
.login-brand p  { color: #6c757d; font-size: .88rem; }
.role-btn {
    display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.25rem;
    border: 2px solid #e9ecef; border-radius: 10px; cursor: pointer;
    transition: all .2s; background: #fff; width: 100%; text-align: left;
    margin-bottom: .75rem;
}
.role-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.role-btn .role-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
.role-btn .role-name { font-weight: 700; font-size: .95rem; color: #212529; }
.role-btn .role-desc { font-size: .78rem; color: #6c757d; }
.demo-notice { background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: .75rem 1rem; font-size: .8rem; color: #92400e; text-align: center; margin-bottom: 1.5rem; }

/* ---- FLASHCARD CALENDAR ---- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-day-header { text-align: center; font-size: .63rem; font-weight: 600; color: #6c757d; padding: 4px 0; }
.cal-day {
    min-height: 68px; border: 1px solid #e9ecef; border-radius: 6px;
    padding: 4px; transition: border-color .15s;
    min-width: 0; overflow: hidden;
}
.cal-day.cal-empty { background: #f8f9fa; border-color: transparent; }
.cal-day.drag-over { border-color: var(--primary); background: var(--primary-light); }
.cal-day-num {
    width: 18px; height: 18px; font-size: .63rem; color: #adb5bd;
    display: flex; align-items: center; justify-content: center; margin-bottom: 2px;
}
.cal-day.today .cal-day-num { background: var(--primary); color: #fff; border-radius: 50%; font-weight: 700; }
.cal-chip {
    font-size: .63rem; border-radius: 4px; padding: 2px 4px;
    cursor: grab; display: flex; align-items: center; gap: 2px;
    user-select: none; line-height: 1.3;
}
.cal-chip:active { cursor: grabbing; }
.cal-chip-ro { cursor: default; opacity: .65; border-style: dashed !important; }
.cal-chip-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.cal-chip-remove { flex-shrink: 0; cursor: pointer; opacity: .55; font-size: .75rem; line-height: 1; }
.cal-chip-remove:hover { opacity: 1; }
.cal-pool { display: flex; flex-direction: column; gap: 5px; max-height: 480px; overflow-y: auto; scrollbar-width: thin; }
.pool-item {
    border: 1px solid #e9ecef; border-radius: 6px; padding: 6px 10px;
    cursor: grab; display: flex; align-items: center; gap: 8px;
    background: #fff; user-select: none; transition: all .15s;
}
.pool-item:hover { border-color: var(--primary); background: var(--primary-light); }
.pool-item:active { cursor: grabbing; }
.pool-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.pool-title { font-size: .8rem; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ════════════════════════════════════════════════════════════════
   FLASHCARD SKIN / TEMPLATE SYSTEM
   .skin-canvas  = flex:1 area inside .phone-screen
   .sk-*         = skin sub-elements (prefix avoids collisions)
   All 5 types: dual_stacked | full_bottom | overlaid_box | split_lr | dyk_panel
   ════════════════════════════════════════════════════════════════ */

/* ── Base canvas (replaces the old flex:1 wrapper div) ── */
.skin-canvas {
    flex: 1; min-height: 0;
    position: relative; overflow: hidden;
    display: flex; flex-direction: column;
    background: #e8f5f1;
}

/* ── SDG badge — shared by all skins, now clickable ── */
.sk-sdg-badge {
    position: absolute; top: 7px; right: 7px; z-index: 10;
    width: 22px; height: 22px; border-radius: 5px;
    display: flex; align-items: center; justify-content: center;
    font-size: .55rem; font-weight: 800; color: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.35);
    cursor: pointer; text-decoration: none;
    transition: transform .15s, box-shadow .15s;
    user-select: none;
}
.sk-sdg-badge:hover { transform: scale(1.15); box-shadow: 0 2px 8px rgba(0,0,0,.4); }

/* ── Shared panel (used in dual + split) ── */
.sk-panel {
    flex: 1; position: relative; overflow: hidden; min-height: 0;
    display: flex; align-items: center; justify-content: center;
    background-size: cover; background-position: center; background-repeat: no-repeat;
}
.sk-panel .sk-no-image {
    text-align: center; color: #bbb; font-size: .6rem; padding: .75rem;
    z-index: 1; position: relative;
}
.sk-panel .sk-no-image .bi { font-size: 1.2rem; display: block; margin-bottom: .2rem; }

/* Caption bar at bottom of a panel */
.sk-caption {
    position: absolute; bottom: 0; left: 0; right: 0; z-index: 3;
    background: rgba(0,0,0,.45); color: #fff;
    font-size: .5rem; line-height: 1.2; padding: .2rem .4rem;
    backdrop-filter: blur(2px);
}

/* ── SKIN A: dual_stacked ── top/bottom split ── */
.skin-dual { flex-direction: column; }
.skin-dual .sk-top    { border-bottom: 1px dashed rgba(0,0,0,.12); }
.skin-dual .sk-top    { background: linear-gradient(135deg,#f5f0eb,#e8e0d8); }
.skin-dual .sk-bottom { background: linear-gradient(135deg,#e8f5e9,#c8e6c9); }

/* ── SKIN B: full_bottom ── single image, headline overlay at bottom ── */
.skin-full-bottom { flex-direction: column; background: #222; }
.skin-full-bottom .sk-full-img {
    flex: 1; min-height: 0;
    background-size: cover; background-position: center; background-repeat: no-repeat;
    position: relative;
}
.skin-full-bottom .sk-bottom-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(0,0,0,.75) 0%, rgba(0,0,0,.0) 100%);
    padding: 1.5rem .6rem .5rem;
    z-index: 2;
}
.skin-full-bottom .sk-headline {
    color: #fff; font-size: .85rem; font-weight: 800;
    line-height: 1.15; text-shadow: 0 1px 3px rgba(0,0,0,.6);
}
.skin-full-bottom .sk-no-image {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: #666; font-size: .6rem; text-align: center; padding: 1rem;
}

/* ── SKIN C: overlaid_box ── single image, dark semi-transparent panel ── */
.skin-overlay-box { flex-direction: column; background: #222; }
.skin-overlay-box .sk-full-img {
    flex: 1; min-height: 0;
    background-size: cover; background-position: center; background-repeat: no-repeat;
    position: relative; display: flex; align-items: flex-end; justify-content: center;
    padding: .5rem;
}
.skin-overlay-box .sk-box {
    position: absolute;
    /* position varies via .sk-pos-top / .sk-pos-center / .sk-pos-bottom */
    left: .5rem; right: .5rem;
    padding: .5rem .6rem;
    border-radius: 4px;
    backdrop-filter: blur(4px);
    z-index: 2;
}
.skin-overlay-box .sk-pos-top    { top: .5rem; }
.skin-overlay-box .sk-pos-center { top: 50%; transform: translateY(-50%); }
.skin-overlay-box .sk-pos-bottom { bottom: .5rem; }
.skin-overlay-box .sk-accent-bar {
    height: 2px; width: 24px; border-radius: 2px;
    margin-bottom: .3rem;
}
.skin-overlay-box .sk-headline {
    font-size: .78rem; font-weight: 800; line-height: 1.2;
}
.skin-overlay-box .sk-subline {
    font-size: .55rem; line-height: 1.3; margin-top: .2rem; opacity: .85;
}
.skin-overlay-box .sk-no-image {
    flex: 1; display: flex; align-items: center; justify-content: center;
    color: #666; font-size: .6rem; text-align: center; padding: 1rem;
}

/* ── SKIN D: split_lr ── two images side by side ── */
.skin-split-lr { flex-direction: row; }
.skin-split-lr .sk-left  { border-right: 1.5px solid #fff; background: linear-gradient(135deg,#f5e8e8,#e8c8c8); }
.skin-split-lr .sk-right { border-left:  1.5px solid #fff; background: linear-gradient(135deg,#e8f5e9,#c8e6c9); }
.sk-split-label {
    position: absolute; bottom: 0; left: 0; right: 0; z-index: 3;
    padding: .25rem .3rem; font-size: .5rem; font-weight: 700; line-height: 1.2;
    display: flex; align-items: center; gap: .2rem;
}
.sk-split-label.sk-negative { background: rgba(180,0,0,.6); color: #fff; }
.sk-split-label.sk-positive { background: rgba(0,120,40,.6); color: #fff; }
.sk-sentiment-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid currentColor;
    font-size: .45rem; font-weight: 900; flex-shrink: 0;
}

/* ── SKIN E: dyk_panel ── full bleed image, central frosted-glass panel ── */
.skin-dyk {
    background: #1a1a2e;
    background-size: cover; background-position: center; background-repeat: no-repeat;
    flex-direction: column; justify-content: flex-start;
    padding: .4rem;
}
.skin-dyk::before {
    content: ''; position: absolute; inset: 0;
    background: rgba(0,0,0,.35); z-index: 0;
}
.skin-dyk > * { position: relative; z-index: 1; }
.sk-dyk-header {
    display: flex; align-items: center; gap: .3rem;
    font-size: .45rem; font-weight: 700; color: rgba(255,255,255,.9);
    letter-spacing: .04em; text-transform: uppercase;
    background: rgba(0,0,0,.2); border-radius: 4px;
    padding: .2rem .35rem; backdrop-filter: blur(4px);
    align-self: flex-start;
}
.sk-dyk-header .sk-sdg-mini {
    width: 14px; height: 14px; border-radius: 3px;
    display: flex; align-items: center; justify-content: center;
    font-size: .45rem; font-weight: 900; color: #fff; flex-shrink: 0;
}
.sk-dyk-panel {
    position: absolute; left: .4rem; right: .4rem;
    /* top + transform set via inline style from dyk_panel_y */
    background: rgba(255,255,255,.18);
    backdrop-filter: blur(12px) saturate(1.4);
    -webkit-backdrop-filter: blur(12px) saturate(1.4);
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 8px; padding: .5rem .55rem .45rem;
    display: flex; flex-direction: column; align-items: center;
    text-align: center; gap: .2rem;
    z-index: 2;
}
.sk-dyk-eyebrow {
    font-size: .42rem; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; color: rgba(255,255,255,.75);
}
.sk-dyk-icon {
    font-size: 1.1rem; line-height: 1;
}
.sk-dyk-panel .sk-headline {
    font-size: .68rem; font-weight: 800; color: #fff; line-height: 1.25;
}
.sk-dyk-panel .sk-subline {
    font-size: .5rem; color: rgba(255,255,255,.8); line-height: 1.3;
}
.sk-dyk-cta {
    width: 100%; padding: .3rem; border-radius: 20px;
    font-size: .5rem; font-weight: 700; text-align: center;
    border: none; cursor: default; letter-spacing: .04em; text-transform: uppercase;
    color: #fff; margin-top: .1rem;
}

/* ── SDG Info Modal ── */
.sdg-modal-badge {
    width: 56px; height: 56px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; font-weight: 900; color: #fff;
    flex-shrink: 0;
}
.sdg-modal-name  { font-size: 1rem; font-weight: 700; line-height: 1.2; }
.sdg-modal-sub   { font-size: .8rem; color: #6c757d; }
.sdg-modal-desc  { font-size: .85rem; color: #495057; line-height: 1.6; }

/* ── Template picker (backoffice) ── */
.tpl-picker { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tpl-btn {
    border: 2px solid #dee2e6; border-radius: 8px; padding: .35rem .65rem;
    font-size: .75rem; font-weight: 600; cursor: pointer; background: #fff;
    color: #495057; transition: all .15s; white-space: nowrap;
}
.tpl-btn:hover  { border-color: var(--primary); color: var(--primary); }
.tpl-btn.active { border-color: var(--primary); background: var(--primary); color: #fff; }

/* ── Skin status chip ── */
.skin-status-chip {
    display: inline-flex; align-items: center; gap: .25rem;
    font-size: .65rem; font-weight: 600; padding: .15rem .45rem;
    border-radius: 20px;
}
.skin-status-chip.approved { background: #d1fae5; color: #065f46; }
.skin-status-chip.draft    { background: #fef3c7; color: #92400e; }
.skin-status-chip.rejected { background: #fee2e2; color: #991b1b; }

/* ── Flashcard Editor Page (flashcard-edit.php) ── */
.fce-page { display: flex; flex-direction: column; height: calc(100vh - 56px); overflow: hidden; }
.fce-page-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: .75rem 1.5rem; border-bottom: 1px solid #e9ecef;
    background: #fff; flex-shrink: 0; gap: 1rem;
}
.fce-page-header h5 { margin: 0; font-size: .95rem; font-weight: 700; color: #1a1a2e; }
.fce-body { display: flex; flex: 1; min-height: 0; overflow: hidden; }

.fce-left {
    flex: 1; min-width: 0; overflow-y: auto;
    border-right: 1px solid #e9ecef;
    display: flex; flex-direction: column;
}
/* Flashcard editor tabs — match wizard-step visual style */
.fce-tabs {
    display: flex; flex-shrink: 0;
    background: #fff; border-bottom: 1px solid #e9ecef;
    padding: 0; overflow: hidden;
}
.fce-tabs .nav-item { flex: 1; }
.fce-tabs .nav-link {
    display: flex; align-items: center; justify-content: center; gap: .35rem;
    width: 100%; border: none; border-bottom: 3px solid transparent; border-radius: 0;
    padding: .75rem .5rem; font-size: .8rem; font-weight: 500; color: #6c757d;
    background: transparent; transition: color .15s, border-color .15s, background .15s;
    white-space: nowrap;
}
.fce-tabs .nav-link:hover  { color: var(--primary); background: var(--primary-light); }
.fce-tabs .nav-link.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--primary-light); font-weight: 600; }
.fce-tab-content { flex: 1; padding: 1.5rem; overflow-y: visible; }
.fce-tab-content .tab-pane { padding: 0; }

.fce-right {
    width: 280px; flex-shrink: 0; overflow-y: auto;
    background: #f8f9fa; padding: 1rem;
}
.fce-preview-sticky { position: sticky; top: 0; }
.fce-preview-label { font-size: .72rem; font-weight: 700; color: #888; letter-spacing: .06em;
    text-transform: uppercase; margin-bottom: .75rem; }

/* Phone mockup — 9:19.5 (modern smartphone ratio) */
.phone-mock-wrap { display: flex; justify-content: center; margin-bottom: .5rem; }
.phone-mockup {
    width: 240px;
    aspect-ratio: 9 / 19.5;
    background: #111;
    border-radius: 36px;
    padding: 0;
    box-shadow: 0 0 0 2px #333, 0 20px 56px rgba(0,0,0,.45);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}
/* Frame overlay — drawn on top of content so rounded corners mask square edges */
.phone-mockup::after {
    content: '';
    position: absolute; inset: 0;
    border-radius: 36px;
    box-shadow: inset 0 0 0 10px #111;
    pointer-events: none;
    z-index: 20;
}
/* Notch pill */
.phone-mockup::before {
    content: '';
    position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 52px; height: 5px;
    background: #333; border-radius: 3px; z-index: 21;
}

/* Skin subtabs (5 skin-type toggles in Skins tab) */
.skin-subtabs {
    display: flex; gap: 0; margin-bottom: 1.25rem;
    border: 1px solid #e9ecef; border-radius: 10px; overflow: hidden; background: #fff;
}
.skin-subtab {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    gap: .2rem; padding: .6rem .3rem .5rem;
    font-size: .72rem; font-weight: 500; color: #6c757d;
    cursor: pointer; transition: background .15s, color .15s;
    border-right: 1px solid #e9ecef; position: relative;
}
.skin-subtab:last-child { border-right: none; }
.skin-subtab:hover { background: var(--primary-light); color: var(--primary); }
.skin-subtab.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.skin-subtab.inactive { opacity: .45; }
.skin-subtab .skin-subtab-icon { font-size: 1rem; }
.skin-subtab .skin-subtab-label { text-align: center; line-height: 1.2; }
.skin-subtab .skin-subtab-cb {
    position: absolute; top: 4px; right: 5px;
}
.skin-subtab .skin-subtab-cb .form-check-input { width: .75rem; height: .75rem; margin: 0; cursor: pointer; }

.skin-editor-section { border-top: 2px dashed #dee2e6; padding-top: 1.25rem; margin-top: .25rem; }
.skin-editor-label { font-size: .72rem; font-weight: 700; color: #888; letter-spacing: .06em;
    text-transform: uppercase; margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; }

.skin-default-row {
    margin-top: 1.25rem; padding-top: 1.25rem;
    border-top: 1px solid #e9ecef;
}

/* Quiz tab micro-question context box */
.quiz-mq-box {
    background: var(--primary-light); border-left: 3px solid var(--primary);
    border-radius: 0 6px 6px 0; padding: .6rem .9rem; margin-bottom: 1.25rem;
}
.quiz-mq-box .quiz-mq-label { font-size: .68rem; font-weight: 700; color: var(--primary); letter-spacing: .06em; text-transform: uppercase; margin-bottom: .2rem; }
.quiz-mq-box .quiz-mq-text  { font-size: .85rem; color: #1a1a2e; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main-wrapper { margin-left: 0; }
}

/* ════════════════════════════════════════════════════════════════
   INSIGHTS MODULE
   ════════════════════════════════════════════════════════════════ */

/* ── SDG mini badge (table) ── */
.sdg-mini-badge-sm {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: 4px;
    font-size: .6rem; font-weight: 800; color: #fff;
}

/* ── SDG checkbox grid in insight editor ── */
.sdg-check-grid {
    display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px;
}
.sdg-check-label {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    width: 100%; aspect-ratio: 1; border-radius: 6px;
    border: 2px solid #e9ecef; background: #f8f9fa;
    cursor: pointer; transition: all .15s; position: relative; overflow: hidden;
}
.sdg-check-label input[type=checkbox] { position: absolute; opacity: 0; width: 0; height: 0; }
.sdg-check-label .sdg-num { font-size: .75rem; font-weight: 800; color: #aaa; line-height: 1; }
.sdg-check-label:hover { border-color: var(--sdg-color, var(--primary)); }
.sdg-check-label.checked { background: var(--sdg-color, var(--primary)); border-color: var(--sdg-color, var(--primary)); }
.sdg-check-label.checked .sdg-num { color: #fff; }

/* ── Markdown editor preview ── */
.insight-md-preview {
    font-size: .88rem; line-height: 1.75; color: #333;
}
.insight-md-preview h1,.insight-md-preview h2,.insight-md-preview h3 { font-weight: 700; margin: 1rem 0 .5rem; }
.insight-md-preview h1 { font-size: 1.3rem; }
.insight-md-preview h2 { font-size: 1.1rem; }
.insight-md-preview h3 { font-size: .95rem; }
.insight-md-preview p  { margin: 0 0 .875rem; }
.insight-md-preview ul,.insight-md-preview ol { padding-left: 1.5rem; margin: 0 0 .875rem; }
.insight-md-preview li { margin-bottom: .25rem; }
.insight-md-preview blockquote {
    border-left: 3px solid var(--primary); padding-left: .875rem;
    margin: 0 0 .875rem; color: #555;
}
.insight-md-preview code { background: #f4f6f8; padding: 1px 5px; border-radius: 4px; font-size: .82em; }
.insight-md-preview pre  { background: #f4f6f8; border-radius: 6px; padding: .75rem 1rem; overflow-x: auto; }

/* ── [[concept]] chip ── */
.insight-ref-chip {
    display: inline-flex; align-items: center;
    background: var(--primary-light); color: var(--primary);
    border: 1px solid rgba(15,139,108,.25); border-radius: 12px;
    padding: .05rem .55rem; font-size: .8em; font-weight: 600;
    cursor: pointer; text-decoration: none;
    transition: background .15s;
}
.insight-ref-chip:hover { background: #c5e8df; color: var(--primary); }

/* ── Cover preview in editor ── */
.insight-cover-preview {
    width: 100%; aspect-ratio: 16/9; border-radius: 8px;
    background: #e9ecef no-repeat center/cover;
    border: 1px solid #e2e8f0;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main-wrapper { margin-left: 0; }
}

/* ---- UTILITIES ---- */
.text-primary-custom { color: var(--primary) !important; }
.bg-primary-custom   { background: var(--primary) !important; }
.fw-600 { font-weight: 600; }
.fs-xs  { font-size: .75rem; }
.fs-sm  { font-size: .82rem; }
