/* ============================================
   CINTA FINANCE — BASE STYLES
   base.css
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- CSS Variables --- */
:root {
    --sidebar-w: 240px;
    --topbar-h: 60px;

    /* Brand Colors */
    --primary: #1a3a5c;
    --primary-light: #234e78;
    --accent: #e8a020;
    --accent-light: #f5b84c;
    --danger: #d63031;
    --success: #00b894;
    --warning: #fdcb6e;
    --info: #0984e3;

    /* Surfaces */
    --bg: #f0f2f7;
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --sidebar-bg: #0f2540;
    --sidebar-hover: #1a3a5c;
    --sidebar-active: #e8a020;

    /* Text */
    --text-primary: #1a2030;
    --text-secondary: #5a6a7e;
    --text-muted: #9aaabb;
    --text-light: #ffffff;
    --sidebar-text: #c8d8e8;
    --sidebar-label: #5a7898;

    /* Borders */
    --border: #e2e8f0;
    --border-dark: #c8d4e0;

    /* Shadows */
    --shadow-sm: 0 1px 4px rgba(0,0,0,0.08);
    --shadow: 0 2px 12px rgba(0,0,0,0.10);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.14);

    /* Typography */
    --font: 'Sora', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Radius */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { cursor: pointer; border: none; background: none; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transition: width 0.28s cubic-bezier(.4,0,.2,1);

    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar.collapsed{
    width:72px;
}

.sidebar.collapsed.hover-open{
    width:240px;
    box-shadow:0 12px 40px rgba(0,0,0,.25);
}

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    min-height: 72px;
}
.brand-icon {
    width: 36px; height: 36px;
    background: var(--accent);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 700; color: white;
    flex-shrink: 0;
}
.brand-text { overflow: hidden; white-space: nowrap; }
.brand-name {
    display: block;
    font-size: 15px; font-weight: 700;
    color: #fff;
    letter-spacing: 3px;
}
.brand-sub {
    display: block;
    font-size: 10px;
    color: var(--sidebar-label);
    letter-spacing: 1px;
    margin-top: 1px;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
    overflow-x: hidden;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.nav-section-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--sidebar-label);
    padding: 14px 18px 6px;
    white-space: nowrap;
    overflow: hidden;
}
.sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    color: var(--sidebar-text);
    font-size: 13px;
    font-weight: 400;
    border-radius: 0;
    transition: all 0.18s;
    white-space: nowrap;
    position: relative;
}
.nav-item:hover {
    background: var(--sidebar-hover);
    color: #fff;
}
.nav-item.active {
    background: rgba(232,160,32,0.15);
    color: var(--accent);
    font-weight: 600;
    border-right: 3px solid var(--accent);
}
.nav-icon {
    font-size: 15px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}
.nav-label { overflow: hidden; }

.sidebar.collapsed:not(.hover-open) .nav-label{
    opacity:0;
    width:0;
}

.sidebar.hover-open .nav-label{
    opacity:1;
    width:auto;
}

.sidebar.collapsed:not(.hover-open) .brand-text{
    display:none;
}

.sidebar.hover-open .brand-text{
    display:flex;
}

.sidebar.collapsed:not(.hover-open) .user-details,
.sidebar.collapsed:not(.hover-open) .logout-btn{
    opacity:0;
    width:0;
}

.sidebar.hover-open .user-details,
.sidebar.hover-open .logout-btn{
    opacity:1;
    width:auto;
}

.sidebar.collapsed:not(.hover-open) .nav-section-label{
    opacity:0;
}

.sidebar.hover-open .nav-section-label{
    opacity:1;
}

