/* FBR Tier-1 POS Master Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --primary-color: #0284c7;
    --primary-hover: #0369a1;
    --emerald-accent: #059669;
    --slate-dark: #0f172a;
    --slate-sidebar: #1e293b;
    --slate-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 20px -2px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 35px -4px rgba(15, 23, 42, 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-main);
    color: var(--slate-dark);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* ==========================================
   AUTHENTICATION LAYOUT
   ========================================== */
.auth-wrapper {
    min-height: 100vh;
    background: radial-gradient(circle at 10% 20%, rgba(2, 132, 199, 0.08) 0%, rgba(15, 23, 42, 0) 90%),
                linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.auth-card {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 440px;
    padding: 2.5rem;
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.auth-brand-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #0284c7, #0d9488);
    color: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.25rem;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

/* ==========================================
   MAIN DASHBOARD & SIDEBAR LAYOUT
   ========================================== */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--slate-sidebar);
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    z-index: 1000;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-brand-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: #ffffff;
    letter-spacing: -0.3px;
    margin: 0;
}

.sidebar-brand-sub {
    font-size: 0.72rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
}

.sidebar-nav {
    padding: 1rem 0.75rem;
    flex-grow: 1;
}

.nav-link-custom {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.8rem 1rem;
    color: #94a3b8;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.92rem;
    transition: all 0.2s ease;
    margin-bottom: 0.3rem;
}

.nav-link-custom:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.06);
}

.nav-link-custom.active {
    color: #ffffff;
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.main-content {
    flex-grow: 1;
    background-color: var(--bg-main);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.top-navbar {
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 38px;
    height: 38px;
    background-color: #e0f2fe;
    color: #0369a1;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================
   CARDS & STATS
   ========================================== */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    margin-bottom: 1rem;
}

.stat-icon.primary { background: #e0f2fe; color: #0284c7; }
.stat-icon.success { background: #dcfce7; color: #15803d; }
.stat-icon.warning { background: #fef3c7; color: #b45309; }
.stat-icon.purple  { background: #f3e8ff; color: #7e22ce; }

.stat-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--slate-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--slate-dark);
    margin-top: 0.25rem;
}

/* ==========================================
   STATUS BADGES
   ========================================== */
.badge-status {
    padding: 0.35em 0.75em;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 30px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.badge-status-synced {
    background-color: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.badge-status-pending {
    background-color: #fef3c7;
    color: #b45309;
    border: 1px solid #fde68a;
}

.badge-status-failed {
    background-color: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

/* ==========================================
   POS INTERFACE CALCULATOR
   ========================================== */
.pos-table-card {
    background: #ffffff;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.pos-table th {
    background-color: #f8fafc;
    color: var(--slate-muted);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.9rem 1rem;
    border-bottom: 2px solid var(--border-color);
}

.pos-table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
}

.pos-summary-card {
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
    color: #ffffff;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.12);
    font-size: 0.92rem;
    color: #cbd5e1;
}

.summary-row.grand-total {
    border-bottom: none;
    padding-top: 1rem;
    margin-top: 0.5rem;
    font-size: 1.4rem;
    font-weight: 800;
    color: #38bdf8;
}

/* ==========================================
   THERMAL RECEIPT PRINT STYLING (80mm)
   ========================================== */
.receipt-wrapper {
    background-color: #ffffff;
    padding: 1.5rem;
    max-width: 340px;
    margin: 0 auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: #000000;
    line-height: 1.4;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
}

.receipt-header {
    text-align: center;
    border-bottom: 1px dashed #000;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.receipt-logo {
    max-width: 90px;
    height: auto;
    margin-bottom: 6px;
}

.receipt-title {
    font-weight: 800;
    font-size: 15px;
    text-transform: uppercase;
}

.receipt-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 11px;
}

.receipt-table th {
    border-bottom: 1px solid #000;
    text-align: left;
    padding: 4px 0;
}

.receipt-table td {
    padding: 4px 0;
}

.receipt-divider {
    border-top: 1px dashed #000;
    margin: 8px 0;
}

.receipt-qr-box {
    text-align: center;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed #000;
}

.receipt-qr-code {
    display: inline-block;
    padding: 6px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
}

.receipt-offline-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
    padding: 8px;
    font-weight: 700;
    font-size: 10px;
    text-align: center;
    border-radius: 4px;
    margin-top: 8px;
}

/* ==========================================
   A4 SHEET TAX INVOICE PRINT STYLES
   ========================================== */
@page {
    size: A4 portrait;
    margin: 0;
}

.a4-invoice-wrapper {
    background: #ffffff;
    color: #0f172a;
    padding: 16px 20px;
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    box-sizing: border-box;
}

.a4-header {
    border-bottom: 2px solid #0284c7;
    padding-bottom: 8px;
    margin-bottom: 10px;
}

.a4-badge-fbr {
    background-color: #0f172a;
    color: #38bdf8;
    padding: 4px 10px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: inline-block;
}

.a4-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
}

.a4-table th {
    background-color: #f1f5f9;
    color: #334155;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 6px 8px;
    border: 1px solid #cbd5e1;
}

.a4-table td {
    font-size: 10px;
    padding: 5px 8px;
    border: 1px solid #e2e8f0;
}

.a4-signature-box {
    border-top: 1px solid #94a3b8;
    width: 160px;
    text-align: center;
    padding-top: 3px;
    font-size: 10px;
    font-weight: 600;
    color: #475569;
}

/* Isolated Print Container (Hidden on screen, 100% visible on print) */
#isolatedPrintContainer {
    display: none;
}

@media print {
    @page {
        size: A4 portrait;
        margin: 0;
    }

    html, body {
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        overflow: visible !important;
    }

    /* Hide all page content except isolatedPrintContainer */
    body > *:not(#isolatedPrintContainer) {
        display: none !important;
        visibility: hidden !important;
    }

    #isolatedPrintContainer {
        display: block !important;
        visibility: visible !important;
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        border: none !important;
        background: #ffffff !important;
    }

    #isolatedPrintContainer * {
        visibility: visible !important;
    }

    #isolatedPrintContainer.thermal-mode {
        width: 80mm !important;
        max-width: 80mm !important;
        padding: 0 !important;
    }

    #isolatedPrintContainer.a4-mode {
        width: 210mm !important;
        max-width: 210mm !important;
        min-width: 210mm !important;
        box-sizing: border-box !important;
        padding: 8mm 12mm !important;
        background: #ffffff !important;
        overflow: hidden !important;
        page-break-inside: avoid !important;
        page-break-after: avoid !important;
        page-break-before: avoid !important;
    }
}

