/* ============================================================
   MAXIM MAINTENANCE SOLUTIONS — PROFESSIONAL LIGHT THEME
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Montserrat:wght@700;800;900&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
    --navy:          #0D1B4B;
    --navy-mid:      #1A237E;
    --navy-light:    #283593;
    --navy-fade:     #E8EAF6;
    --gold:          #F9A825;
    --gold-light:    #FFF8E1;
    --gold-border:   #FFE082;
    --accent-green:  #2E7D32;
    --accent-red:    #C62828;
    --accent-teal:   #00838F;
    --bg-page:       #F4F6FB;
    --bg-white:      #FFFFFF;
    --bg-grey:       #f2f4f8;
    --border:        #c9d0e6;
    --border-dark:   #9fa9cc;
    --text-dark:     #0D1B4B;
    --text-body:     #2C3E70;
    --text-muted:    #6B7AA1;
    --text-light:    #9EA9C4;
    --shadow-sm:     0 2px 8px rgba(13,27,75,0.07);
    --shadow-md:     0 6px 24px rgba(13,27,75,0.10);
    --shadow-lg:     0 12px 40px rgba(13,27,75,0.13);
    --radius-lg:     14px;
    --radius-md:     9px;
    --radius-sm:     5px;
    --transition:    all 0.22s ease;
}

/* ── Reset ─────────────────────────────────────────────── */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-page);
    color: var(--text-body);
    min-height: 100vh;
    font-size: 13px;
    line-height: 1.6;
}

/* ── TOP NAV ───────────────────────────────────────────── */
.top-nav {
    position: sticky; top: 0; z-index: 1000;
    background: var(--navy);
    border-bottom: 3px solid var(--gold);
    padding: 0 32px;
    display: flex; align-items: center; height: 62px; gap: 16px;
    box-shadow: 0 2px 12px rgba(13,27,75,0.18);
}
.top-nav-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.top-nav-brand svg { width: 36px; height: 36px; }
.brand-name {
    font-family: 'Montserrat', sans-serif; font-size: 15px; font-weight: 900;
    color: #fff; letter-spacing: 0.5px; display: block; line-height: 1.1;
}
.brand-sub {
    font-size: 9px; font-weight: 600; color: var(--gold);
    letter-spacing: 2px; text-transform: uppercase; display: block;
}
.nav-sep    { width: 1px; height: 28px; background: rgba(255,255,255,0.15); }
.nav-label  { font-size: 11px; color: rgba(255,255,255,0.50); font-weight: 500; }
.nav-spacer { flex: 1; }
.nav-actions { display: flex; gap: 8px; align-items: center; }

/* ── BUTTONS ───────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 8px 18px; border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 600;
    cursor: pointer; text-decoration: none; transition: var(--transition);
    letter-spacing: 0.2px; white-space: nowrap; line-height: 1;
    user-select: none;
}
.btn:active { transform: translateY(1px); filter: brightness(0.9); }

.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); box-shadow: 0 2px 4px rgba(13,27,75,0.1); }
.btn-primary:hover { background: var(--navy-mid); box-shadow: 0 4px 12px rgba(13,27,75,0.2); }

.btn-gold    { background: var(--gold); color: var(--navy); border-color: var(--gold); font-weight: 700; box-shadow: 0 2px 4px rgba(249,168,37,0.2); }
.btn-gold:hover { background: #F57F17; color: #fff; box-shadow: 0 4px 12px rgba(249,168,37,0.3); }

.btn-outline { background: transparent; color: var(--navy); border-color: var(--border-dark); }
.btn-outline:hover { background: var(--navy-fade); border-color: var(--navy); }

.btn-nav { background: rgba(255,255,255,0.10); color: #fff; border-color: rgba(255,255,255,0.15); }
.btn-nav:hover { background: rgba(255,255,255,0.20); }

.btn-success { background: #E8F5E9; color: var(--accent-green); border-color: #A5D6A7; }
.btn-success:hover { background: #C8E6C9; color: #1B5E20; }

.btn-danger  { background: #FFEBEE; color: var(--accent-red); border-color: #EF9A9A; }
.btn-danger:hover { background: var(--accent-red); color: #fff; border-color: var(--accent-red); box-shadow: 0 4px 12px rgba(198,40,40,0.2); }

.btn-sm { padding: 6px 12px; font-size: 11.5px; border-radius: 4px; }
.btn-lg { padding: 14px 30px; font-size: 15px; border-radius: 8px; }

/* ── PAGE WRAPPER ──────────────────────────────────────── */
.page-wrapper { max-width: 1160px; margin: 0 auto; padding: 30px 22px 60px; }

