/* ================================================================
   Billing Management System - Global Stylesheet
   Responsive · Professional ERP · Cross-browser
   ================================================================ */

/* ── Reset & Base ────────────────────────────────────────────── */

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    background: #f2f4f7;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #334155;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Navbar ──────────────────────────────────────────────────── */

.navbar {
    padding: 0.5rem 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.navbar-brand {
    font-size: 1.05rem;
    letter-spacing: -0.3px;
    white-space: nowrap;
}

.navbar-toggler {
    border: 1px solid rgba(255,255,255,0.25);
    padding: 0.35rem 0.6rem;
}

.navbar-nav .nav-link,
.navbar .btn {
    white-space: nowrap;
}

.navbar .d-flex {
    gap: 0.4rem;
}

.navbar .dropdown-menu {
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    border: 1px solid rgba(0,0,0,0.08);
    padding: 4px;
}

.navbar .dropdown-item {
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
}

.navbar .dropdown-item.active {
    background: rgba(255,255,255,0.15);
}

/* ── Page Container ──────────────────────────────────────────── */

.container-fluid {
    max-width: 1920px;
}

/* ── Summary Cards ───────────────────────────────────────────── */

.summary-cards .card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: transform 0.15s, box-shadow 0.15s;
}

.summary-cards .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.summary-cards .card-body {
    padding: 14px 16px;
}

.summary-cards .card-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #64748b;
    margin-bottom: 4px;
}

.summary-cards .card-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
    word-break: break-word;
}

