/* =====================================================================
   財務資訊管理系統 — 介面主題
   ===================================================================== */

:root {
    --app-sidebar-w: 252px;
    --app-bg: #f4f6fb;
    --app-primary: #4f46e5;       /* indigo  */
    --app-primary-dark: #4338ca;
    --app-income: #16a34a;        /* green   */
    --app-outcome: #dc2626;       /* red     */
    --app-ink: #1f2937;
    --app-muted: #6b7280;
    --app-border: #e5e7eb;
    --app-sidebar-bg: #111827;    /* dark slate */
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--app-bg);
    color: var(--app-ink);
    font-family: "Noto Sans TC", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ---------- 版型骨架 ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--app-sidebar-w);
    flex: 0 0 var(--app-sidebar-w);
    background: var(--app-sidebar-bg);
    color: #cbd5e1;
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    z-index: 1040;
}

.app-main {
    flex: 1 1 auto;
    margin-left: var(--app-sidebar-w);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

@media (max-width: 991.98px) {
    .app-sidebar { display: none; }
    .app-main { margin-left: 0; }
}

/* ---------- 品牌 ---------- */
.app-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 1.25rem 1.25rem;
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: .3px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.app-brand .brand-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--app-primary), #7c3aed);
    color: #fff;
    font-size: 1.2rem;
    flex: 0 0 auto;
}

.app-brand small {
    display: block;
    font-weight: 400;
    font-size: .72rem;
    color: #94a3b8;
}

/* ---------- 側邊欄導覽 ---------- */
.app-nav {
    padding: 1rem .75rem;
    display: flex;
    flex-direction: column;
    gap: .25rem;
    overflow-y: auto;
}

.app-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .7rem .85rem;
    border-radius: 10px;
    color: #cbd5e1;
    font-weight: 500;
    transition: background .15s, color .15s;
}

.app-nav .nav-link i {
    font-size: 1.15rem;
    width: 1.3rem;
    text-align: center;
}

.app-nav .nav-link:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
}

.app-nav .nav-link.active {
    background: linear-gradient(135deg, var(--app-primary), #6d28d9);
    color: #fff;
    box-shadow: 0 6px 16px rgba(79, 70, 229, .35);
}

.app-sidebar-foot {
    margin-top: auto;
    padding: 1rem 1.25rem;
    font-size: .75rem;
    color: #64748b;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

/* ---------- 頂部列 ---------- */
.app-topbar {
    height: 64px;
    background: #fff;
    border-bottom: 1px solid var(--app-border);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.app-topbar .topbar-title {
    font-weight: 600;
    font-size: 1.05rem;
    margin: 0;
}

.app-user {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .9rem;
}

.app-user .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--app-primary), #7c3aed);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 600;
}

/* ---------- 內容區 ---------- */
.app-content {
    padding: 1.75rem 1.5rem;
    max-width: 1200px;
    width: 100%;
}

/* ---------- 卡片 / 表格 微調 ---------- */
.card {
    border: 1px solid var(--app-border);
    border-radius: 14px;
}

.card.shadow-sm {
    box-shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04) !important;
}

.table > :not(caption) > * > * {
    padding: .85rem 1rem;
}

.table thead th {
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--app-muted);
    font-weight: 600;
    border-bottom-width: 1px;
}

.table tbody tr:hover {
    background: #f9fafb;
}

/* ---------- 統計卡 ---------- */
.stat-card {
    border-radius: 16px;
    border: 1px solid var(--app-border);
    background: #fff;
    padding: 1.25rem 1.4rem;
    height: 100%;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .05);
}

.stat-card .stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 1.4rem;
}

.stat-card .stat-label {
    color: var(--app-muted);
    font-size: .85rem;
    margin: 0;
}

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    margin: .15rem 0 0;
    letter-spacing: -.5px;
}

.tone-income { color: var(--app-income); }
.tone-outcome { color: var(--app-outcome); }
.tone-primary { color: var(--app-primary); }

.bg-income-soft { background: #dcfce7; color: var(--app-income); }
.bg-outcome-soft { background: #fee2e2; color: var(--app-outcome); }
.bg-primary-soft { background: #e0e7ff; color: var(--app-primary); }
.bg-info-soft { background: #cffafe; color: #0891b2; }

/* ---------- 頁首區塊 ---------- */
.page-head h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 .2rem;
}

.page-head p {
    color: var(--app-muted);
    margin: 0;
    font-size: .92rem;
}

/* ---------- 登入頁 ---------- */
.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(124, 58, 237, .25), transparent),
        radial-gradient(1000px 600px at 110% 110%, rgba(79, 70, 229, .3), transparent),
        #0f172a;
}

.login-card {
    width: 100%;
    max-width: 410px;
    background: #fff;
    border-radius: 20px;
    padding: 2.4rem 2.2rem;
    box-shadow: 0 30px 60px -20px rgba(2, 6, 23, .6);
}

.login-card .brand-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--app-primary), #7c3aed);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 1.7rem;
    margin: 0 auto 1rem;
}

