/* ========================================================= */
/* --- "DIGITAL ARCHIVE" THEME (SCREEN STYLES) --- */
/* ========================================================= */

:root {
    --primary-color: #1d2d35;       /* Dark Charcoal */
    --accent-color: #ffc107;        /* Modern Amber */
    --background-color: #f9f9f9;    /* Clean Off-White */
    --text-color: #333333;          /* Dark Slate Gray */
    --card-bg-color: #ffffff;       /* Pure White */
    --danger-color: #dc3545;
    --success-color: #28a745;
}

html { scroll-behavior: smooth; }

body {
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: 'Inter', sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
}

main { flex-grow: 1; }

#mainApp {
    flex-grow: 1;
    flex-direction: column;
    width: 100%;
}

h1, h2, h3, h4, h5, h6, .navbar-brand, .modal-title {
    font-family: 'Poppins', sans-serif;
    color: var(--primary-color);
}

a { color: var(--accent-color); text-decoration: none; font-weight: bold; cursor: pointer; }
a:hover { color: #e0a800; }

/* --- Header & Navbar --- */
.navbar-custom { background-color: var(--primary-color); padding: 1rem 0; }
.navbar-custom .navbar-brand { color: #ffffff !important; font-size: 1.8rem; font-weight: 700; }
.navbar-custom .navbar-brand strong { color: var(--accent-color); }
.navbar-custom .nav-link { color: rgba(255, 255, 255, 0.8); font-weight: 600; }
.navbar-custom .nav-link.active, .navbar-custom .nav-link:hover { color: var(--accent-color); }

/* --- Page Header --- */
.page-header { background-color: var(--card-bg-color); padding: 2.5rem 0; text-align: center; border-bottom: 1px solid #e0e0e0; margin-bottom: 3rem; }
.page-header h1 { font-size: 2.8rem; font-weight: 700; margin-bottom: 0; }

/* --- Live Ticker --- */
.ticker-bar { background-color: #111b20; color: #ffffff; border-bottom: 1px solid #333; font-family: 'Roboto Mono', monospace; }
.spot-price-item { color: var(--accent-color); margin-right: 1.5rem; }
.spot-price-item strong { color: #ffffff; transition: color 0.5s ease-out, text-shadow 0.5s ease-out; }
.price-up { color: #28a745 !important; text-shadow: 0 0 8px rgba(40, 167, 69, 0.8); }
.price-down { color: #dc3545 !important; text-shadow: 0 0 8px rgba(220, 53, 69, 0.8); }

/* --- Buttons --- */
.btn { border-radius: 0.25rem; font-weight: 700; padding: 0.75rem 1.5rem; transition: all 0.2s ease-in-out; }
.btn-primary { background-color: var(--primary-color); border-color: var(--primary-color); color: #fff; }
.btn-primary:hover { background-color: #111b20; border-color: #111b20; color: #fff; }
.btn-warning { background-color: var(--accent-color); border-color: var(--accent-color); color: var(--primary-color); }
.btn-warning:hover { background-color: #e0a800; border-color: #e0a800; color: var(--primary-color); }
.btn-outline-secondary { color: var(--primary-color); border-color: var(--primary-color); }
.btn-outline-secondary:hover { background-color: var(--primary-color); color: #fff; }
.btn-check:checked + .btn-outline-primary { background-color: var(--primary-color); color: white; border-color: var(--primary-color); }
.btn-outline-primary { color: var(--primary-color); border-color: var(--primary-color); }

.btn-outline-custom { color: var(--text-color); border-color: #ced4da; background-color: transparent; }
.btn-outline-custom:hover { background-color: #f8f9fa; border-color: #adb5bd; color: var(--primary-color); }

/* --- Cards & Content --- */
.card-custom { border: 1px solid #e0e0e0; background-color: var(--card-bg-color); border-top: 4px solid var(--accent-color); border-radius: 0.25rem; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.04); transition: transform 0.2s ease, box-shadow 0.2s ease; }
.card-custom .card-header { background-color: transparent; border-bottom: 1px solid #e0e0e0; padding: 1.25rem; font-family: 'Poppins', sans-serif; font-size: 1.25rem; font-weight: 600; }
.selection-card { cursor: pointer; height: 100%; }
.selection-card:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.1); }
.selection-card .bi { color: var(--primary-color); transition: color 0.3s; }
.selection-card:hover .bi { color: var(--accent-color); }

/* --- Numista Catalog Custom Styles --- */
.catalog-option-container { border: 1px solid #e0e0e0; padding: 1rem; border-radius: 0.5rem; margin-bottom: 0.5rem; background-color: #fff; transition: all 0.2s; cursor: pointer; }
.catalog-option-container:hover { background-color: #f8f9fa; border-color: #adb5bd; }
.catalog-option-container.selected { border-color: var(--accent-color); background-color: rgba(255, 193, 7, 0.05); box-shadow: 0 4px 8px rgba(0,0,0,0.05); }
.catalog-thumb { width: 60px; height: 60px; object-fit: cover; border: 1px solid #dee2e6; border-radius: 4px; background-color: #fff; transition: transform 0.2s ease; }
.catalog-thumb:hover { transform: scale(1.15); z-index: 10; position: relative; }

/* --- Invoice Table Styles --- */
.invoice-table th { font-family: 'Poppins', sans-serif; text-transform: uppercase; font-size: 0.85rem; letter-spacing: 0.5px; color: #6c757d; border-bottom: 2px solid #dee2e6; }
.invoice-table td { vertical-align: middle; font-family: 'Inter', sans-serif; font-size: 0.95rem; }
.invoice-buy-row { border-left: 4px solid var(--danger-color); }
.invoice-sell-row { border-left: 4px solid var(--success-color); }

.inv-edit-input { max-width: 140px; text-align: right; margin-left: auto; border: 1px solid transparent; background: transparent; padding: 0.25rem; transition: all 0.2s; border-radius: 4px; }
.inv-edit-input:hover, .inv-edit-input:focus { border-color: var(--accent-color); background: #fff; outline: none; box-shadow: 0 0 0 0.2rem rgba(255, 193, 7, 0.25); }

.inv-preview-input { width: 160px; text-align: right; border: 1px solid transparent; background: transparent; padding: 0; margin: 0; transition: all 0.2s; border-radius: 4px; color: var(--primary-color); }
.inv-preview-input:hover, .inv-preview-input:focus { border-color: rgba(255, 255, 255, 0.5); background: rgba(255,255,255,0.5); outline: none; }

/* Hide browser spin buttons globally */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

.inv-note-input { border: 1px dashed transparent !important; transition: all 0.2s; }
.inv-note-input:hover, .inv-note-input:focus { border-color: var(--accent-color) !important; background: #fff !important; outline: none; }

/* --- Login Wall --- */
#loginWall { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--primary-color); z-index: 2000; display: flex; align-items: center; justify-content: center; flex-direction: column; }
.login-card { background: var(--card-bg-color); padding: 2.5rem; border-radius: 0.25rem; width: 100%; max-width: 400px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); border-top: 4px solid var(--accent-color); }

/* --- Dropzone Overrides --- */
.dropzone { border: 2px dashed var(--primary-color); background: #f8f9fa; border-radius: 0.25rem; min-height: 150px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; }
.dropzone .dz-message { font-family: 'Poppins', sans-serif; font-weight: 600; color: var(--primary-color); }

/* --- Results & Images --- */
.result-image-container img { max-width: 150px; max-height: 150px; border: 1px solid var(--border-color); padding: 4px; background: #fff; border-radius: 0.25rem; object-fit: cover; cursor: pointer; transition: transform 0.2s ease-in-out; }
.result-image-container img:hover { transform: scale(1.05); border-color: var(--accent-color); }

/* --- Footer --- */
.footer-custom { background-color: var(--primary-color); color: rgba(255, 255, 255, 0.7); padding: 2rem 0; margin-top: auto; }
.footer-custom a { color: var(--accent-color); }
.footer-custom a:hover { color: #ffffff; }

/* --- Utils --- */
.table-hover tbody tr:hover { background-color: rgba(255, 193, 7, 0.1); }
.spinner-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.9); z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.animate-fade-in { animation: fadeIn 0.4s ease-out forwards; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }


/* ========================================================= */
/* --- PHYSICAL INVOICE PRINT STYLES (Strict Formatting) --- */
/* ========================================================= */

@media print {
    /* Hide everything on the screen except the print template */
    body * {
        visibility: hidden;
    }
    
    #printArea, #printArea * {
        visibility: visible;
    }
    
    /* Position the print area perfectly at the top left of the paper */
    #printArea {
        width: 100%;
        margin: 0;
        padding: 0;
    }

    @page {
        size: letter portrait;
        margin: 0.5in; /* Standard margins */
    }

    .print-wrapper {
        width: 100%;
        font-family: Arial, Helvetica, sans-serif;
        color: #000;
        background-color: #fff;
    }

    /* Top Checkboxes Row */
    .print-checkboxes {
        display: flex;
        justify-content: center;
        gap: 40px;
        margin-bottom: 20px;
        font-weight: bold;
        font-size: 14px;
        text-transform: uppercase;
    }

    .print-cb-item {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .print-box {
        width: 14px;
        height: 14px;
        border: 1px solid #000;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        line-height: 1;
    }

    /* Header Text */
    .print-header-text {
        text-align: center;
        margin-bottom: 25px;
    }
    
    .print-header-text h1 {
        font-size: 34px;
        font-weight: 900;
        margin: 0 0 5px 0;
        font-family: 'Arial Black', Impact, sans-serif;
        letter-spacing: 1px;
    }
    
    .print-header-text p {
        margin: 0;
        font-size: 12px;
        font-weight: bold;
    }

    /* Customer Grid Box */
    .print-grid {
        border: 1px solid #000;
        margin-bottom: 3px;
        display: flex;
        flex-direction: column;
    }

    .pg-row {
        display: flex;
        width: 100%;
        border-bottom: 1px solid #000;
        min-height: 28px; /* Force minimum height for empty rows */
    }
    
    .pg-row:last-child {
        border-bottom: none;
    }

    .pg-cell {
        padding: 2px 6px;
        border-right: 1px solid #000;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        box-sizing: border-box;
    }
    .pg-cell:last-child { border-right: none; }

    .pg-cell-group {
        display: flex;
        flex-direction: column;
    }

    .border-top-1 { border-top: 1px solid #000; }
    .border-start-1 { border-left: 1px solid #000; }
    .border-end-1 { border-right: 1px solid #000; }
    .border-bottom-1 { border-bottom: 1px solid #000; }
    
    .h-50 { height: 50%; }
    .w-50 { width: 50%; }
    .w-100 { width: 100%; }

    .pg-label {
        font-size: 9px;
        font-weight: bold;
        line-height: 1;
        text-transform: uppercase;
    }

    .pg-val {
        font-size: 14px;
        margin-top: auto;
        min-height: 14px;
    }

    /* Primary Invoice Items Table */
    .print-items-table {
        width: 100%;
        border-collapse: collapse;
        empty-cells: show;
        border: 1px solid #000;
        margin-bottom: 15px;
    }

    /* Force black background and white text for headers */
    .print-items-table th {
        background-color: #000 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
        font-size: 12px;
        font-weight: bold;
        text-align: left;
        padding: 4px 8px;
        border: 1px solid #000;
    }
    
    .print-items-table th:last-child {
        text-align: center;
    }
    
    .print-items-table td {
        border-right: 1px solid #000;
        border-bottom: 1px solid #000;
        padding: 4px 8px;
        font-size: 14px;
        height: 24px; /* Forces lines to render even if row is completely empty */
    }
    
    .print-items-table td:last-child {
        border-right: none;
        text-align: right;
    }

    /* Footer: Signature and Total */
    .print-footer-row {
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
        margin-top: 10px;
    }

    .pf-sig {
        display: flex;
        align-items: flex-end;
        width: 50%;
    }
    
    .pf-x {
        font-size: 20px;
        font-weight: bold;
        margin-right: 10px;
        line-height: 0.8;
    }
    
    .pf-line {
        flex-grow: 1;
        border-bottom: 2px solid #000;
        height: 20px;
    }

    .pf-total-wrap {
        display: flex;
        align-items: stretch;
        border: 2px solid #000;
    }
    
    /* Force background color for Total box */
    .pf-total-label {
        background-color: #000 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
        font-weight: bold;
        padding: 6px 15px;
        font-size: 18px;
        display: flex;
        align-items: center;
    }
    
    .pf-total-val {
        padding: 6px 15px;
        font-size: 18px;
        font-weight: bold;
        min-width: 140px;
        text-align: right;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }

    /* Section headers for split Buy/Sell invoice printing */
    .print-section-header td {
        background-color: #333 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
        font-size: 12px;
        font-weight: bold;
        text-transform: uppercase;
        letter-spacing: 2px;
        text-align: left !important;
        padding: 5px 10px !important;
        border-bottom: 2px solid #000 !important;
    }

    /* Subtotal rows for split Buy/Sell invoice printing */
    .print-subtotal-row td {
        background-color: #e8e8e8 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
        font-weight: bold;
        font-size: 13px;
        border-top: 1px solid #666 !important;
        border-bottom: 2px solid #000 !important;
        padding: 4px 8px;
    }
}

/* ========================================================= */
/* --- POS COMPACT UI OVERRIDES --- */
/* ========================================================= */

/* Strips all padding/height from inputs for ultra-thin table rows */
.pos-bare-input {
    border: 1px solid transparent;
    background: transparent;
    padding: 0px 4px;
    margin: 0;
    outline: none;
    box-shadow: none;
    line-height: 1.2;
    border-radius: 3px;
    width: 100%;
    transition: all 0.2s;
}
.pos-bare-input:hover, .pos-bare-input:focus {
    background: rgba(255, 255, 255, 0.8);
    border-color: var(--accent-color);
}

/* Custom scrollbar for the receipt panel to keep it sleek */
.receipt-scroll {
    scrollbar-width: thin;
    scrollbar-color: #adb5bd transparent;
}
.receipt-scroll::-webkit-scrollbar { width: 6px; }
.receipt-scroll::-webkit-scrollbar-thumb { background-color: #adb5bd; border-radius: 10px; }

/* Tighten up table cells */
.pos-table td, .pos-table th {
    padding-top: 0.25rem !important;
    padding-bottom: 0.25rem !important;
}

/* ========================================================= */
/* --- EBAY TRACKER STYLES --- */
/* ========================================================= */

@keyframes pulseDangerRow {
    0% { background-color: rgba(220, 53, 69, 0.05); }
    50% { background-color: rgba(220, 53, 69, 0.2); }
    100% { background-color: rgba(220, 53, 69, 0.05); }
}

.pulse-danger-row td {
    animation: pulseDangerRow 2s infinite ease-in-out;
}

/* ========================================================= */
/* --- UNIFIED CAPSULE SEARCH BAR STYLES --- */
/* ========================================================= */

.search-wrapper-premium {
    position: relative;
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 2px solid #ced4da;
    border-radius: 50px;
    padding: 3px 115px 3px 18px; /* space for absolute custom button on the right */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
}

.search-wrapper-premium:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.18), 0 0 0 3px rgba(255, 193, 7, 0.12);
    transform: translateY(-1px);
    background: #fff;
    z-index: 1100;
}

.search-icon-premium {
    color: var(--primary-color);
    opacity: 0.6;
    font-size: 1.1rem;
    margin-right: 10px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.search-wrapper-premium:focus-within .search-icon-premium {
    color: var(--accent-color);
    opacity: 1;
    transform: scale(1.15);
}

.search-input-premium {
    flex-grow: 1;
    border: none !important;
    background: transparent !important;
    padding: 8px 0 !important;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-color);
    outline: none !important;
    box-shadow: none !important;
    min-width: 0; /* allows input to shrink properly in flex layouts */
}

.search-input-premium::placeholder {
    color: #8a9ba8;
    font-weight: 600;
}

.search-btn-custom-premium {
    position: absolute;
    right: 4px;
    top: 4px;
    bottom: 4px;
    background: var(--primary-color);
    color: #ffffff;
    border: none;
    border-radius: 40px;
    padding: 0 20px;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 4px rgba(29, 45, 53, 0.12);
    transition: all 0.2s ease-in-out;
}

.search-btn-custom-premium:hover {
    background: #111b20;
    color: var(--accent-color);
    box-shadow: 0 4px 8px rgba(29, 45, 53, 0.22);
    transform: translateY(-1px);
}

.search-btn-custom-premium:active {
    transform: translateY(0);
}

/* Custom styled dropdown container */
.search-suggestions-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 10px;
    right: 10px;
    background: #ffffff;
    border: 1px solid #ced4da;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    max-height: 280px;
    overflow-y: auto;
    z-index: 1050;
    padding: 6px 0;
}

.search-suggestion-item {
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-suggestion-item:hover {
    background: #f1f3f5;
    color: var(--accent-color);
}

.search-suggestion-item .suggestion-suffix {
    font-size: 0.7rem;
    font-weight: 700;
    color: #6c757d;
    background: #e9ecef;
    padding: 2px 8px;
    border-radius: 20px;
    flex-shrink: 0;
    margin-left: 10px;
}

@media (max-width: 576px) {
    .search-wrapper-premium {
        padding-right: 50px;
    }
    .search-btn-custom-premium span {
        display: none;
    }
    .search-btn-custom-premium {
        padding: 0 12px;
    }
}