/* Footer */
.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-avatar {
    width: 34px; height: 34px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: var(--accent);
    flex-shrink: 0;
}
.user-details {
    overflow: hidden;
    white-space: nowrap;
    flex: 1;
}
.user-name { display: block; font-size: 12px; font-weight: 600; color: #fff; }
.user-role { display: block; font-size: 10px; color: var(--sidebar-label); }
.sidebar.collapsed .user-details, .sidebar.collapsed .logout-btn { opacity: 0; width: 0; overflow: hidden; }
.logout-btn { font-size: 16px; color: var(--sidebar-label); transition: color 0.18s; padding: 4px; }
.logout-btn:hover { color: var(--danger); }

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.28s cubic-bezier(.4,0,.2,1);
}
.main-content.expanded { margin-left: 72px; }

/* Topbar */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky; top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}
.sidebar-toggle {
    font-size: 18px;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.sidebar-toggle:hover { background: var(--bg); }
.topbar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}
.topbar-date {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}
.notif-badge {
    font-size: 13px;
    position: relative;
    cursor: pointer;
}
.notif-badge span {
    position: absolute;
    top: -4px; right: -6px;
    background: var(--danger);
    color: white;
    font-size: 9px;
    font-weight: 700;
    width: 14px; height: 14px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}

/* Page Body */
.page-body {
    padding: 24px;
    flex: 1;
}

/* ============================================
   SHARED COMPONENTS
   ============================================ */

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}
.page-header p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}
.page-header-actions { display: flex; gap: 10px; }

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
.card-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s;
    font-family: var(--font);
    border: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-light); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border-dark);
    color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11px; }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.badge-success { background: #d4f5ea; color: #00885e; }
.badge-danger { background: #fde8e8; color: #b52828; }
.badge-warning { background: #fef3d0; color: #a07000; }
.badge-info { background: #d6ecff; color: #0662b0; }
.badge-neutral { background: #edf0f5; color: #5a6a7e; }

/* Table */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
table.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 13px;
    background: var(--surface);
}
table.data-table thead {
    background: var(--primary);
    color: #fff;
}
table.data-table thead th {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.5px;
    text-align: center;
    white-space: nowrap;
}
table.data-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.12s;
    text-align: center;
}
table.data-table tbody tr:last-child { border-bottom: none; }
table.data-table tbody tr:hover { background: var(--surface-2); }
table.data-table tbody td {
    padding: 11px 16px;
    color: var(--text-primary);
    vertical-align: middle;
}
table.data-table .mono { font-family: var(--font-mono); font-size: 12px; }

/* Action Buttons in Table */
.action-btns { 
    display: flex;
    gap: 6px; 
    justify-content: center;
    align-items: center;
}

/* Form Elements */
.form-group { margin-bottom: 18px; }
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-primary);
    background: var(--surface);
    transition: border-color 0.18s;
    font-family: var(--font);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,58,92,0.08);
}
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235a6a7e'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 30px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

/* Filter Bar */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.filter-bar input, .filter-bar select {
    padding: 8px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font);
    background: var(--surface);
    color: var(--text-primary);
    min-width: 160px;
}
.filter-bar input:focus, .filter-bar select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px;
    height: 100%;
}
.stat-card.blue::before { background: var(--primary); }
.stat-card.gold::before { background: var(--accent); }
.stat-card.green::before { background: var(--success); }
.stat-card.red::before { background: var(--danger); }
.stat-card.purple::before { background: #6c5ce7; }

.stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
    line-height: 1;
}
.stat-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}
.stat-icon {
    position: absolute;
    top: 14px; right: 16px;
    font-size: 28px;
    opacity: 0.12;
}

/* Divider */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

/* Amount styles */
.amount-credit { color: var(--success); font-weight: 600; font-family: var(--font-mono); }
.amount-debit { color: var(--danger); font-weight: 600; font-family: var(--font-mono); }
.amount { font-family: var(--font-mono); font-weight: 600; }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.pagination-info { font-size: 12px; color: var(--text-muted); }
.pagination-btns { display: flex; gap: 6px; }
.page-btn {
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font);
}
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn:hover:not(.active) { border-color: var(--primary); color: var(--primary); }


