/* =====================================================================
   MainLayout.css — Sidebar, Topbar, Nav styles
   External file เพื่อหลีกเลี่ยง Razor parser issues กับ @media / @keyframes
   ---------------------------------------------------------------------
   REDESIGN 2026-06: ink-teal sidebar + jade/gold accent + line icons
   พาเลต hardcode (ไม่พึ่ง flowiq-design.css เพื่อไม่ให้กระทบ app ทั้งระบบ)
     ink-teal : #0E1C18 -> #0A1512   line: rgba(255,255,255,.07)
     text     : #C2D2CB / muted #7E938B / faint #5C6F67
     brand    : #0B6E63 / #11a08f     active text+icon: #5fd6c4
     gold     : #BE8C2C / #d6a338
   ===================================================================== */

/* ── Font scope: sidebar/topbar ใช้ IBM Plex Sans Thai ───────────────────
   host มีกฎ * { font-family:'Sarabun' !important } จึงต้อง !important + scope
   (ส่วน content ของแอปยังเป็น Sarabun จนกว่าจะ port หน้าอื่น) */
.cfiq-sidebar, .cfiq-sidebar *,
.cfiq-topbar,  .cfiq-topbar * {
    font-family: 'IBM Plex Sans Thai', 'Sarabun', sans-serif !important;
}

/* ═══════════════════════════════════════════════════════════════════════
   SIDEBAR — ink-teal redesign
   ═══════════════════════════════════════════════════════════════════════ */
