/* CSS Variables */
:root {
    --primary-color: #2563eb; /* Professional Blue */
    --text-dark: #1f2937;
    --text-medium: #4b5563;
    --text-light: #6b7280;
    --border-color: #e5e7eb;
    --bg-light: #f9fafb;
    --table-header-bg: #111827; /* Dark gray for table header */
    --table-header-text: #ffffff;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --font-family: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    color: var(--text-dark);
    background-color: #f3f4f6; /* Outer background */
    line-height: 1.5;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Main Container */
.invoice-container {
    background-color: #ffffff;
    width: 100%;
    max-width: 900px;
    padding: 32px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    border-radius: 4px; /* Optional slight rounding */
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 24px;
}

.header-left .company-name {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.header-left .company-address,
.header-left .company-contact {
    font-size: 0.875rem;
    color: var(--text-medium);
}

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

.bill-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
}

.header-info-grid {
    display: grid;
    grid-template-columns: auto auto;
    gap: 0.5rem 1rem;
    font-size: 0.9rem;
}

.header-info-grid .label {
    font-weight: 600;
    color: var(--text-medium);
    text-align: right;
}

.header-info-grid .value {
    font-weight: 500;
    color: var(--text-dark);
    text-align: right;
}

/* Party Details */
.details-box {
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 4px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 24px;
    margin-bottom: 32px;
}

.detail-row {
    display: flex;
    gap: 8px;
}

.detail-row .label {
    font-weight: 600;
    color: var(--text-medium);
    min-width: 100px;
}

.detail-row .value {
    color: var(--text-dark);
    font-weight: 500;
}

/* Expenses Table */
.table-container {
    margin-bottom: 32px;
    overflow-x: auto; /* Scroll table on small screens */
}

.expenses-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.expenses-table th,
.expenses-table td {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
}

.expenses-table thead th {
    background-color: var(--table-header-bg);
    color: var(--table-header-text);
    font-weight: 600;
    text-align: left;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.expenses-table .col-serial {
    width: 60px;
    text-align: center;
}

.expenses-table .col-amount {
    text-align: right;
    width: 150px;
}

.expenses-table tbody tr:nth-child(even) {
    background-color: #f8fafc;
}

.expenses-table td.amount-cell {
    text-align: right;
    font-family: 'Courier New', Courier, monospace; /* Align numbers better */
    font-weight: 600;
}

.total-row {
    font-weight: 700;
    border-top: 2px solid var(--text-dark);
}

.total-row .total-label {
    text-align: right;
    padding-right: 24px;
    font-size: 1.1rem;
}

.total-row .total-amount {
    text-align: right;
    font-size: 1.2rem;
    color: var(--primary-color);
}

/* Summary Section */
.summary-section {
    background-color: var(--bg-light);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 32px;
    border: 1px solid var(--border-color);
}

.amount-words {
    margin-bottom: 16px;
    font-size: 1rem;
}

.amount-words .label {
    font-weight: 700;
    color: var(--text-medium);
    margin-right: 8px;
}

.amount-words .value {
    font-style: italic;
    font-weight: 500;
    color: var(--text-dark);
    text-transform: capitalize;
}

.notes {
    font-size: 0.85rem;
    color: var(--text-light);
    border-top: 1px dashed var(--border-color);
    padding-top: 12px;
}

.notes p {
    margin-bottom: 4px;
}

/* Footer */
.footer {
    text-align: center;
    margin-top: auto;
}

.footer .divider {
    height: 1px;
    background-color: var(--border-color);
    width: 50%;
    margin: 0 auto 16px;
}

.footer p {
    font-size: 0.9rem;
    color: var(--text-medium);
    font-weight: 500;
}

/* Floating Action Buttons */
.fab-container {
    position: fixed;
    bottom: 32px;
    right: 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 100;
}

.fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background-color 0.2s;
}

.fab:hover {
    background-color: #1d4ed8;
    transform: translateY(-2px);
}

.fab:active {
    transform: translateY(0);
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
    body {
        padding: 0;
        background-color: white;
    }
    
    .invoice-container {
        box-shadow: none;
        border: none;
        padding: 16px;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 24px;
    }

    .header-right {
        text-align: left;
        width: 100%;
    }
    
    .header-info-grid {
        grid-template-columns: auto 1fr;
        text-align: left;
    }
    
    .header-info-grid .label,
    .header-info-grid .value {
        text-align: left;
    }

    .details-box {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .fab-container {
        bottom: 16px;
        right: 16px;
    }
    
    .fab {
        width: 48px;
        height: 48px;
    }
}

/* Print Styles */
@media print {
    body {
        background-color: white;
        padding: 0;
    }

    .invoice-container {
        box-shadow: none;
        border: none;
        padding: 0;
        width: 100%;
        max-width: 100%;
    }

    .fab-container {
        display: none !important;
    }

    /* Ensure backgrounds print correctly */
    .expenses-table thead th {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        background-color: #111827 !important;
        color: white !important;
    }
    
    .details-box, .summary-section {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        background-color: #f9fafb !important;
    }
}
