/* ─── Finance ERP — Production Stylesheet ─────────────────────────────────── */

/* Typography */
body {
    font-size: 0.875rem;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* Navbar */
.navbar-brand { font-size: 1rem; letter-spacing: 0.5px; }

/* Cards */
.card { border-radius: 0.5rem; }
.card-header { font-size: 0.85rem; }
.hover-card { transition: transform 0.15s ease, box-shadow 0.15s ease; cursor: pointer; }
.hover-card:hover { transform: translateY(-3px); box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.12) !important; }

/* Tables */
.table { font-size: 0.8125rem; }
.table th { font-weight: 600; white-space: nowrap; }
.table td { vertical-align: middle; }

/* Forms */
.form-label { font-size: 0.8125rem; margin-bottom: 0.25rem; }
.form-control, .form-select { font-size: 0.8125rem; }
.form-control-sm, .form-select-sm { font-size: 0.75rem; }

/* Badges */
.badge { font-size: 0.7rem; }

/* Login card */
.card .card-header.bg-primary { border-radius: 0.5rem 0.5rem 0 0 !important; }

/* Nav tabs in voucher entry */
.nav-tabs .nav-link { font-size: 0.8125rem; padding: 0.4rem 0.8rem; }
.nav-tabs .nav-link.active { font-weight: 600; }