.cfiq-sidebar {
    width: 228px;
    min-width: 228px;
    height: 100vh;
    background: linear-gradient(178deg, #0E1C18, #0A1512);
    border-right: none;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

/* ── Main content ────────────────────────────────────────────────────── */
.cfiq-main {
    flex-grow: 1;
    min-height: 100vh;
    margin-left: 228px;
    min-width: 0;
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Logo area ───────────────────────────────────────────────────────── */
.sb-logo-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 14px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}
.sb-logo-box {
    width: 32px;
    height: 32px;
    background: linear-gradient(150deg, #0B6E63, #11a08f);
    border: none;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.5px;
    flex-shrink: 0;
    box-shadow: 0 3px 12px rgba(13,160,140,0.4);
}
.sb-brand-name { font-size: 15px; font-weight: 700; color: #fff; line-height: 1; }
.sb-brand-sub  { font-size: 10px; color: #5C6F67; margin-top: 2px; font-weight: 500; }

/* ── Search bar ──────────────────────────────────────────────────────── */
.sb-search-wrap {
    position: relative;
    padding: 10px 10px 6px;
    flex-shrink: 0;
}
.sb-search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-25%);
    color: #5C6F67;
    pointer-events: none;
    display: flex;
    align-items: center;
}
.sb-search-input {
    width: 100%;
    padding: 7px 28px 7px 32px;
    background: rgba(0,0,0,0.22);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    font-size: 12px;
    color: #C2D2CB;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s, background 0.15s;
}
.sb-search-input::placeholder { color: #5C6F67; }
.sb-search-input:focus {
    border-color: rgba(17,160,143,0.55);
    background: rgba(0,0,0,0.3);
}
.sb-search-clear {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-25%);
    background: none;
    border: none;
    color: #5C6F67;
    cursor: pointer;
    font-size: 11px;
    padding: 2px 4px;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.12s;
}
.sb-search-clear:hover { color: #C2D2CB; }

/* ── Nav list (scrollable + thin jade scrollbar) ─────────────────────── */
.sb-nav-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 8px 8px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(17,160,143,0.4) transparent;
}
.sb-nav-list::-webkit-scrollbar        { width: 3px; }
.sb-nav-list::-webkit-scrollbar-track  { background: transparent; }
.sb-nav-list::-webkit-scrollbar-thumb  { background: rgba(17,160,143,0.35); border-radius: 3px; }
.sb-nav-list::-webkit-scrollbar-thumb:hover { background: rgba(17,160,143,0.65); }

/* Section labels & dividers */
.sb-section-label {
    font-size: 9.5px;
    font-weight: 700;
    color: #5C6F67;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    padding: 12px 10px 4px;
    margin-top: 2px;
}
.sb-section-divider {
    height: 1px;
    background: rgba(255,255,255,0.07);
    margin: 4px 10px;
}
.sb-no-result {
    font-size: 12px;
    color: #5C6F67;
    text-align: center;
    padding: 20px 10px;
}

/* Nav link */
.sb-nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 8px;
    border-radius: 8px;
    font-size: 13px;
    color: #C2D2CB;
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
    cursor: pointer;
    white-space: nowrap;
    min-height: 36px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.sb-nav-link:hover {
    background: rgba(255,255,255,0.05);
    color: #ffffff;
    text-decoration: none;
}
.sb-nav-link.sb-active {
    background: linear-gradient(90deg, rgba(17,160,143,0.18), rgba(17,160,143,0.06));
    color: #ffffff;
    font-weight: 600;
}
.sb-nav-link.sb-active::before {
    content: "";
    position: absolute;
    left: -8px;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: #11a08f;
}
.sb-icon-wrap {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #7E938B;
    font-size: 14px;
    transition: color 0.12s;
}
.sb-icon-wrap svg { width: 18px; height: 18px; }
.sb-nav-link:hover .sb-icon-wrap { color: #C2D2CB; }
.sb-nav-link.sb-active .sb-icon-wrap { color: #5fd6c4; }
.sb-link-text { font-size: 13px; }

/* ── Footer ──────────────────────────────────────────────────────────── */
.sb-footer {
    flex-shrink: 0;
    padding: 8px;
    border-top: 1px solid rgba(255,255,255,0.07);
}

/* Plan row (gold accent) */
.sb-plan-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 10px;
    margin-bottom: 6px;
    background: linear-gradient(120deg, rgba(190,140,44,0.16), rgba(190,140,44,0.05));
    border: 1px solid rgba(190,140,44,0.28);
    border-radius: 8px;
}
.sb-plan-name  { font-size: 11px; font-weight: 700; color: #f3e6c8; letter-spacing: 0.2px; }
.sb-trial-days { font-size: 10px; color: #d6a338; font-weight: 600; }

/* Clickable plan badge → settings/subscription (rc24) */
.sb-plan-link { text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s; }
.sb-plan-link:hover { background: linear-gradient(120deg, rgba(190,140,44,0.26), rgba(190,140,44,0.10)); border-color: rgba(190,140,44,0.48); }
.sb-plan-right { display: flex; align-items: center; gap: 7px; }
.sb-plan-chevron { color: #d6a338; opacity: .75; flex-shrink: 0; transition: transform .15s, opacity .15s; }
.sb-plan-link:hover .sb-plan-chevron { transform: translateX(2px); opacity: 1; }

/* User card */
.sb-user-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
    margin-bottom: 6px;
}
.sb-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: #1c3a33;
    color: #7fe0cf;
    font-size: 13px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sb-user-info { flex: 1; min-width: 0; }
.sb-user-name {
    font-size: 12px;
    font-weight: 600;
    color: #eaf3ef;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sb-user-role { font-size: 10px; color: #5C6F67; margin-top: 1px; }
.sb-user-menu-btn {
    background: none;
    border: none;
    color: #5C6F67;
    cursor: pointer;
    padding: 4px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: color 0.12s, background 0.12s;
}
.sb-user-menu-btn:hover { color: #C2D2CB; background: rgba(255,255,255,0.08); }

/* Logout button */
.sb-logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 7px;
    background: rgba(255,255,255,0.04);
    border: none;
    border-radius: 8px;
    font-size: 12px;
    color: #7E938B;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.sb-logout-btn:hover {
    background: rgba(200,70,60,0.14);
    color: #f0a8a0;
}

/* ── Mobile (max 1099px) ─────────────────────────────────────────────── */
@media (max-width: 1099.98px) {
    .cfiq-sidebar {
        transform: translateX(-100%);
        box-shadow: none;
        pointer-events: none;
    }
    .cfiq-sidebar.cfiq-sidebar-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.4);
        pointer-events: auto;
    }
    .cfiq-main {
        margin-left: 0 !important;
    }
    .cfiq-topbar { display: flex !important; }
}

/* ── Top bar (mobile content bar — light) ────────────────────────────── */
.cfiq-topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    background: #fff;
    border-bottom: 1px solid #e8edf2;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    flex-shrink: 0;
}

/* ── Overlay ─────────────────────────────────────────────────────────── */
.cfiq-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1039;
    animation: cfiq-fadeIn 0.2s ease;
    touch-action: manipulation;
}
@keyframes cfiq-fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
.cfiq-hamburger {
    background: none;
    border: none;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #475569;
    transition: background 0.15s;
    padding: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.cfiq-hamburger:hover { background: #f4f6fb; }

.cfiq-topbar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #0B6E63;
    color: white;
    font-size: 13px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    margin-left: auto;
}

.cfiq-close-btn {
    background: rgba(255,255,255,0.08);
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 16px;
    color: #7E938B;
    transition: color 0.12s, background 0.12s;
}
.cfiq-close-btn:hover { color: #fff; background: rgba(255,255,255,0.15); }

/* ── Banners ─────────────────────────────────────────────────────────── */
.cfiq-banner { border-bottom: 1px solid transparent; flex-wrap: wrap; gap: 8px; }
.cfiq-banner-info    { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.cfiq-banner-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.cfiq-banner-danger  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.cfiq-banner-btn         { background: #0B6E63; color: white !important; border: none; border-radius: 6px; font-size: 12px; font-weight: 600; padding: 4px 14px; white-space: nowrap; }
.cfiq-banner-btn:hover   { background: #0a5f56; }
.cfiq-banner-btn-outline { background: transparent; color: #1e40af !important; border: 1px solid #93c5fd; border-radius: 6px; font-size: 12px; font-weight: 600; padding: 4px 14px; white-space: nowrap; }
.cfiq-banner-btn-outline:hover { background: #dbeafe; }

/* ── Plan badges (backward compat) ──────────────────────────────────── */
.cfiq-plan-badge   { font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 100px; letter-spacing: 0.3px; }
.plan-free         { background: #f1f5f9; color: #475569; }
.plan-starter      { background: #f0fdf4; color: #15803d; }
.plan-business     { background: #e0f5ef; color: #0B6E63; }
.plan-professional { background: #ede9fe; color: #6d28d9; }
.plan-enterprise   { background: #fef3c7; color: #92400e; }

/* ── Legacy nav classes (ไม่ได้ใช้แล้ว แต่คงไว้เผื่อ page อื่น ref) ── */
.cfiq-nav-list { overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
.cfiq-nav      { color: #64748b; font-size: 13px; font-weight: 500; text-decoration: none; display: flex; align-items: center; gap: 8px; transition: all 0.15s; min-height: 44px; }
.cfiq-nav:hover  { background: #f0faf8 !important; color: #0f6e56 !important; }
.cfiq-active     { background: #e1f5ee !important; color: #0f6e56 !important; font-weight: 600; }
.cfiq-section-label { font-size: 10px; font-weight: 700; color: #b0bec5; letter-spacing: 0.8px; text-transform: uppercase; }
.nav-icon { font-size: 14px; }

/* ─ Reconcile dot indicator (Transactions table) ──────────────────── */
.recon-dot {
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: help;
}
.recon-dot:hover {
    transform: scale(1.6);
}
.recon-confirmed {
    box-shadow: 0 0 0 2px rgba(15,110,86,0.2);
}
.recon-matched {
    box-shadow: 0 0 0 2px rgba(245,158,11,0.2);
}

/* =====================================================================
   Version Badge (Sidebar Footer)
   ===================================================================== */
.sb-version {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 10px;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(255,255,255,0.04);
    color: #5C6F67 !important;
    font-size: 10.5px;
    font-weight: 500;
    text-decoration: none !important;
    letter-spacing: 0.2px;
    transition: all .15s ease;
    cursor: pointer;
}
.sb-version:hover {
    background: rgba(255,255,255,0.08);
    color: #C2D2CB !important;
}
.sb-version-num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}
.sb-version-pre {
    background: rgba(214, 163, 56, 0.18);
    color: #d6a338;
    font-size: 8.5px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.6px;
    line-height: 1;
    text-transform: uppercase;
}