.summary-cards .border-accent-blue    { border-left: 4px solid #3b82f6 !important; }
.summary-cards .border-accent-green   { border-left: 4px solid #22c55e !important; }
.summary-cards .border-accent-info    { border-left: 4px solid #06b6d4 !important; }
.summary-cards .border-accent-danger  { border-left: 4px solid #ef4444 !important; }
.summary-cards .border-accent-warning { border-left: 4px solid #f59e0b !important; }
.summary-cards .border-accent-purple  { border-left: 4px solid #8b5cf6 !important; }

/* ── Filter / Search Card ────────────────────────────────────── */

.filter-card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.filter-card .card-body {
    padding: 12px 16px;
}

/* ── Content Card ────────────────────────────────────────────── */

.content-card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    overflow: hidden;
}

.content-card .card-header {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 16px;
    font-weight: 600;
}

.content-card .card-body {
    padding: 16px;
}

/* ── Table Container ─────────────────────────────────────────── */

.table-responsive {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ── ERP Table - Professional Header ─────────────────────────── */

.erp-table,
.table.table-bordered {
    border-collapse: collapse;
    width: 100%;
}

/* Header row */
.erp-table thead th,
.table.table-bordered thead th {
    background: #595959;
    color: #ffffff;
    font-size: 12px;
    font-weight: 500;
    padding: 20px 12px;
    vertical-align: middle;
    text-align: center;
    white-space: nowrap;
    border-top: 1px solid #999999;
    border-right: 1px solid #d4d4d4;
    border-bottom: 1px solid #000000;
    position: sticky;
    top: 0;
    z-index: 10;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.erp-table thead th:last-child,
.table.table-bordered thead th:last-child {
    border-right: none;
}

/* Text columns - left aligned in header */
.erp-table thead th.text-start,
.table.table-bordered thead th.text-start {
    text-align: left !important;
}

/* Numeric columns - right aligned in header */
.erp-table thead th.text-end,
.table.table-bordered thead th.text-end {
    text-align: right !important;
}

/* Header column width hints for main table */
.erp-table thead th.col-date     { min-width: 85px;  max-width: 100px; }
.erp-table thead th.col-model    { min-width: 100px; max-width: 130px; }
.erp-table thead th.col-supplier { min-width: 110px; max-width: 150px; }
.erp-table thead th.col-gw,
.erp-table thead th.col-qty,
.erp-table thead th.col-roll,
.erp-table thead th.col-rate     { min-width: 65px;  max-width: 80px; }
.erp-table thead th.col-bill-amount,
.erp-table thead th.col-packing,
.erp-table thead th.col-container { min-width: 90px; max-width: 110px; }
.erp-table thead th.col-ta       { min-width: 70px;  max-width: 90px; }
.erp-table thead th.col-total    { min-width: 90px;  max-width: 110px; }
.erp-table thead th.col-payment  { min-width: 85px;  max-width: 100px; }
.erp-table thead th.col-advance  { min-width: 110px; max-width: 140px; }
.erp-table thead th.col-due      { min-width: 85px;  max-width: 100px; }
.erp-table thead th.col-payby    { min-width: 75px;  max-width: 95px; }
.erp-table thead th.col-action   { min-width: 100px; max-width: 120px; }

/* ── Table Body ──────────────────────────────────────────────── */

.erp-table tbody td,
.table.table-bordered tbody td {
    padding: 10px 12px;
    vertical-align: middle;
    font-size: 13px;
    color: #334155;
    border-color: #e5e7eb;
    border-right: 1px solid #e5e7eb;
}

.erp-table tbody td:last-child,
.table.table-bordered tbody td:last-child {
    border-right: none;
}

.erp-table tbody tr,
.table.table-bordered tbody tr {
    transition: background 0.15s;
}

.erp-table tbody tr:hover,
.table.table-bordered tbody tr:hover {
    background: #f0f5ff;
}

.erp-table tbody tr:nth-child(even),
.table.table-bordered tbody tr:nth-child(even) {
    background: #fafbfc;
}

.erp-table tbody tr:nth-child(even):hover,
.table.table-bordered tbody tr:nth-child(even):hover {
    background: #f0f5ff;
}

/* Table footer */
.table.table-bordered tfoot tr {
    background: #e0f2fe !important;
}

.table.table-bordered tfoot td {
    font-weight: 600;
    padding: 10px 12px;
    border-color: #e5e7eb;
    border-right: 1px solid #e5e7eb;
}

.table.table-bordered tfoot td:last-child {
    border-right: none;
}

/* ── Table Cell Modifiers ────────────────────────────────────── */

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-size: 13px;
}

.erp-table .col-date,
.table.table-bordered .col-date {
    white-space: nowrap;
    font-size: 12px;
    color: #64748b;
}

.erp-table .col-model,
.table.table-bordered .col-model {
    font-weight: 500;
    color: #1e293b;
}

.erp-table .col-supplier,
.table.table-bordered .col-supplier {
    color: #475569;
}

.erp-table .col-total,
.table.table-bordered .col-total {
    font-weight: 600;
    color: #0f172a;
}

.col-action {
    white-space: nowrap;
    text-align: center !important;
    font-size: 12px;
}

.col-payby {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #64748b;
}

.empty-state {
    padding: 48px 20px;
    color: #94a3b8;
    font-size: 14px;
}

/* ── Due Amount Colors ───────────────────────────────────────── */

.due-pos {
    color: #dc2626;
    font-weight: 700;
}

.due-zero {
    color: #16a34a;
    font-weight: 700;
}

/* ── Form Styles ─────────────────────────────────────────────── */

.card .form-label {
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    margin-bottom: 4px;
}

.readonly-field {
    background: #f3f4f6 !important;
}

/* ── Alert Styles ────────────────────────────────────────────── */

.alert {
    border-radius: 8px;
    font-size: 14px;
}

/* ── Button Consistency ──────────────────────────────────────── */

.btn-sm {
    font-size: 12.5px;
    padding: 4px 10px;
    border-radius: 6px;
}

/* ── Page Title ──────────────────────────────────────────────── */

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 1rem;
}

/* ================================================================
   RESPONSIVE BREAKPOINTS
   ================================================================ */

/* ── Large screens (1200px+) ─────────────────────────────────── */
@media (min-width: 1200px) {
    .summary-cards .card-value {
        font-size: 1.4rem;
    }
}

/* ── Laptops (992px - 1199px) ────────────────────────────────── */
@media (max-width: 1199px) {
    .summary-cards .card-value {
        font-size: 1.2rem;
    }
}

/* ── Tablets (768px - 991px) ─────────────────────────────────── */
@media (max-width: 991px) {
    .navbar .d-flex {
        flex-wrap: wrap;
        gap: 0.3rem;
    }

    .navbar .btn {
        font-size: 11.5px;
        padding: 3px 8px;
    }

    .summary-cards .card-value {
        font-size: 1.1rem;
    }

    .summary-cards .card-label {
        font-size: 10px;
    }

    .erp-table thead th,
    .table.table-bordered thead th {
        font-size: 11px;
        padding: 16px 8px;
    }

    .erp-table tbody td,
    .table.table-bordered tbody td {
        font-size: 12px;
        padding: 8px 8px;
    }

    .num {
        font-size: 12px;
    }

    .content-card .card-body {
        padding: 12px;
    }
}

/* ── Small tablets / Large phones (576px - 767px) ────────────── */
@media (max-width: 767px) {
    body {
        font-size: 13px;
    }

    .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }

    .navbar {
        padding: 0.4rem 0.75rem;
    }

    .navbar-brand {
        font-size: 0.95rem;
    }

    .navbar .btn {
        font-size: 11px;
        padding: 3px 7px;
    }

    .summary-cards .card-body {
        padding: 10px 12px;
    }

    .summary-cards .card-value {
        font-size: 1rem;
    }

    .summary-cards .card-label {
        font-size: 9.5px;
        letter-spacing: 0.2px;
    }

    .page-title {
        font-size: 1.1rem;
    }

    .filter-card .card-body {
        padding: 10px 12px;
    }

    .erp-table thead th,
    .table.table-bordered thead th {
        font-size: 10px;
        padding: 12px 6px;
    }

    .erp-table tbody td,
    .table.table-bordered tbody td {
        font-size: 11px;
        padding: 7px 6px;
    }

    .num {
        font-size: 11px;
    }

    .content-card .card-header {
        padding: 10px 12px;
        font-size: 14px;
    }

    .content-card .card-body {
        padding: 10px;
    }

    .alert {
        font-size: 13px;
        padding: 10px 14px;
    }
}

/* ── Mobile phones (max 575px) ───────────────────────────────── */
@media (max-width: 575px) {
    body {
        font-size: 12.5px;
    }

    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }

    .navbar-brand {
        font-size: 0.88rem;
    }

    .navbar-toggler {
        padding: 0.25rem 0.5rem;
    }

    .summary-cards .card-value {
        font-size: 0.95rem;
    }

    .summary-cards .card-label {
        font-size: 9px;
    }

    .summary-cards .card-body {
        padding: 8px 10px;
    }

    .erp-table thead th,
    .table.table-bordered thead th {
        font-size: 9px;
        padding: 10px 5px;
    }

    .erp-table tbody td,
    .table.table-bordered tbody td {
        font-size: 10.5px;
        padding: 6px 5px;
    }

    .num {
        font-size: 10.5px;
    }

    .btn-sm {
        font-size: 11px;
        padding: 3px 7px;
    }

    .form-control,
    .form-select {
        font-size: 13px;
        padding: 6px 10px;
    }

    .card .form-label {
        font-size: 12px;
    }
}

/* ================================================================
   PRINT STYLES
   ================================================================ */

@media print {
    .no-print,
    .print-bar,
    .navbar {
        display: none !important;
    }

    body {
        background: #fff;
        margin: 0;
        padding: 10px;
        font-size: 11px;
    }

    .summary-cards .card,
    .content-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .erp-table thead th,
    .table.table-bordered thead th {
        background: #595959 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .table {
        font-size: 0.85em;
    }

    .table-responsive {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
