@import url('https://fonts.googleapis.com/css2?family=Hind+Siliguri:wght@400;500;600;700&family=Inter:wght@400;500;600;700;800;900&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Hind Siliguri', sans-serif;
    background: #f0f4f8;
    color: #1a1a2e;
    font-size: 14px;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ================= Buttons ================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    border: none;
    transition: all .2s;
    white-space: nowrap;
}

.btn-primary { background: #1565C0; color: #fff; }
.btn-primary:hover { background: #0D47A1; box-shadow: 0 4px 12px rgba(21,101,192,.3); transform: translateY(-1px); }
.btn-success { background: #2E7D32; color: #fff; }
.btn-success:hover { background: #1B5E20; }
.btn-danger { background: #C62828; color: #fff; }
.btn-danger:hover { background: #B71C1C; }
.btn-warning { background: #F57F17; color: #fff; }
.btn-warning:hover { background: #E65100; }
.btn-secondary { background: #fff; color: #374151; border: 1.5px solid #d1d5db; }
.btn-secondary:hover { background: #f9fafb; }
.btn-whatsapp { background: #25D366; color: #fff; }
.btn-whatsapp:hover { background: #128C7E; }

.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-lg { padding: 13px 28px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

/* ================= Forms ================= */
.form-group { margin-bottom: 14px; }
.form-label {
    display: block;
    font-size: 11px;
    font-weight: 800;
    color: #374151;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: .4px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    font-size: 13px;
    font-family: inherit;
    color: #1a1a2e;
    background: #fff;
    transition: border-color .2s;
}

.form-control:focus {
    outline: none;
    border-color: #1565C0;
    box-shadow: 0 0 0 3px rgba(21,101,192,.1);
}

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ================= Cards ================= */
.card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    border: 1px solid #e5e7eb;
}

.card-header {
    padding: 16px 22px;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 { font-size: 14px; font-weight: 700; }
.card-body { padding: 22px; }

/* ================= Badges ================= */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-paid { background: #d1fae5; color: #065f46; }
.badge-draft { background: #f3f4f6; color: #6b7280; }
.badge-sent { background: #dbeafe; color: #1e40af; }
.badge-partial { background: #fef3c7; color: #92400e; }
.badge-overdue { background: #fee2e2; color: #991b1b; }
.badge-cancelled { background: #f3f4f6; color: #9ca3af; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-pro { background: linear-gradient(135deg,#F57F17,#FFD600); color: #1a1a2e; }
.badge-free { background: #f3f4f6; color: #6b7280; }

/* ================= Tables ================= */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    background: #f8faff;
    color: #1565C0;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 11px 14px;
    text-align: left;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid #f5f5f5; vertical-align: middle; }
tbody tr:hover td { background: #f8faff; }

/* ================= Stat cards ================= */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(145px,1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: #fff; border-radius: 14px; padding: 16px; border: 1px solid #e5e7eb; border-left: 4px solid #1565C0; }
.stat-icon { font-size: 24px; margin-bottom: 6px; }
.stat-value { font-size: 19px; font-weight: 800; }
.stat-label { font-size: 11px; color: #6b7280; margin-top: 2px; font-weight: 600; }

/* ================= Navbar & Layout ================= */
.navbar {
    background: linear-gradient(135deg,#0D47A1,#1565C0);
    color: #fff;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 2px 10px rgba(0,0,0,.15);
}

.navbar-brand { display: flex; align-items: center; gap: 9px; font-size: 19px; font-weight: 800; color: #fff; }
.navbar-menu { display: flex; align-items: center; gap: 6px; }
.navbar-menu a {
    color: rgba(255,255,255,.8);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    transition: all .2s;
}
.navbar-menu a:hover { background: rgba(255,255,255,.15); color: #fff; }

.layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar {
    width: 234px;
    background: #0D47A1;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: rgba(255,255,255,.7);
    font-size: 13px;
    font-weight: 500;
    transition: all .2s;
    border-right: 3px solid transparent;
}

.sidebar a:hover, .sidebar a.active {
    background: rgba(255,255,255,.12);
    color: #fff;
    border-right-color: #FFD600;
}

.sidebar .nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-section {
    padding: 7px 18px 3px;
    font-size: 10px;
    font-weight: 800;
    color: rgba(255,255,255,.35);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-top: 6px;
}

.sidebar-bottom { margin-top: auto; padding: 14px; border-top: 1px solid rgba(255,255,255,.1); }
.main-content { flex: 1; padding: 20px; overflow-x: hidden; }

/* ================= Page Components ================= */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.page-title { font-size: 19px; font-weight: 800; }
.page-subtitle { font-size: 12px; color: #6b7280; margin-top: 2px; }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 12px; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.gap-2 { gap: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: #9ca3af; font-size: 12px; }
hr { border: none; border-top: 1px solid #f0f0f0; margin: 16px 0; }

/* ================= Empty State ================= */
.empty-state { text-align: center; padding: 48px 20px; color: #9ca3af; }
.empty-state .ei { font-size: 42px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ================= Invoice Builder ================= */
.item-row td { padding: 5px 3px; }
.item-row input, .item-row select {
    padding: 7px 9px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 12px;
    width: 100%;
    background: #fff;
    font-family: inherit;
    transition: border-color .2s;
}
.item-row input:focus, .item-row select:focus { border-color: #1565C0; outline: none; background: #EFF6FF; }

.total-box { background: #F8FAFF; border: 1px solid #E3EEFF; border-radius: 12px; padding: 16px; }
.total-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; font-size: 13px; border-bottom: 1px solid #f0f0f0; }
.total-row:last-child { border: none; font-size: 17px; font-weight: 800; color: #1565C0; padding-top: 10px; }

/* ================= Template Cards ================= */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(130px,1fr)); gap: 10px; }
.tpl-card { border: 3px solid #e5e7eb; border-radius: 12px; overflow: hidden; cursor: pointer; transition: all .2s; position: relative; }
.tpl-card:hover { border-color: #1565C0; transform: translateY(-2px); box-shadow: 0 4px 16px rgba(21,101,192,.2); }
.tpl-card.selected { border-color: #1565C0; box-shadow: 0 0 0 3px rgba(21,101,192,.2); }
.tpl-hdr { padding: 14px; text-align: center; color: #fff; font-weight: 700; font-size: 11px; }
.tpl-bdy { padding: 8px; background: #fff; }
.tpl-line { height: 4px; border-radius: 3px; margin-bottom: 4px; opacity: .3; }
.tpl-name { font-size: 10px; font-weight: 800; color: #374151; text-align: center; padding: 4px 2px; }
.tpl-chk {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #1565C0;
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    display: none;
}
.tpl-card.selected .tpl-chk { display: flex; }

/* ================= Invoice Paper / View ================= */
.invoice-paper {
    max-width: 794px;
    margin: 0 auto;
    background: #fff;
    padding: 46px;
    box-shadow: 0 4px 24px rgba(0,0,0,.1);
    border-radius: 4px;
}

/* ================= Upgrade/Payment ================= */
.pm-card { border: 2px solid #e5e7eb; border-radius: 14px; padding: 20px; cursor: pointer; transition: all .2s; text-align: center; }
.pm-card:hover, .pm-card.selected { border-color: #1565C0; background: #EFF6FF; box-shadow: 0 4px 12px rgba(21,101,192,.15); }
.pm-icon { font-size: 38px; margin-bottom: 8px; }

/* ================= Responsive ================= */
@media(max-width: 768px) {
    .sidebar { display: none; }
    .stat-grid { grid-template-columns: repeat(2,1fr); }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .main-content { padding: 12px; }
    .navbar-menu a:not(.btn-sm) { display: none; }
    .invoice-paper { padding: 20px; }
}

/* ========================================================
   PRINT & PDF SETTINGS (100% Match with View)
   ======================================================== */
@media print {
    /* Force background colors and images to print perfectly */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    /* Hide UI elements that shouldn't be printed */
    .no-print, .navbar, .sidebar, .page-header { 
        display: none !important; 
    }

    /* Reset layout background and margins to be completely clean */
    body, html { 
        background: #fff !important; 
        margin: 0 !important; 
        padding: 0 !important; 
    }

    .layout, .main-content { 
        display: block !important; 
        width: 100% !important; 
        margin: 0 !important; 
        padding: 0 !important; 
        min-height: auto !important; 
        overflow: visible !important;
    }

    /* Keep the invoice paper padding but remove shadow and margins */
    .invoice-paper { 
        box-shadow: none !important; 
        margin: 0 !important; 
        padding: 46px !important; /* Keep internal padding so it looks like the view */
        max-width: 100% !important; 
        border: none !important; 
        page-break-after: avoid;
    }

    /* Page size and margin control */
    @page { 
        size: A4; 
        margin: 0mm; /* Browser default headers and footers will be hidden */
    }
}