/* ==========================================================================
   MENTORCORE — Design System
   Diretrizes (Projeto/Parte 3): Clean, Premium, Humanizada, 100% responsivo.
   Tema claro/escuro/auto via data-theme nas variáveis do tenant.
   ========================================================================== */

:root {
    /* Identidade do tenant (sobrescrita pelo tema dinâmico) */
    --primary: #8A42FF;
    --primary-strong: #6d28d9;
    --primary-soft: rgba(138, 66, 255, 0.10);
    --secondary: #222831;
    --accent: #FFB84D;
    --accent-soft: rgba(255, 184, 77, 0.14);

    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 8px;
    --sidebar-w: 264px;
    --topbar-h: 68px;
    --shadow-sm: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.10);
    --shadow: 0 4px 12px rgba(16,24,40,.08);
    --shadow-lg: 0 12px 32px rgba(16,24,40,.14);
    --ring: 0 0 0 3px rgba(138,66,255,.18);
}

/* Tema claro (padrão) */
[data-theme="light"], :root[data-theme="light"] {
    color-scheme: light;
    --bg: #F6F7FB;
    --bg-elev: #FFFFFF;
    --bg-subtle: #EFF0F6;
    --surface: #FFFFFF;
    --surface-2: #F9FAFC;
    --border: #E6E8F0;
    --border-strong: #D5D8E3;
    --text: #1C2130;
    --text-muted: #6B7280;
    --text-faint: #98A2B3;
    --shadow: 0 4px 12px rgba(16,24,40,.07);
    --sidebar-bg: #1C2130;
    --sidebar-text: #C7CDDC;
    --sidebar-active: rgba(138,66,255,.16);
}

/* Tema escuro */
[data-theme="dark"] {
    color-scheme: dark;
    --bg: #11141C;
    --bg-elev: #171B26;
    --bg-subtle: #1E2330;
    --surface: #171B26;
    --surface-2: #1E2330;
    --border: #2A3040;
    --border-strong: #39415A;
    --text: #EDEFF6;
    --text-muted: #9AA3B5;
    --text-faint: #67708A;
    --shadow: 0 6px 18px rgba(0,0,0,.35);
    --sidebar-bg: #0E1118;
    --sidebar-text: #A8B0C4;
    --sidebar-active: rgba(138,66,255,.22);
}

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4,h5 { margin: 0 0 .5em; line-height: 1.25; letter-spacing: -.01em; color: var(--text); }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; color: var(--text-muted); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* ============ Layout de painel ============ */
.layout-app {
    min-height: 100vh;
    display: flex;
    background: var(--bg);
}
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
    transition: margin-left .25s ease;
}
.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    font-weight: 700;
    color: #fff;
    font-size: 1.05rem;
    letter-spacing: -.01em;
}
.sidebar .brand .logo-mark {
    width: 38px; height: 38px; border-radius: 12px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #fff; font-weight: 800; font-size: 1rem;
    flex-shrink: 0;
}
.app-logo { display: inline-block; flex-shrink: 0; object-fit: contain; }
.sidebar .brand .app-logo { border-radius: 8px; }
.brand .app-logo { height: 38px; }
.vitrine-brand .app-logo { border-radius: 8px; }
.auth-logo .app-logo { border-radius: 8px; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 6px 12px 16px; }
.sidebar .nav-label {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .09em;
    color: rgba(199,205,220,.5); padding: 14px 10px 6px;
}
.sidebar nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 11px; margin: 2px 0; border-radius: var(--radius-sm);
    color: var(--sidebar-text); font-weight: 500; font-size: .92rem;
    transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--sidebar-active); color: #fff; }
.sidebar nav a .ic { width: 20px; text-align: center; opacity: .85; flex-shrink: 0; }
.sidebar .sidebar-foot {
    padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar .sidebar-foot a {
    display: flex; align-items: center; gap: 10px; color: var(--sidebar-text);
    font-size: .88rem; padding: 6px 4px;
}
.sidebar .sidebar-foot a:hover { color: #fff; text-decoration: none; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 14px;
    padding: 0 26px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30;
}
.topbar .menu-toggle {
    display: none; background: none; border: 0; cursor: pointer;
    color: var(--text); font-size: 1.25rem; padding: 6px;
}
.topbar .page-title { font-weight: 700; font-size: 1.02rem; color: var(--text); }
.topbar .spacer { flex: 1; }
.topbar .user-chip {
    display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 6px;
    border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border);
}
.topbar .avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center; font-weight: 700; color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    font-size: .85rem;
}
.topbar .user-chip .who { line-height: 1.1; }
.topbar .user-chip .who b { font-size: .85rem; display: block; color: var(--text); }
.topbar .user-chip .who span { font-size: .72rem; color: var(--text-muted); }

.content { padding: 26px; flex: 1; }

