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

:root {
    --primary-color: #1e40af;
    --text-main: #0f172a;
    --text-muted: #4b5563;
    --border-color: #374151;
    --bg-light: #f9fafb;
}

body {
    background: #f3f4f6;
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 0;
}

.invoice-page-wrapper {
    width: 297mm;
    margin: 10px auto;
    background: #fff;
    display: flex;
    position: relative;
    border: 1px solid #e5e7eb;
}

.invoice-container {
    width: 50%;
    padding: 3mm 5mm; /* Very compact padding */
    box-sizing: border-box;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Watermark */
.invoice-container::before {
    content: 'PAID';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    font-size: 140px;
    font-weight: 800;
    color: rgba(30, 64, 175, 0.02);
    pointer-events: none;
    z-index: 0;
}

/* Middle Separator */
.invoice-page-wrapper::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 1px dashed #cbd5e1;
    z-index: 2;
}

/* Bill Details Bar */
.bill-details-bar {
    background: var(--primary-color);
    color: #fff;
    padding: 4px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 10px; /* Very compact */
    margin-bottom: 8px;
    text-transform: uppercase;
}

/* Header Main */
.header-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.header-left {
    width: 45%;
}

.logo-section img {
    max-height: 35px;
    margin-bottom: 2px;
}

.school-details h1 {
    font-size: 14px;
    margin: 0;
    color: var(--primary-color);
    font-weight: 700;
    line-height: 1;
}

.school-details p {
    font-size: 8px;
    margin: 0;
    color: var(--text-main);
}

.header-middle {
    width: 15%;
    text-align: center;
}

.bill-type {
    font-size: 8px;
    font-weight: 700;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 2px;
    display: inline-block;
}

.header-right {
    width: 40%;
    text-align: right;
}

.contact-grid {
    display: inline-grid;
    grid-template-columns: auto auto;
    font-size: 8.5px;
    column-gap: 5px;
    text-align: left;
}

.contact-label {
    font-weight: 700;
    color: var(--primary-color);
}

/* Student Info Grid - Density optimized */
.student-info-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 columns for multi-row items */
    gap: 4px 8px;
    margin-bottom: 10px;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
    padding: 6px 0;
}

.info-item {
    font-size: 9px;
    display: flex;
    flex-direction: column; /* Label above Value for more items */
}

.info-item .label {
    font-size: 8px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 1px;
}

.info-item .value {
    font-weight: 700;
    color: var(--text-main);
}

/* Main Table */
.table-area {
    flex: 1;
}

.main-invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
    font-size: 9px;
    border: 1px solid var(--border-color);
}

.main-invoice-table th {
    background: var(--primary-color);
    color: #fff;
    padding: 4px 2px;
    text-align: center;
    border: 0.5px solid #fff;
    font-weight: 600;
}

.main-invoice-table td {
    padding: 3px 4px;
    border: 0.5px solid var(--border-color);
}

.main-invoice-table tfoot td {
    font-weight: 700;
    background: #f9fafb;
    font-size: 9.5px;
}

/* Footer Section */
.invoice-footer-section {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 5px;
}

.footer-left {
    width: 50%;
}

.amt-words {
    font-size: 9.5px;
    margin: 0 0 4px 0;
    line-height: 1.1;
}

.system-msg {
    font-size: 8px;
    font-style: italic;
    color: var(--text-muted);
}

.total-paid-box {
    border: 1.5px solid var(--border-color);
    padding: 5px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 11px;
    background: #fff;
}

.total-label {
    min-width: 100px;
}

.total-value {
    color: var(--primary-color);
}

/* Print Overrides */
@media print {
    body { background: none; }
    .invoice-page-wrapper {
        width: 100%;
        margin: 0;
        box-shadow: none;
        border: none;
    }
    @page {
        size: landscape;
        margin: 3mm;
    }
    .print-actions { display: none; }
}

.print-actions {
    position: fixed;
    bottom: 10px;
    right: 10px;
    display: flex;
    gap: 10px;
}

.btn-print, .btn-back {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
}

.btn-print { background: var(--primary-color); color: #fff; border: none; }
.btn-back { background: #fff; color: #000; border: 1px solid #ccc; }

.text-right { text-align: right; }
.text-center { text-align: center; }

.btn-print {
    background: var(--primary-color);
    color: #fff;
    border: none;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(3, 45, 161, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-back {
    background: #fff;
    color: var(--text-main);
    border: 1px solid #cbd5e1;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