/* ── FLASH ─────────────────────────────────────────────── */
.flash {
    padding: 12px 18px; border-radius: var(--radius-sm);
    font-weight: 600; font-size: 13px; margin-bottom: 20px;
    display: flex; align-items: center; gap: 10px;
}
.flash-success { background: #E8F5E9; border: 1px solid #A5D6A7; color: #1B5E20; }
.flash-error   { background: #FFEBEE; border: 1px solid #EF9A9A; color: #B71C1C; }

/* ── PAGE HEADING ──────────────────────────────────────── */
.page-heading {
    display: flex; align-items: flex-end; justify-content: space-between;
    margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-heading h2 { font-family: 'Montserrat', sans-serif; font-size: 22px; font-weight: 900; color: var(--navy); }
.page-heading p  { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.page-heading-right { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── STATS CARDS ───────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 26px; }
.stat-card {
    background: var(--bg-white); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 20px;
    display: flex; align-items: center; gap: 16px;
    box-shadow: var(--shadow-sm); transition: var(--transition);
    border-top: 3px solid var(--stat-color, var(--navy));
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon {
    width: 46px; height: 46px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center; font-size: 18px;
    background: var(--stat-bg, var(--navy-fade)); color: var(--stat-color, var(--navy)); flex-shrink: 0;
}
.stat-data h3 { font-family: 'Montserrat', sans-serif; font-size: 26px; font-weight: 900; color: var(--navy); line-height: 1; }
.stat-data p  { font-size: 10.5px; color: var(--text-muted); margin-top: 3px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }

/* ── MAIN CARD ─────────────────────────────────────────── */
.main-card { background: var(--bg-white); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); overflow: hidden; }
.main-card-header { padding: 16px 22px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); background: var(--bg-grey); }
.main-card-header h3 { font-family: 'Montserrat', sans-serif; font-size: 14px; font-weight: 800; color: var(--navy); display: flex; align-items: center; gap: 8px; }
.main-card-header h3 i { color: var(--gold); }
.main-card-header span { font-size: 11px; color: var(--text-muted); }

/* ── DATA TABLE ────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th { padding: 11px 16px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-muted); border-bottom: 2px solid var(--border); text-align: left; background: var(--bg-grey); white-space: nowrap; }
.data-table tbody td { padding: 13px 16px; font-size: 12.5px; border-bottom: 1px solid var(--border); color: var(--text-body); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #F7F8FF; }
.slip-num-cell { font-family: 'Montserrat', sans-serif; font-size: 12px; font-weight: 800; color: var(--navy); }
.company-cell { font-weight: 600; color: var(--text-dark); }
.muted-cell   { color: var(--text-muted); font-size: 12px; }
.weight-cell  { font-weight: 700; text-align: right; color: var(--accent-teal); }

/* ── STATUS BADGES ─────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; }
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; display: inline-block; }
.badge-draft     { background: #E3F2FD; color: #1565C0; }
.badge-finalised { background: #E8F5E9; color: #2E7D32; }
.badge-shipped   { background: #FFF3E0; color: #E65100; }
.badge-archived  { background: #ECEFF1; color: #546E7A; }
.action-btns { display: flex; gap: 6px; align-items: center; justify-content: center; flex-wrap: nowrap; white-space: nowrap; }
.action-btns .btn { flex-shrink: 0; min-width: 80px; }

/* ── EMPTY STATE ───────────────────────────────────────── */
.empty-state { padding: 60px 20px; text-align: center; color: var(--text-muted); }
.empty-state i { font-size: 46px; opacity: 0.18; margin-bottom: 14px; display: block; }
.empty-state p { font-size: 14px; }
.empty-state a { color: var(--navy); font-weight: 700; text-decoration: none; }

/* ── FORM CARD ─────────────────────────────────────────── */
.form-card { background: var(--bg-white); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); overflow: hidden; margin-bottom: 24px; }
.form-card-header { padding: 16px 24px; background: var(--navy); border-bottom: 3px solid var(--gold); display: flex; align-items: center; gap: 10px; }
.form-card-header i  { color: var(--gold); font-size: 16px; }
.form-card-header h3 { font-family: 'Montserrat', sans-serif; font-size: 15px; font-weight: 800; color: #fff; }
.form-body { padding: 26px 28px; }

.section-title { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px; color: var(--navy-mid); margin: 26px 0 14px; display: flex; align-items: center; gap: 8px; }
.section-title i { color: var(--gold); font-size: 12px; }
.section-title::after { content:''; flex:1; height:1px; background: var(--border); }
.section-title:first-child { margin-top: 0; }

.form-grid   { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.form-grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 14px; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.field input, .field textarea, .field select {
    padding: 11px 15px; 
    border: 2px solid #5C6BC0; /* Distinct blue-grey border */
    border-radius: 6px; 
    font-family: 'Inter', sans-serif;
    font-size: 14px; 
    color: #000; 
    background: #fbfdff;
    outline: none; 
    transition: all 0.2s ease; 
    width: 100%;
}
.field input:hover, .field textarea:hover { border-color: var(--navy); background: #fff; }
.field input:focus, .field textarea:focus, .field select:focus { 
    background: #fff;
    border-color: #F9A825; /* Gold border on focus */
    box-shadow: 0 0 0 4px rgba(249,168,37,0.15); 
}
.field textarea { resize: vertical; min-height: 90px; }

.items-table-wrap { border: 1px solid var(--navy); border-radius: 8px; overflow: hidden; margin-top: 10px; }
.items-edit-table { width: 100%; border-collapse: collapse; }
.items-edit-table thead th { background: var(--navy); color: #fff; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.8px; padding: 12px 10px; text-align: left; }
.items-edit-table tbody tr { border-bottom: 2px solid #eee; }
.items-edit-table tbody td { padding: 10px 8px; background: #fff; }
.items-edit-table tbody td input { 
    background: #fafbff; 
    border: 2px solid #9FA8DA; /* Visible border for table inputs */
    border-radius: 4px; 
    padding: 9px 12px; 
    font-size: 14px; 
    color: #000; 
    font-weight: 500;
    width: 100%; 
    outline: none; 
    transition: all 0.2s; 
}
.items-edit-table tbody td input:focus { background: #fff; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(13,27,75,0.1); }
.items-edit-table tbody td input::placeholder { color: #888; }
.items-edit-table tbody td input::placeholder { color: #aaa; opacity: 1; }
.totals-row td { background: var(--navy-fade) !important; font-weight: 700; color: var(--navy) !important; font-size: 12.5px; padding: 10px 10px !important; border-top: 2px solid var(--border-dark); }
.item-actions { display: flex; gap: 10px; margin-top: 12px; }
.form-footer { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: center; }

/* ============================================================
   PRINT-READY SLIP — matches professional sample layout
   ============================================================ */
.slip-wrapper {
    background: #fff;
    border: 1px solid #aaa;
    border-radius: 2px;
    font-family: Arial, sans-serif;
    font-size: 11px;
    color: #000;
    max-width: 1050px;
    margin: 0 auto;
    /* Force background colors to show in print */
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

/* Header row: grey boxed title left, logo right */
.slip-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 25px;
    gap: 20px;
}
.slip-title-box {
    border: 1px solid #333;
    background: #D9D9D9 !important; /* Slightly darker grey for print visibility */
    padding: 18px 50px;
    text-align: center;
    min-width: 280px;
}
.slip-title-box h1 {
    font-family: Arial, sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: #000;
    text-transform: uppercase;
    letter-spacing: 2px;
    line-height: 1;
    margin: 0;
}
.slip-logo-area { display: flex; align-items: center; }

/* Meta strip: DATE | SALE ORDER | CUSTOMER REF */
.slip-meta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin: 0 25px;
    border: 1px solid #333;
}
.meta-cell {
    display: flex;
    align-items: stretch;
    border-right: 1px solid #333;
}
.meta-cell:last-child { border-right: none; }
.meta-label {
    background: #D9D9D9 !important;
    color: #000;
    font-size: 9px;
    font-weight: 700;
    padding: 7px 10px;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    border-right: 1px solid #333;
    min-width: 95px;
    line-height: 1.2;
    display: flex;
    align-items: center;
}
.meta-value {
    padding: 7px 12px;
    font-size: 11px;
    font-weight: 400;
    color: #000;
    display: flex;
    align-items: center;
}

/* Address boxes: SELLER | BUYER | SHIP TO */
.slip-addresses {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin: 12px 25px 0;
    border: 1px solid #333;
}
.address-box { border-right: 1px solid #333; display: flex; flex-direction: column; }
.address-box:last-child { border-right: none; }
.address-label {
    background: #D9D9D9 !important;
    color: #000;
    font-size: 9px;
    font-weight: 700;
    padding: 5px 10px;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    border-bottom: 1px solid #333;
}
.address-body { padding: 8px 10px; flex: 1; min-height: 100px; }
.address-body strong { font-size: 11px; font-weight: 700; color: #000; display: block; margin-bottom: 2px; }
.address-body p  { font-size: 10px; color: #111; line-height: 1.5; }
.address-body small { font-size: 9.5px; color: #333; display: block; margin-top: 3px; }

/* Shipment info row */
.slip-shipinfo {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin: 12px 25px 0;
    border: 1px solid #333;
}
.shipinfo-cell { border-right: 1px solid #333; }
.shipinfo-cell:last-child { border-right: none; }
.shipinfo-cell .meta-label {
    display: block;
    border-right: none;
    border-bottom: 1px solid #333;
    min-width: unset;
}
.shipinfo-cell .meta-value { display: block; padding: 6px 10px; height: 35px; }

/* Product table */
.slip-table-wrap { margin: 15px 25px 0; overflow-x: auto; }
.slip-table { width: 100%; border-collapse: collapse; border: 1px solid #333; }
.slip-table thead th {
    background: #D9D9D9 !important;
    color: #000;
    font-size: 9.5px;
    font-weight: 700;
    padding: 8px 10px;
    text-transform: uppercase;
    border: 1px solid #333;
    text-align: left;
    vertical-align: middle;
}
.slip-table thead .th-group { text-align: center; }
.slip-table thead .th-sub  { font-size: 9px; font-weight: 700; }
.slip-table tbody td {
    padding: 6px 10px;
    border: 1px solid #999;
    font-size: 10.5px;
    vertical-align: middle;
    color: #000;
}
.slip-table tfoot td {
    padding: 7px 10px;
    font-weight: 700;
    font-size: 11px;
    color: #000;
    border: 1px solid #333;
    background: #D9D9D9 !important;
}

/* Strict Monochrome for print compliance */
.qty-cell   { text-align: center; font-weight: 700; color: #000; }
.net-cell   { text-align: right;  font-weight: 400; color: #000; }
.gross-cell { text-align: right;  font-weight: 400; color: #000; }
.pkg-cell   { text-align: center; color: #000; }
.unit-cell  { text-align: center; color: #000; }
.row-num    { text-align: center; color: #000; font-size: 10px; }

.t-center { text-align: center !important; }
.t-right  { text-align: right !important; }
.t-bold   { font-weight: 700; }

.code-cell { font-family: Arial, sans-serif; font-size: 10px; color: #000; }

/* Slip footer area */
.slip-footer-area {
    padding: 20px 25px 25px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
}
.slip-footer-left .company-bold {
    font-weight: 700;
    font-size: 11px;
    display: block;
    margin-bottom: 2px;
}
.slip-footer-left p { font-size: 10px; color: #000; line-height: 1.6; }
.slip-footer-sigs { display: flex; gap: 40px; }
.sig-block p { font-size: 8.5px; color: #000; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 25px; font-weight: 700; }
.sig-line { border-top: 1px solid #000; padding-top: 4px; font-size: 9px; color: #111; width: 100%; min-width: 170px; }

/* ── PRINT ───────────────────────────────────────────────── */
@media print {
    /* Hide browser headers/footers (URL, date, title) */
    @page { 
        margin: 0; 
        size: A4 landscape;
    }
    
    body { 
        background: #fff !important; 
        margin: 0; 
        padding: 0;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* Add slim page margin so it fits on one sheet */
    .page-wrapper {
        margin: 0;
        padding: 0.8cm 1.2cm; /* Reduced padding to help fit one page */
        width: 100%;
        max-width: 100%;
    }

    .top-nav, .page-heading, .flash, .no-print, .btn { display: none !important; }
    
    .slip-wrapper { 
        box-shadow: none; 
        border: 1px solid #333; 
        border-radius: 0; 
        width: 100%; 
        margin: 0;
        page-break-inside: avoid; /* Prevent splitting the whole block */
    }

    /* Tighten vertical space for print */
    .slip-header { padding: 12px 20px; }
    .address-body { min-height: 80px; padding: 6px 10px; }
    .slip-footer-area { padding: 15px 25px; }
    .slip-table-wrap { margin-top: 10px; }
}

/* ── RESPONSIVE ────────────────────────────────────────── */
@media (max-width: 960px) {
    .stats-grid { grid-template-columns: repeat(2,1fr); }
    .form-grid  { grid-template-columns: 1fr 1fr; }
    .span-2     { grid-column: span 2; }
}
@media (max-width: 640px) {
    .stats-grid { grid-template-columns: 1fr; }
    .form-grid  { grid-template-columns: 1fr; }
    .span-2, .span-3 { grid-column: unset; }
    .top-nav { padding: 0 14px; }
    .page-wrapper { padding: 16px 14px 50px; }
    .slip-meta, .slip-addresses, .slip-shipinfo { grid-template-columns: 1fr; margin: 8px 10px 0; }
    .meta-cell, .address-box, .shipinfo-cell { border-right: none; border-bottom: 1.5px solid #888; }
    .slip-table-wrap { margin: 10px 10px 0; }
    .slip-header { padding: 14px 10px; flex-direction: column; }
    .slip-footer-area { padding: 12px 10px 16px; }
    .slip-title-box h1 { font-size: 20px; }
}

/* ── Animations ────────────────────────────────────────── */
@keyframes fadeUp { from { opacity:0; transform:translateY(14px); } to { opacity:1; transform:translateY(0); } }
.anim { animation: fadeUp 0.35s ease-out both; }
.d1 { animation-delay: .05s; }
.d2 { animation-delay: .10s; }
.d3 { animation-delay: .15s; }
.d4 { animation-delay: .20s; }
