/* 
================================================================
PROJECT: PROFESSIONAL INVOICE MANAGEMENT SYSTEM
FILE: style.css (Final Corrected Version)
FEATURES: Strict A4, Margin Control, Background Support, Perfect Alignment
================================================================
*/

@import url('https://fonts.googleapis.com/css2?family=Tinos:wght@400;700&display=swap');

:root {
    --primary-color: #2c3e50;
    --accent-color: #3498db;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --light-bg: #f4f7f6;
    --white: #ffffff;
    --black: #000000;
}

/* 1. Global Reset & UI Styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-bg);
    margin: 0;
    color: #333;
}

nav {
    background: var(--primary-color);
    color: var(--white);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    position: sticky;
    top: 0;
    z-index: 1000;
}

nav .logo-link {
    color: var(--white);
    text-decoration: none;
    font-size: 1.4rem;
    font-weight: bold;
}

nav a {
    color: var(--white);
    text-decoration: none;
    margin-left: 20px;
    font-size: 0.95rem;
}

.container {
    max-width: 1000px;
    margin: 30px auto;
    padding: 25px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.1);
}

/* 2. Dashboard & Cards */
.card-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 25px;
    margin-top: 30px;
}

.card {
    background: var(--light-bg);
    width: 240px;
    padding: 50px 20px;
    text-align: center;
    border-radius: 100%;
    text-decoration: none;
    color: var(--primary-color);
    font-size: 1.3rem;
    font-weight: bold;
    box-shadow: 0 25px 25px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    border-bottom: 15px solid var(--accent-color);
}

.card:hover {
    transform: translateY(-10px);
    background: var(--accent-color);
    color: var(--white);
}

/* 3. STRICT A4 INVOICE LAYOUT (Output) */
.invoice-box {
    width: 210mm;
    height: 296mm; /* Fixed A4 Height */
    margin: 20px auto;
    background: var(--white);
    position: relative;
    box-sizing: border-box;
    overflow: hidden; /* Prevents 2nd page spillover */
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
    color: var(--black);
    font-family: 'Tinos', 'Times New Roman', serif;
}

/* Background digital letterhead layer */
.bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.invoice-content {
    position: relative;
    z-index: 2;
    padding: 20mm;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

/* Dynamic Top Margins */
.margin-5cm { padding-top: 30mm !important; }
.margin-8cm { padding-top: 50mm !important; }

/* 4. Perfect Alignment Table Logic */
.inv-main-table {
    width: 100%;
    border-collapse: collapse;
    border: 1.5px solid var(--black);
    table-layout: fixed; /* Crucial for vertical line alignment */
}

.inv-main-table th, 
.inv-main-table td {
    border: 1.2px solid var(--black);
    padding: 10px;
    font-size: 12pt;
    font-weight: normal; /* Default is normal */
}

/* Remove Grey Background from Header */
.inv-main-table th {
    background: var(--white) !important;
    text-align: center;
    text-transform: capitalize;
}

/* Column Ratios (75% Desc | 25% Amt) */
.col-desc { width: 75%; text-align: left; }
.col-amt { width: 25%; text-align: right; }

.col-descr { width: 73.5%; text-align: left; }
.col-amnt { width: 26.5%; text-align: right; }

/* Content row locks the table structure */
.content-row-box {
    vertical-align: top;
    padding: 0 !important;
}

.inner-table {
    width: 100%;
    height: 100%;
    border-collapse: collapse;
    border: none;
    margin-top: 0px;
}

.inner-table td {
    border: none;
    padding: 10px 12px;
    vertical-align: top;
    line-height: 1.5;
}

/* 5. Typography & Formatting Rules */
.bold-txt { font-weight: bold !important; }
.center-txt { text-align: center !important; }

/* Bank section styling */
.bank-details {
    margin-top: 40px;
    padding-top: 15px;
    border-top: 1px dashed #555;
    font-size: 12pt;
    line-height: 1.6;
}

.total-row td {
    padding: 15px 10px;
}

/* Double underline for total amount */
.double-line {
    border-bottom: 4px double var(--black);
    display: inline-block;
    padding-bottom: 2px;
}

/* 6. Form Components (Admin/Create) */
input, select, textarea {
    width: 100%;
    padding: 12px;
    margin: 8px 0;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 1rem;
}

.btn {
    padding: 12px 25px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    color: var(--white);
    text-decoration: none;
    display: inline-block;
    transition: background 0.3s;
}

.btn-blue { background: var(--accent-color); }
.btn-green { background: var(--success-color); }
.btn-orange { background: #f39c12; }
.btn-red { background: var(--danger-color); }

/* 7. PRINT ENGINE SETTINGS */
@media print {
    .no-print { display: none !important; }
    body { background: var(--white); }
    .invoice-box { 
        margin: 0; 
        box-shadow: none; 
        border: none; 
        width: 100%;
    }
    /* Forces background image and colors to show in print */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    @page {
        size: A4;
        margin: 0;
    }
}

table { width: 100%; border-collapse: collapse; margin-top: 20px; }
table th, table td { padding: 12px; border: 1px solid #ddd; text-align: left; }
table th { background: #eee; color: #333; }