/* ============================================
   BILLING SOFTWARE - MAIN STYLESHEET
   ============================================ */

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #3b82f6;
    --bg-light: #f1f5f9;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-light);
    color: #1e293b;
    min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 250px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h4 {
    margin: 0;
    color: white;
    font-weight: 600;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 14px;
}

.sidebar-menu li a:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.sidebar-menu li a.active {
    background: var(--sidebar-active);
    color: white;
    border-left: 3px solid white;
}

.sidebar-menu i {
    width: 20px;
    font-size: 16px;
}

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

/* ============ MAIN CONTENT ============ */
.main-content {
    margin-left: 250px;
    min-height: 100vh;
    transition: margin 0.3s;
}

.topbar {
    background: white;
    padding: 12px 24px;
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    gap: 15px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.content-area {
    padding: 24px;
}

/* ============ CARDS ============ */
.stat-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--card-shadow);
    border-left: 4px solid var(--primary);
}

.stat-card .label {
    font-size: 13px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
    margin: 8px 0;
    color: #0f172a;
}

.stat-card.success { border-left-color: #10b981; }
.stat-card.warning { border-left-color: #f59e0b; }
.stat-card.danger { border-left-color: #ef4444; }
.stat-card.info { border-left-color: #06b6d4; }

.data-card {
    background: white;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    margin-bottom: 20px;
}

.data-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.data-card-header h5 {
    margin: 0;
    font-weight: 600;
}

.data-card-body {
    padding: 20px;
}

/* ============ TABLES ============ */
.table {
    margin: 0;
}

.table thead th {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #475569;
    font-weight: 600;
}

.table td {
    vertical-align: middle;
}

/* ============ BADGES ============ */
.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-paid { background: #dcfce7; color: #166534; }
.status-unpaid { background: #fef3c7; color: #92400e; }
.status-partial { background: #dbeafe; color: #1e40af; }
.status-draft { background: #e2e8f0; color: #475569; }
.status-cancelled { background: #fee2e2; color: #991b1b; }

/* ============ INVOICE PRINT ============ */
.invoice-print {
    background: white;
    padding: 40px;
    max-width: 850px;
    margin: 20px auto;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 2px solid #2563eb;
    padding-bottom: 20px;
    margin-bottom: 25px;
}

.invoice-title {
    text-align: center;
    color: #dc2626;
    font-size: 24px;
    font-weight: 700;
    margin: 20px 0;
    letter-spacing: 2px;
}

.invoice-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.invoice-table th,
.invoice-table td {
    border: 1px solid #cbd5e1;
    padding: 10px;
    text-align: left;
}

.invoice-table th {
    background: #f1f5f9;
    font-weight: 600;
}

.invoice-table .text-end { text-align: right; }
.invoice-table .text-center { text-align: center; }

.invoice-totals {
    text-align: right;
    font-weight: 600;
}

.invoice-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    font-size: 13px;
}

.bank-details {
    background: #f8fafc;
    padding: 15px;
    border-left: 3px solid #2563eb;
}

/* ============ LOGIN ============ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-card h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #1e293b;
}

/* ============ FORMS ============ */
.form-label {
    font-weight: 500;
    font-size: 14px;
    color: #334155;
}

.form-control, .form-select {
    border: 1px solid #cbd5e1;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* ============ PRINT ============ */
@page {
    size: A4;
    margin: 0;
}

@media print {
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; color-adjust: exact !important; }
    html, body { width: 210mm; margin: 0 !important; padding: 0 !important; background: white !important; }
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; padding: 0 !important; }
    .content-area { padding: 0 !important; margin: 0 !important; }
    .invoice-print { box-shadow: none; margin: 0; max-width: 100%; }

    /* A4 page reset for print */
    .a4-page {
        width: 210mm !important;
        min-height: auto !important;
        height: auto !important;
        margin: 0 !important;
        padding: 10mm !important;
        box-shadow: none !important;
        page-break-after: always;
        page-break-inside: avoid;
    }
    .a4-page:last-of-type { page-break-after: auto; }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
}
