/**
 * SERENENESS ENTERPRISE Accounting Academy
 * Corporate ERP Theme — Bootstrap 5.3
 */

:root {
    /* สีจากโลโก้ SERENENESS ENTERPRISE */
    --se-primary: #0066b3;
    --se-teal: #00a8c4;
    --se-accent: #7cb342;
    --se-success: #5a9e2f;
    --se-warning: #c9a227;
    --se-danger: #dc3545;
    --se-navy: #0a3d62;
    --sidebar-width: 280px;
    --sidebar-bg: linear-gradient(180deg, #0a3d62 0%, #0066b3 55%, #00a8c4 100%);
    --sidebar-hover: rgba(255, 255, 255, 0.12);
    --bs-primary: #0066b3;
    --bs-primary-rgb: 0, 102, 179;
    --bs-success: #5a9e2f;
    --bs-success-rgb: 90, 158, 47;
}

.btn-primary {
    --bs-btn-bg: var(--se-primary);
    --bs-btn-border-color: var(--se-primary);
    --bs-btn-hover-bg: #005291;
    --bs-btn-hover-border-color: #005291;
}

.bg-primary {
    background-color: var(--se-primary) !important;
}

.text-primary {
    color: var(--se-primary) !important;
}

.badge.bg-primary {
    background: linear-gradient(135deg, var(--se-teal), var(--se-accent)) !important;
}

body.app-body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f0f4f8;
    min-height: 100vh;
}

/* ========== Brand Logo ========== */
.brand-logo-img {
    object-fit: contain;
    display: block;
}

.brand-logo-img--sidebar {
    width: 56px;
    height: 56px;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.2));
}

.brand-logo-img--topbar {
    width: 36px;
    height: 36px;
}

.brand-logo-img--login {
    width: 140px;
    height: auto;
    max-height: 120px;
    margin: 0 auto;
}

.brand-logo-img--certificate {
    width: 120px;
    height: auto;
    margin: 0 auto;
}

.brand-logo-img--chat {
    width: 40px;
    height: 40px;
    background: #fff;
    border-radius: 8px;
    padding: 4px;
}

.brand-logo-img--compact {
    width: 48px;
    height: 48px;
}

.brand-mark {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-mark--login {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
}

.brand-mark-text strong {
    display: block;
    font-size: 1rem;
    letter-spacing: 0.04em;
    line-height: 1.2;
}

.brand-mark-text small {
    display: block;
    opacity: 0.85;
    font-size: 0.7rem;
}

.brand-mark--sidebar .brand-mark-text strong {
    color: #fff;
}

.brand-mark--sidebar .brand-mark-text small {
    color: rgba(255, 255, 255, 0.8);
}

.brand-mark--login .brand-mark-text strong {
    font-size: 1.15rem;
    color: var(--se-navy);
}

.brand-mark--login .brand-mark-text small {
    color: var(--se-teal);
    font-weight: 600;
}

.brand-tagline {
    display: block;
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 0.35rem;
}

/* ========== Login ========== */
.login-page {
    background: linear-gradient(145deg, #f8fbfd 0%, #e8f4fa 40%, #d4eef5 100%);
    position: relative;
}

.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('../images/logo.png') center /  min(70vw, 480px) no-repeat;
    opacity: 0.04;
    pointer-events: none;
}

.login-card {
    max-width: 460px;
    width: 100%;
    border-radius: 1.25rem;
    border: none;
    border-top: 4px solid var(--se-teal);
    box-shadow: 0 12px 40px rgba(0, 102, 179, 0.18);
    position: relative;
    z-index: 1;
}

.login-card .btn-primary {
    background: linear-gradient(135deg, var(--se-primary), var(--se-teal));
    border: none;
}

.login-card .btn-primary:hover {
    background: linear-gradient(135deg, #005291, #008fa8);
}

/* ========== Layout ========== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: #0a3d62;
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 1.25rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand {
    background: rgba(0, 0, 0, 0.15);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.5rem;
    overflow-y: auto;
}

.sidebar-nav .nav-link {
    color: rgba(255, 255, 255, 0.85);
    padding: 0.65rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    transition: background 0.2s;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    background: var(--sidebar-hover);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--se-accent);
}

.sidebar-section-label {
    padding: 0.85rem 1rem 0.35rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 0.35rem;
}

.sidebar-nav .nav-link--sim {
    font-size: 0.88rem;
    padding-left: 0.85rem;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-badge {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.9rem;
}

.user-badge i {
    font-size: 1.75rem;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.content-area {
    flex: 1;
}

.topbar {
    background: #fff;
    padding: 0.75rem 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ========== Stats ========== */
.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0;
}

.result-score {
    font-size: 2.5rem;
    font-weight: 700;
}

/* ========== VAT Simulator ========== */
.tax-result-card {
    background: linear-gradient(160deg, var(--se-primary), var(--se-teal) 50%, var(--se-navy));
}

.tax-result-card .result-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 1rem;
}

.tax-result-card .result-row.grand,
.tax-result-card .result-row.net {
    font-size: 1.15rem;
    font-weight: 600;
}

.tax-result-card .result-row.net strong {
    color: #c5e86c;
}

/* ========== Journal ========== */
.journal-table th,
.journal-table td {
    vertical-align: middle;
}

.explanation-card {
    border-left: 4px solid var(--se-teal);
}

.chat-header-brand {
    background: linear-gradient(135deg, var(--se-primary), var(--se-teal)) !important;
    border: none;
}

/* ========== Chat ========== */
.chat-container {
    min-height: 480px;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    max-height: 420px;
    overflow-y: auto;
    background: #f8fafc;
}

.chat-bubble {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.chat-bubble.bot {
    background: #fff;
    border: 1px solid #dee2e6;
    margin-right: auto;
    border-bottom-left-radius: 0.25rem;
}

.chat-bubble.user {
    background: var(--se-primary);
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: 0.25rem;
}

.chat-bubble.typing {
    opacity: 0.7;
    font-style: italic;
}

/* ========== Certificate ========== */
.certificate-wrapper {
    max-width: 800px;
}

.certificate-border {
    background: linear-gradient(135deg, var(--se-primary), var(--se-teal), var(--se-accent));
    padding: 8px;
    border-radius: 4px;
}

.certificate-inner {
    background: #fff;
    padding: 3rem 2rem;
}

.cert-logo {
    margin-bottom: 1rem;
}

.cert-logo .brand-logo-img--certificate {
    width: 160px;
}

.cert-org {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #0b2239;
}

.cert-sub {
    color: #6c757d;
    margin-bottom: 1.5rem;
}

.cert-title {
    font-size: 2rem;
    background: linear-gradient(90deg, var(--se-primary), var(--se-teal));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 1rem 0;
}

.cert-name {
    color: var(--se-primary);
    font-size: 1.75rem;
    margin: 1rem 0;
}

.cert-score strong {
    font-size: 2rem;
    color: var(--se-success);
    display: block;
}

.sign-line {
    border-top: 2px solid #333;
    width: 80%;
    margin: 0 auto 0.5rem;
}

/* ========== Quiz ========== */
.quiz-question-card {
    border-left: 4px solid var(--se-primary) !important;
}

.result-banner {
    border-radius: 1rem;
}

/* ========== Print ========== */
@media print {
    .sidebar,
    .topbar,
    .content-footer,
    .d-print-none,
    .page-header {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .certificate-wrapper {
        max-width: 100%;
    }
}

/* ========== Mobile ========== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    body.sidebar-open::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1035;
    }
}