/* ============ Cartões e grades ============ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 18px; }
.card .card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card .card-head h3 { margin: 0; }
.card-flat { background: var(--surface-2); border-color: transparent; box-shadow: none; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.stack > * + * { margin-top: 18px; }

.stat {
    display: flex; align-items: center; gap: 14px;
    padding: 18px; border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.stat .ico {
    width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0;
    display: grid; place-items: center; font-size: 1.3rem;
    background: var(--primary-soft); color: var(--primary);
}
.stat b { font-size: 1.4rem; display: block; line-height: 1.1; color: var(--text); }
.stat span { font-size: .82rem; color: var(--text-muted); }

/* ============ Botões ============ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid var(--border-strong); cursor: pointer;
    padding: 9px 16px; border-radius: var(--radius-sm);
    font: inherit; font-weight: 600; font-size: .9rem;
    background: var(--surface); color: var(--text);
    transition: all .15s ease; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    border-color: transparent; color: #fff;
}
.btn-primary:hover { filter: brightness(1.06); background: linear-gradient(135deg, var(--primary), var(--primary-strong)); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-danger { background: #EF4444; border-color: transparent; color: #fff; }
.btn-danger:hover { background: #DC2626; filter: none; }
.btn-sm { padding: 5px 11px; font-size: .8rem; border-radius: 8px; }
.btn-lg { padding: 12px 22px; font-size: 1rem; border-radius: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-soft { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.btn-soft:hover { background: rgba(138,66,255,.2); }

/* ============ Formulários ============ */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: 6px; color: var(--text); }
.field .hint { font-size: .77rem; color: var(--text-faint); margin-top: 5px; }
.input, select.input, textarea.input {
    width: 100%; padding: 10px 13px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong); background: var(--surface-2);
    color: var(--text); font: inherit; font-size: .92rem;
    transition: border .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); background: var(--surface); }
textarea.input { min-height: 110px; resize: vertical; }
.input::placeholder { color: var(--text-faint); }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 16px; }
.form-row-3 { grid-template-columns: repeat(3, 1fr); }
.input-group { display: flex; gap: 8px; align-items: flex-start; }
.check-item { display: flex; align-items: center; gap: 8px; font-size: .9rem; padding: 4px 0; color: var(--text); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 16px; height: 16px; }
input[type="range"] { accent-color: var(--primary); width: 100%; }