.success-toast{
    position:fixed;
    bottom:20px;
    right:20px;

    background:#16a34a;
    color:#fff;

    padding:14px 20px;
    border-radius:10px;

    font-weight:600;

    display:none;
    z-index:9999;
}

.sidebar-brand{
    display:flex;
    align-items:center;
    gap:14px;
    padding:18px 16px;
    border-bottom:1px solid rgba(255,255,255,.08);
}

.brand-logo{

    width:52px;
    height:52px;

    border-radius:14px;

    overflow:hidden;

    background:#fff;

    display:flex;
    align-items:center;
    justify-content:center;

    box-shadow:0 8px 18px rgba(0,0,0,.18);

    flex-shrink:0;
}

.brand-logo img{

    width:100%;
    height:100%;

    object-fit:contain;

    padding:4px;
}

.brand-text{

    display:flex;
    flex-direction:column;
}

.brand-name{

    font-size:20px;
    font-weight:700;

    letter-spacing:1px;

    color:#fff;
}

.brand-sub{

    font-size:11px;

    color:rgba(255,255,255,.65);

    letter-spacing:.5px;

    text-transform:uppercase;
}


/* =========================
   Global Toast
========================= */

#toast-container{
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;

    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast{
    min-width: 320px;
    max-width: 420px;

    padding: 14px 18px;

    border-radius: 12px;

    color:#fff;
    font-size:14px;
    font-weight:500;

    box-shadow:0 12px 30px rgba(0,0,0,.15);

    transform:translateX(120%);
    opacity:0;

    transition:.35s ease;
}

.toast.show{
    transform:translateX(0);
    opacity:1;
}

.toast.success{
    background:#16a34a;
}

.toast.error{
    background:#dc2626;
}

.toast.warning{
    background:#d97706;
}

.toast.info{
    background:#2563eb;
}

/* ============================================
   FLATPICKR THEME — matches navy/gold brand
   ============================================ */
.flatpickr-calendar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-family: var(--font);
}
.flatpickr-months .flatpickr-month {
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius) var(--radius) 0 0;
    fill: #fff;
}
.flatpickr-current-month input.cur-year,
.flatpickr-current-month .flatpickr-monthDropdown-months {
    color: #fff;
}
.flatpickr-prev-month svg, .flatpickr-next-month svg { fill: #fff; }
.flatpickr-weekday {
    background: var(--surface);
    color: var(--text-muted);
}
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
    background: var(--accent);
    border-color: var(--accent);
}
.flatpickr-day.today { border-color: var(--accent); }
.flatpickr-day:hover { background: var(--surface-2); }

/* ============================================
   RESPONSIVE — MOBILE SIDEBAR (off-canvas)
   ============================================ */
@media (max-width: 768px) {

    .sidebar {
        width: 240px !important;   /* always full width when shown — ignore desktop collapsed state */
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(.4,0,.2,1);
        box-shadow: none;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    /* Full labels/icons always visible when the mobile sidebar is open —
       the desktop icon-only "collapsed" styling doesn't apply here */
    .sidebar .nav-label,
    .sidebar .brand-text,
    .sidebar .nav-section-label,
    .sidebar .user-details {
        opacity: 1 !important;
        width: auto !important;
        overflow: visible !important;
    }

    .main-content {
        margin-left: 0;   /* sidebar overlays instead of pushing content */
    }
    .main-content.expanded {
        margin-left: 0;
    }

    .page-body { padding: 16px; }
    .topbar { padding: 0 16px; }

    /* Dim backdrop behind the open mobile sidebar */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.4);
        z-index: 99;
    }
    .sidebar-backdrop.show { display: block; }
}

@media print {

    body * {
        visibility: hidden;
    }

    #receiptPaper,
    #receiptPaper * {
        visibility: visible;
    }

    #receiptPaper {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        box-shadow: none;
        border: none;
    }

    .receipt-actions {
        display: none !important;
    }

}