/* ==========================================
   RESPONSIVE POS TABLE & LINE ITEM UTILITIES
   ========================================== */
.fs-8 { font-size: 0.8rem !important; }
.fs-9 { font-size: 0.72rem !important; }
.mt-1\.5 { margin-top: 0.35rem !important; }

.pos-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.pos-table th {
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 0.75rem 0.5rem;
    border-top: none;
}

.pos-table tr.item-row {
    transition: background-color 0.2s ease;
}

.pos-table tr.item-row:hover {
    background-color: rgba(2, 132, 199, 0.02);
}

.pos-table tr.item-row td {
    border-bottom: 1px dashed var(--border-color);
}

.pos-table .form-control:focus,
.pos-table .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* Header Hover Effects & Custom Transitions */
.hvr-light {
    transition: all 0.2s ease;
}
.hvr-light:hover {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.1);
}

/* Touch-Friendly Quantity Control Buttons for Mobile POS */
.qty-btn-group {
    display: inline-flex;
    align-items: center;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    overflow: hidden;
    background: #ffffff;
}
.qty-btn-group .btn {
    padding: 2px 8px;
    font-weight: bold;
    border: none;
    border-radius: 0;
}
.qty-btn-group input {
    width: 45px;
    text-align: center;
    border: none;
    border-left: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    font-weight: 700;
}

/* Mobile Responsive Tweaks (< 768px) */
@media (max-width: 767.98px) {
    .container-fluid {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    .pos-table th, .pos-table td {
        font-size: 0.75rem !important;
        padding: 0.4rem 0.3rem !important;
    }
    .pos-table .form-control-sm, .pos-table .form-select-sm {
        font-size: 0.75rem !important;
        padding: 0.25rem 0.35rem !important;
    }
}

@media (max-width: 991.88px) {
    .pos-table-container::after {
        content: '← Swipe horizontally to view all FBR DI fields →';
        display: block;
        text-align: center;
        font-size: 0.75rem;
        color: var(--slate-muted);
        padding: 0.5rem;
        background-color: #f1f5f9;
        font-family: monospace;
    }
}