/* Amount columns */
.text-end.text-success { color: #198754 !important; }
.text-end.text-danger  { color: #dc3545 !important; }

/* Alerts auto-dismiss */
.alert { font-size: 0.8125rem; }

/* Spinner centering */
.spinner-overlay {
    position: fixed; inset: 0;
    background: rgba(255,255,255,0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
}

/* DataTables overrides */
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
}
.dataTables_wrapper .dataTables_length select {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.2rem 0.4rem;
    font-size: 0.8125rem;
}

/* Print */
@media print {
    .navbar, .btn, form { display: none !important; }
    .card { border: none !important; box-shadow: none !important; }
}

/* ── Premium Navbar ─────────────────────────────────────────────────────── */
.nav-pill {
    display: flex; align-items: center; gap: .42rem;
    padding: .42rem .85rem; border-radius: 9px;
    color: rgba(255,255,255,.6); font-size: .82rem; font-weight: 500;
    text-decoration: none; border: none; background: none; cursor: pointer;
    transition: background .18s, color .18s, box-shadow .18s;
    white-space: nowrap; position: relative; letter-spacing: .01em;
}
.nav-pill:hover {
    background: rgba(255,255,255,.08);
    color: rgba(255,255,255,.95);
    box-shadow: 0 1px 0 rgba(255,255,255,.06) inset;
}
.nav-pill.active {
    background: rgba(59,130,246,.18);
    color: #60a5fa;
    box-shadow: 0 1px 0 rgba(59,130,246,.2) inset;
}
.nav-pill i:first-child { font-size: .76rem; }
.nav-arrow { font-size: .5rem !important; margin-left: .15rem; opacity: .5; transition: transform .2s; }
.nav-dd-wrap:hover .nav-arrow { transform: rotate(180deg); opacity: .9; }

/* Dropdown wrapper */
.nav-dd-wrap { position: relative; }
.nav-dd-wrap::after {
    content: ''; position: absolute;
    top: 100%; left: -10px; right: -10px;
    height: 20px;
    background: transparent;
    display: block; z-index: 9998;
}

/* Dropdown panel */
.nav-dd {
    display: none; position: absolute; top: 100%; left: 0;
    margin-top: 6px;
    background: linear-gradient(145deg, #1a2744 0%, #0f1f3d 100%);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 14px; padding: .5rem; min-width: 230px;
    box-shadow: 0 20px 60px rgba(0,0,0,.6),
                0 0 0 1px rgba(255,255,255,.04) inset;
    z-index: 9999;
    animation: ddSlide .15s cubic-bezier(.16,1,.3,1);
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    overflow-x: hidden;
}
@keyframes ddSlide {
    from { opacity:0; transform:translateY(-6px) scale(.98) }
    to   { opacity:1; transform:none }
}
.nav-dd::-webkit-scrollbar { width: 4px; }
.nav-dd::-webkit-scrollbar-track { background: transparent; }
.nav-dd::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

/* Dropdown section divider */
.nav-dd-sep {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.07), transparent);
    margin: .35rem .5rem;
}
.nav-dd-section-title {
    font-size: .58rem; font-weight: 700; color: #475569;
    text-transform: uppercase; letter-spacing: .6px;
    padding: .3rem .65rem .1rem;
}

/* Dropdown items */
.nav-dd-item {
    display: flex; align-items: center; gap: .65rem;
    padding: .48rem .75rem; border-radius: 9px; font-size: .81rem;
    color: rgba(255,255,255,.65); text-decoration: none; font-weight: 500;
    transition: background .12s, color .12s, transform .1s;
    white-space: nowrap; position: relative;
}
.nav-dd-item:hover {
    background: rgba(59,130,246,.15);
    color: #fff;
    transform: translateX(2px);
}
.nav-dd-item .dd-icon {
    width: 26px; height: 26px; border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: .72rem; flex-shrink: 0;
    background: rgba(255,255,255,.06);
    transition: background .12s;
}
.nav-dd-item:hover .dd-icon { background: rgba(59,130,246,.25); }
/* Breadcrumb bar */
.breadcrumb-bar {
    background: linear-gradient(135deg,#0f172a,#1a2744);
    padding: .45rem 1.5rem; border-bottom: 1px solid rgba(255,255,255,.06);
}
.breadcrumb-bar a { color: #64748b; font-size: .78rem; text-decoration: none; }
.breadcrumb-bar a:hover { color: #94a3b8; }
.breadcrumb-bar .sep { color: #334155; margin: 0 .4rem; font-size: .75rem; }
.breadcrumb-bar .cur { color: #e2e8f0; font-size: .78rem; font-weight: 600; }

/* ═══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — Finance ERP
   Breakpoints: 480px (xs), 640px (sm), 768px (md), 1024px (lg)
═══════════════════════════════════════════════════════════════ */

/* ── Fluid base ────────────────────────────────────────────── */
img, table { max-width: 100%; }
* { box-sizing: border-box; }

/* ── Sidebar overlay on mobile ─────────────────────────────── */
@media (max-width: 768px) {
  /* Sidebar slides in as overlay */
  .sb {
    transform: translateX(-100%) !important;
    width: 240px !important;
    transition: transform .25s ease !important;
    z-index: 500;
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }
  .sb.mob-open {
    transform: translateX(0) !important;
  }
  /* Content always full width */
  .main-area {
    margin-left: 0 !important;
    width: 100%;
  }
  /* Overlay backdrop */
  .sb-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 499;
  }
  .sb-backdrop.show { display: block; }
  /* Hide desktop toggle */
  .sb-toggle { display: none !important; }
  /* Top bar */
  .topbar { padding: 0 .75rem; height: 48px; }
  .topbar-fy { display: none; }
  .topbar-breadcrumb { font-size: .72rem; }
  /* Page content */
  .page-content { padding: .75rem; }
}

/* ── Dashboard ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Hero */
  .hero-row { flex-direction: column; gap: .75rem !important; }
  .hero-btns { flex-wrap: wrap; gap: .4rem; }
  .hbtn { padding: .42rem .85rem !important; font-size: .78rem !important; }
  /* Stat cards */
  .stat-grid { grid-template-columns: 1fr 1fr !important; gap: .5rem !important; }
  .stat-card  { padding: .75rem !important; }
  .stat-val   { font-size: 1.1rem !important; }
  /* Charts */
  .chart-grid { grid-template-columns: 1fr !important; }
  .chart-box  { min-height: 220px !important; }
  /* Report shortcuts */
  .rpt-grid   { grid-template-columns: 1fr 1fr !important; gap: .5rem !important; }
  .rpt        { padding: .65rem !important; }
  .rpt-title  { font-size: .78rem !important; }
  .rpt-ico    { width: 28px; height: 28px; font-size: .75rem; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr !important; }
  .rpt-grid  { grid-template-columns: 1fr !important; }
}

/* ── Tables → horizontal scroll ────────────────────────────── */
@media (max-width: 768px) {
  .table-responsive-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
  }
  /* Make all data tables scrollable on mobile */
  .st-card, .bk-card, .sc-card, .sr-card {
    overflow-x: auto;
  }
  table.st, table.sr, table.ht, table.rpt, table.it {
    min-width: 600px;
  }
}

/* ── Forms ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Stack grid columns */
  .hf-grid, .hf-grid2, .hf-grid4,
  .ui-field-grid, [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
  /* Full width inputs */
  .fl input, .fl select, .fl textarea {
    font-size: 16px !important; /* prevent iOS zoom */
  }
  /* Card bodies */
  .sc-card-body, .bk-card-body { padding: .75rem !important; }
  .bk-grid { grid-template-columns: 1fr !important; }
  /* Buttons */
  .btn-backup { width: 100%; justify-content: center; }
  .type-grid  { grid-template-columns: 1fr !important; }
}

/* ── Voucher Entry ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .ve-header-row { flex-wrap: wrap; gap: .5rem; }
  .ve-type-tabs  { flex-wrap: wrap; gap: .3rem; }
  .ve-type-btn   { padding: .35rem .7rem !important; font-size: .75rem !important; }
  /* Entry table scrollable */
  .ve-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.ve-table { min-width: 700px; }
  /* Footer buttons stack */
  .ve-footer { flex-wrap: wrap; gap: .4rem; }
  .ve-btn    { font-size: .76rem !important; padding: .38rem .75rem !important; }
}

/* ── Sales / Purchase list ─────────────────────────────────── */
@media (max-width: 768px) {
  .sp-header-row { flex-direction: column; gap: .6rem; }
  .sp-header-row .sp-actions { flex-wrap: wrap; gap: .4rem; }
  .sum-row   { grid-template-columns: 1fr 1fr !important; gap: .5rem !important; }
  .sum-card  { padding: .6rem .75rem !important; }
  .sum-val   { font-size: .95rem !important; }
}

/* ── Stock module ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sc-banner { flex-wrap: wrap; gap: .5rem; }
  .sc-banner h5 { font-size: .88rem; }
  table.it   { min-width: 800px; }
  .it-inp    { font-size: 16px !important; }
  .sc-footer { flex-wrap: wrap; }
  .totals-box { width: 100%; margin-left: 0 !important; }
}

/* ── Bank Reconciliation ───────────────────────────────────── */
@media (max-width: 768px) {
  .recon-grid { grid-template-columns: 1fr !important; }
  .sum-row    { grid-template-columns: repeat(2,1fr) !important; }
  .top-bar    { flex-wrap: wrap; gap: .4rem; }
  .top-bar h5 { font-size: .78rem; }
  .tbtn       { font-size: .72rem !important; padding: .32rem .7rem !important; }
  .match-bar  { flex-wrap: wrap; }
}

/* ── Cheque Print ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .cp-grid { grid-template-columns: 1fr !important; }
}

/* ── Reports / Ledger ──────────────────────────────────────── */
@media (max-width: 768px) {
  .sr-filter, .rpt-filter, .st-filter { flex-wrap: wrap; gap: .4rem !important; }
  .fl select, .fl input { min-width: unset !important; width: 100%; }
  .db-info-row { grid-template-columns: 1fr 1fr !important; }
}

/* ── User Management ───────────────────────────────────────── */
@media (max-width: 768px) {
  .um-grid    { grid-template-columns: 1fr !important; }
  .um-actions { flex-wrap: wrap; gap: .4rem; justify-content: flex-end; }
}

/* ── Utility helpers ───────────────────────────────────────── */
@media (max-width: 768px) {
  .hide-mobile  { display: none !important; }
  .full-mobile  { width: 100% !important; }
  .stack-mobile { flex-direction: column !important; }
}
@media (min-width: 769px) {
  .show-mobile-only { display: none !important; }
}

/* ── Touch improvements ────────────────────────────────────── */
@media (max-width: 768px) {
  /* Bigger tap targets */
  .sb-item   { padding: .55rem .9rem !important; }
  .sb-sub-item { padding: .45rem .9rem .45rem 2.5rem !important; }
  button, .btn, a.btn, input[type="submit"] {
    min-height: 40px;
  }
  /* Prevent text selection on buttons */
  button, .sb-item { user-select: none; -webkit-user-select: none; }
  /* Remove hover effects that don't work on touch */
  .bank-card:hover { transform: none !important; }
}

/* ── Print stays unchanged ─────────────────────────────────── */
@media print {
  .sb, .topbar, .sb-backdrop { display: none !important; }
  .main-area { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
}