.btn-brand {
    background: linear-gradient(135deg, var(--app-primary), #6d28d9);
    border: none;
    color: #fff;
}

.btn-brand:hover {
    background: linear-gradient(135deg, var(--app-primary-dark), #5b21b6);
    color: #fff;
}

/* ---------- 表單 ---------- */
.form-label {
    font-weight: 600;
    font-size: .88rem;
    color: #374151;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 .2rem rgba(79, 70, 229, .15);
}

/* =====================================================================
   財務管理課程模組
   ===================================================================== */

/* ---------- 側邊欄群組小標題 ---------- */
.app-nav .nav-section {
    padding: 1rem .85rem .35rem;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #64748b;
}

/* ---------- 課程總覽地圖 ---------- */
.course-part-head {
    display: flex;
    align-items: baseline;
    gap: .7rem;
    margin-bottom: .9rem;
    padding-bottom: .5rem;
    border-bottom: 2px solid var(--app-border);
}

.course-part-no {
    background: var(--app-primary);
    color: #fff;
    font-size: .75rem;
    font-weight: 600;
    padding: .2rem .6rem;
    border-radius: 999px;
}

.course-part-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
}

.chapter-card {
    display: flex;
    align-items: center;
    gap: .9rem;
    height: 100%;
    padding: 1.1rem 1.2rem;
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 14px;
    text-decoration: none;
    color: var(--app-ink);
    box-shadow: 0 1px 3px rgba(16, 24, 40, .05);
    transition: transform .15s, box-shadow .15s, border-color .15s;
}

.chapter-card:hover {
    transform: translateY(-2px);
    border-color: var(--app-primary);
    box-shadow: 0 12px 24px -12px rgba(79, 70, 229, .4);
    color: var(--app-ink);
}

.chapter-card-icon {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    font-size: 1.4rem;
    background: var(--bg-primary-soft, #e0e7ff);
    color: var(--app-primary);
}

.chapter-card-body { flex: 1 1 auto; min-width: 0; }
.chapter-card-no { font-size: .72rem; color: var(--app-muted); font-weight: 600; }
.chapter-card-title { font-weight: 700; font-size: 1.02rem; margin: .1rem 0 .35rem; }
.chapter-card-summary {
    font-size: .82rem;
    color: var(--app-muted);
    margin: 0 0 .6rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.chapter-card-tags { display: flex; flex-wrap: wrap; gap: .3rem; }
.chapter-card-tags .badge { font-weight: 500; }
.chapter-card-arrow { color: #cbd5e1; font-size: 1.1rem; flex: 0 0 auto; }

/* ---------- 章節分頁 ---------- */
.course-tabs {
    gap: .4rem;
    border-bottom: 1px solid var(--app-border);
    padding-bottom: .75rem;
}
.course-tabs .nav-link {
    color: var(--app-muted);
    font-weight: 600;
    border-radius: 10px;
    padding: .5rem 1rem;
}
.course-tabs .nav-link:hover { background: #eef2ff; color: var(--app-primary); }
.course-tabs .nav-link.active { background: var(--app-primary); color: #fff; }

/* ---------- 概念知識頁 ---------- */
.concept-section { margin-bottom: 2.25rem; }
.concept-h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    padding-left: .7rem;
    border-left: 4px solid var(--app-primary);
}
.concept-h3 { font-size: 1.02rem; font-weight: 700; margin: 0 0 .5rem; }

.concept-card {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 14px;
    padding: 1.3rem;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .05);
}
.concept-card p { font-size: .9rem; color: #4b5563; margin: 0; }
.concept-card-soft { background: linear-gradient(135deg, #eef2ff, #f5f3ff); border-color: #e0e7ff; }

.concept-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 1.3rem;
    margin-bottom: .8rem;
}

.concept-card-num { position: relative; }
.concept-num {
    position: absolute;
    top: 1rem;
    right: 1.1rem;
    font-size: 2rem;
    font-weight: 800;
    color: #eef2ff;
    line-height: 1;
}

.concept-list { margin: 0; padding-left: 1.1rem; }
.concept-list li { font-size: .9rem; color: #4b5563; margin-bottom: .35rem; }

.concept-note {
    font-size: .88rem;
    color: var(--app-muted);
    margin-top: .9rem;
    padding: .7rem .9rem;
    background: #f9fafb;
    border-radius: 10px;
}

.concept-flow { display: flex; flex-wrap: wrap; gap: .9rem; }
.concept-flow-item {
    flex: 1 1 240px;
    display: flex;
    gap: .8rem;
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 14px;
    padding: 1.2rem;
}
.concept-flow-no {
    flex: 0 0 auto;
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--app-primary);
    color: #fff;
    font-weight: 700;
    display: grid; place-items: center;
}

.concept-highlight {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    border-radius: 16px;
    padding: 1.6rem 1.8rem;
}
.concept-highlight .concept-h2 { color: #fff; border-left-color: rgba(255, 255, 255, .6); }
.concept-highlight p { color: rgba(255, 255, 255, .92); font-size: .92rem; }
.concept-quote {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 .6rem;
}

.concept-formula {
    margin-top: .7rem;
    padding: .5rem .7rem;
    background: #0f172a;
    color: #a5b4fc;
    border-radius: 8px;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: .82rem;
}

.concept-closing {
    background: #fff;
    border: 1px dashed var(--app-primary);
    border-radius: 14px;
    padding: 1.2rem 1.4rem;
    color: #374151;
    font-size: .95rem;
}
.concept-closing .bi { color: var(--app-primary); font-size: 1.3rem; margin-right: .4rem; }

/* ---------- 第1章互動：資產負債表 ↔ 四大決策 ---------- */
.bs-table { border: 1px solid var(--app-border); border-radius: 14px; overflow: hidden; background: #fff; }
.bs-table-head, .bs-table-foot {
    background: #f9fafb;
    padding: .7rem 1rem;
    font-weight: 700;
    text-align: center;
}
.bs-table-foot { border-top: 1px solid var(--app-border); font-size: .85rem; color: var(--app-muted); }
.bs-col { padding: 1rem; }
.bs-col-asset { border-right: 1px solid var(--app-border); }
.bs-col-title { font-weight: 700; font-size: .85rem; margin-bottom: .6rem; }
.bs-item {
    display: block;
    width: 100%;
    text-align: left;
    border: 1px solid var(--app-border);
    background: #fff;
    border-radius: 10px;
    padding: .6rem .8rem;
    margin-bottom: .5rem;
    font-weight: 600;
    font-size: .9rem;
    cursor: pointer;
    transition: all .15s;
}
.bs-item small { display: block; font-weight: 400; font-size: .75rem; color: var(--app-muted); }
.bs-item:hover { border-color: var(--app-primary); }
.bs-item.active {
    border-color: var(--app-primary);
    background: #eef2ff;
    box-shadow: 0 4px 12px -4px rgba(79, 70, 229, .4);
}

.decision-panel { background: #fff; border: 1px solid var(--app-border); border-radius: 14px; padding: 1rem; height: 100%; }
.decision-panel-title { font-weight: 700; text-align: center; padding: .4rem 0 .8rem; }
.decision-item {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .8rem;
    border-radius: 10px;
    border: 1px solid transparent;
    margin-bottom: .5rem;
    transition: all .15s;
}
.decision-item .bi { font-size: 1.3rem; color: #cbd5e1; }
.decision-item small { display: block; font-size: .76rem; color: var(--app-muted); }
.decision-item.active {
    border-color: var(--app-primary);
    background: linear-gradient(135deg, #eef2ff, #f5f3ff);
}
.decision-item.active .bi { color: var(--app-primary); }

/* ---------- 自我測驗 ---------- */
.quiz-option { padding: .5rem .25rem; }
.quiz-option .form-check-input { cursor: pointer; }
.quiz-option .form-check-label { cursor: pointer; padding-left: .25rem; }

.quiz-score-ring {
    width: 120px; height: 120px;
    border-radius: 50%;
    display: grid; place-items: center;
    margin: 0 auto;
    font-size: 2.2rem; font-weight: 800;
    background: conic-gradient(currentColor 0, currentColor 100%, #eee 0);
    position: relative;
}
.quiz-score-ring::before {
    content: ""; position: absolute; inset: 10px; background: #fff; border-radius: 50%;
}
.quiz-score-ring small { position: relative; font-size: 1rem; }
.quiz-score-ring > * { position: relative; }

.quiz-review-options { list-style: none; margin: 0; padding: 0; }
.quiz-review-options li {
    padding: .5rem .8rem;
    border-radius: 8px;
    margin-bottom: .35rem;
    font-size: .9rem;
    background: #f9fafb;
}
.quiz-review-options li.is-answer { background: #dcfce7; }
.quiz-review-options li.is-wrong { background: #fee2e2; }
.tag-correct, .tag-yours {
    font-size: .7rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; margin-left: .4rem;
}
.tag-correct { background: var(--app-income); color: #fff; }
.tag-yours { background: var(--app-outcome); color: #fff; }
.quiz-explanation {
    margin-top: .6rem;
    padding: .6rem .8rem;
    background: #eff6ff;
    border-left: 3px solid #3b82f6;
    border-radius: 6px;
    font-size: .85rem;
    color: #1e40af;
}

/* ---------- TVM 計算器 ---------- */
.tvm-result {
    font-size: 2rem;
    font-weight: 800;
    color: var(--app-primary);
    letter-spacing: -.5px;
}
.tvm-formula {
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: .82rem;
    word-break: break-all;
}