/* ============ Tabelas ============ */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; background: var(--surface); }
table.table th {
    text-align: left; padding: 11px 14px; font-size: .72rem; text-transform: uppercase;
    letter-spacing: .06em; color: var(--text-faint); background: var(--surface-2);
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
table.table tr:last-child td { border-bottom: 0; }
table.table tr:hover td { background: var(--surface-2); }

/* ============ Badges / chips ============ */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 99px; font-size: .72rem; font-weight: 600;
    background: var(--bg-subtle); color: var(--text-muted);
}
.badge.green { background: rgba(16,185,129,.12); color: #0E9F6E; }
.badge.red { background: rgba(239,68,68,.12); color: #DC2626; }
.badge.amber { background: rgba(245,158,11,.14); color: #B45309; }
.badge.blue { background: rgba(59,130,246,.12); color: #2563EB; }
.badge.purple { background: var(--primary-soft); color: var(--primary); }
[data-theme="dark"] .badge.green { color: #34D399; }
[data-theme="dark"] .badge.red { color: #F87171; }
[data-theme="dark"] .badge.amber { color: #FBBF24; }
[data-theme="dark"] .badge.blue { color: #60A5FA; }

.chip { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: .78rem; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); }

/* ============ Progresso ============ */
.progress { height: 8px; border-radius: 99px; background: var(--bg-subtle); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), var(--primary-strong)); transition: width .5s ease; }
.progress.amber > i { background: linear-gradient(90deg, #F59E0B, #F97316); }
.progress.green > i { background: linear-gradient(90deg, #10B981, #059669); }
.progress-label { display: flex; justify-content: space-between; font-size: .8rem; color: var(--text-muted); margin-bottom: 6px; }

/* ============ Alertas / flash ============ */
.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 15px; border-radius: var(--radius-sm); font-size: .9rem;
    background: var(--surface); border: 1px solid var(--border);
    margin-bottom: 18px;
}
.alert.success { background: rgba(16,185,129,.08); border-color: rgba(16,185,129,.25); color: #047857; }
.alert.error { background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.25); color: #B91C1C; }
.alert.info { background: rgba(59,130,246,.08); border-color: rgba(59,130,246,.25); color: #1D4ED8; }

/* ============ Jornada ============ */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--border-strong); }
.timeline-item { position: relative; padding: 0 0 22px; }
.timeline-item::before {
    content: ""; position: absolute; left: -26px; top: 4px; width: 18px; height: 18px;
    border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong);
}
.timeline-item.done::before { background: var(--primary); border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.timeline-item.current::before { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.timeline-item.locked { opacity: .5; }

/* ============ Login / auth ============ */
.auth-wrap {
    min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background:
        radial-gradient(1200px 600px at 85% -10%, rgba(138,66,255,.16), transparent 60%),
        radial-gradient(900px 500px at -10% 100%, rgba(255,184,77,.12), transparent 55%),
        var(--bg);
}
.auth-card { width: 100%; max-width: 420px; }
.auth-logo {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    margin-bottom: 26px; font-weight: 800; font-size: 1.3rem; color: var(--text);
}
.auth-logo .logo-mark {
    width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong)); color: #fff;
}
.auth-sub { text-align: center; color: var(--text-muted); margin: -14px 0 22px; font-size: .92rem; }

/* ============ Listas ============ */
.list-group { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.list-group .li {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px;
    border-bottom: 1px solid var(--border); background: var(--surface);
}
.list-group .li:last-child { border-bottom: 0; }
.list-group .li:hover { background: var(--surface-2); }

.empty {
    text-align: center; padding: 40px 20px; color: var(--text-muted);
    border: 1px dashed var(--border-strong); border-radius: var(--radius);
}

/* ============ Vida/roda e diagnósticos ============ */
.range-strip {
    display: grid; gap: 18px; padding: 10px 0;
}
.range-strip .row { display: grid; grid-template-columns: 130px 1fr 44px; align-items: center; gap: 14px; }
.range-strip .lbl { font-weight: 600; font-size: .92rem; }
.range-strip .val { font-weight: 700; color: var(--primary); text-align: right; }

.quiz-q { margin-bottom: 26px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.quiz-q:last-child { border-bottom: 0; }
.quiz-q h4 { margin-bottom: 12px; }
.opt-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; cursor: pointer; }
.opt-item:hover { background: var(--surface-2); }
.opt-item input { margin-top: 3px; }
.opt-item.selected { border-color: var(--primary); background: var(--primary-soft); }

/* ============ Tema switch ============ */
.theme-switch { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; }
.theme-switch button {
    border: 0; background: transparent; cursor: pointer; padding: 6px 11px; border-radius: 99px;
    color: var(--text-muted); font-size: .82rem; font-weight: 600;
}
.theme-switch button.active { background: var(--primary); color: #fff; }

/* ============ Vitrine pública ============ */
.vitrine { min-height: 100vh; background: var(--bg); }
.vitrine-hero {
    padding: 70px 24px; text-align: center; position: relative; overflow: hidden;
    background:
        radial-gradient(900px 420px at 80% -20%, var(--primary-soft), transparent 60%),
        radial-gradient(700px 400px at 10% 110%, var(--accent-soft), transparent 55%);
}
.vitrine-hero h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); max-width: 760px; margin: 14px auto; }
.vitrine-hero p { max-width: 560px; margin: 0 auto 22px; font-size: 1.05rem; }
.vitrine-hero .app-logo-lg {
    margin: 0 auto 8px; background: #fff; border-radius: 18px;
    padding: 14px 22px; box-shadow: 0 12px 30px rgba(0,0,0,.18);
}
.vitrine-grid { max-width: 1080px; margin: 0 auto; padding: 40px 24px 70px; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.vitrine .logo-mark {
    width: 74px; height: 74px; border-radius: 22px; margin: 0 auto 10px;
    display: grid; place-items: center; font-size: 2rem; font-weight: 800; color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
}
.pricing-card { text-align: center; }
.pricing-card .price { font-size: 2.1rem; font-weight: 800; color: var(--text); }

/* ============ Notificações ============ */
.notif-item { display: flex; gap: 14px; padding: 12px 4px; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: 0; }
.notif-item .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex-shrink: 0; }
.notif-item.unread { background: var(--primary-soft); border-radius: var(--radius-sm); padding: 12px 14px; }
.notif-item.badge-dot .dot { background: transparent; }

/* ============ Uploads / mídias ============ */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.media-tile {
    aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden;
    background: var(--surface-2); border: 1px solid var(--border);
    display: grid; place-items: center; position: relative;
}
.media-tile img, .media-tile video { width: 100%; height: 100%; object-fit: cover; }

/* ============ Utilitários ============ */
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 18px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 18px; }
.pb-2 { padding-bottom: 8px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-sm { font-size: .84rem; }
.text-xs { font-size: .76rem; }
.small { font-size: .84rem; }
.muted { color: var(--text-muted); }
.nowrap { white-space: nowrap; }
.hide-sm { }

/* ============ Toasts ============ */
.toasts { position: fixed; top: 18px; right: 18px; z-index: 200; display: grid; gap: 10px; max-width: 360px; }
.toast {
    background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm); padding: 12px 16px; box-shadow: var(--shadow-lg);
    animation: toast-in .25s ease; font-size: .9rem; color: var(--text);
}
.toast.success { border-left-color: #10B981; }
.toast.error { border-left-color: #EF4444; }
@keyframes toast-in { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }

/* ============ Responsivo ============ */
@media (max-width: 960px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
    .sidebar { position: fixed; left: 0; top: 0; margin-left: calc(var(--sidebar-w) * -1); box-shadow: var(--shadow-lg); }
    .sidebar.open { margin-left: 0; }
    .topbar .menu-toggle { display: inline-flex; }
    .content { padding: 18px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .hide-sm { display: none; }
    .topbar { padding: 0 16px; }
    .topbar .user-chip .who span { display: none; }
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }