/**
 * Smart Receipt Generator - Main Stylesheet
 * Bootstrap 5 enhancements, dark/light theme, thermal print layout (58mm).
 */

/* ─── CSS Variables ─── */
:root {
    --receipt-width: 219px; /* ~58mm at 96dpi */
    --receipt-font: 'Courier New', Courier, monospace;
}

/* ─── Layout ─── */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* ─── Stat Cards (Dashboard) ─── */
.stat-card .card-body {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--bs-secondary-color);
}

/* ─── QR Preview ─── */
.qr-preview {
    max-width: 160px;
    height: auto;
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    padding: 8px;
    background: #fff;
}

/* ─── Thermal Receipt (Screen Preview) ─── */
.thermal-receipt {
    width: var(--receipt-width);
    max-width: 100%;
    margin: 0 auto;
    padding: 16px;
    background: #fff;
    color: #000;
    font-family: var(--receipt-font);
    font-size: 11px;
    line-height: 1.4;
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.receipt-logo {
    max-width: 80px;
    max-height: 60px;
    margin-bottom: 8px;
}

.receipt-logo-placeholder {
    width: 60px;
    height: 60px;
    margin: 0 auto 8px;
    background: #f0f0f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #666;
}

.receipt-company {
    font-size: 14px;
    font-weight: bold;
    margin: 4px 0;
    text-transform: uppercase;
}

.receipt-meta {
    font-size: 10px;
    margin: 1px 0;
    color: #333;
}

.receipt-divider {
    border-top: 1px dashed #000;
    margin: 8px 0;
}

.receipt-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    font-size: 10px;
    gap: 8px;
}

.receipt-row span:first-child {
    flex-shrink: 0;
}

.receipt-row span:last-child {
    text-align: right;
    word-break: break-word;
}

.receipt-items {
    width: 100%;
    border-collapse: collapse;
    font-size: 9px;
}

.receipt-items th {
    border-bottom: 1px solid #000;
    padding: 4px 2px;
    font-weight: bold;
}

.receipt-items td {
    padding: 3px 2px;
    vertical-align: top;
}

.receipt-items .text-center { text-align: center; }
.receipt-items .text-end { text-align: right; }

.receipt-totals {
    margin-top: 4px;
}

.receipt-grand {
    font-weight: bold;
    font-size: 12px;
    border-top: 1px solid #000;
    padding-top: 4px !important;
    margin-top: 4px;
}

.receipt-qr {
    padding: 8px 0;
}

.qr-code-img {
    width: 120px;
    height: 120px;
}

.qr-hint {
    font-size: 9px;
    margin: 4px 0 2px;
    font-weight: bold;
}

.qr-url {
    font-size: 7px;
    word-break: break-all;
    color: #555;
}

.receipt-footer {
    font-size: 9px;
}

.receipt-disclaimer {
    font-size: 8px;
    color: #666;
    margin-top: 6px;
}

/* ─── Verification Page ─── */
.verify-page {
    max-width: 960px;
    margin: 0 auto;
}

.verify-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
}

.verify-valid {
    background: rgba(25, 135, 84, 0.15);
    color: #198754;
}

.verify-invalid {
    background: rgba(220, 53, 69, 0.15);
    color: #dc3545;
}

.verify-status-banner {
    border-radius: 12px;
    font-size: 1.1rem;
}

/* ─── Print Page ─── */
.print-page {
    background: #e9ecef;
    min-height: 100vh;
    padding: 20px;
}

.print-toolbar {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

.btn-print,
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
}

.btn-print {
    background: #0d6efd;
    color: #fff;
}

.btn-print:hover {
    background: #0b5ed7;
}

.btn-back {
    background: #6c757d;
    color: #fff;
}

.btn-back:hover {
    background: #5c636a;
    color: #fff;
}

.print-container {
    display: flex;
    justify-content: center;
}

/* ─── Print Media (58mm Thermal) ─── */
@media print {
    @page {
        size: 58mm auto;
        margin: 1mm;
    }

    body,
    .print-page {
        background: #fff !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .no-print,
    .print-toolbar {
        display: none !important;
    }

    .thermal-receipt,
    .thermal-print {
        width: 54mm !important;
        max-width: 54mm !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        font-family: Tahoma, Geneva, Verdana, Arial, sans-serif !important;
        font-size: 9pt !important;
        line-height: 1.35 !important;
        page-break-inside: avoid;
    }

    .qr-code-img {
        width: 24mm !important;
        height: 24mm !important;
    }
}

/* ─── Dark Theme Adjustments ─── */
[data-bs-theme="dark"] .thermal-receipt {
    background: #1a1a1a;
    color: #e0e0e0;
    border-color: #444;
}

[data-bs-theme="dark"] .thermal-receipt .receipt-meta,
[data-bs-theme="dark"] .thermal-receipt .qr-url,
[data-bs-theme="dark"] .thermal-receipt .receipt-disclaimer {
    color: #aaa;
}

[data-bs-theme="dark"] .qr-preview {
    background: #fff;
}

[data-bs-theme="dark"] .stat-card {
    background: var(--bs-body-bg);
}

/* ─── Responsive ─── */
@media (max-width: 576px) {
    .thermal-receipt {
        width: 100%;
        font-size: 10px;
    }

    .btn-group-sm .btn {
        padding: 0.2rem 0.4rem;
    }

    .stat-card .card-body {
        flex-direction: column;
        text-align: center;
    }
}

/* ─── Form Enhancements ─── */
#itemsTable input[readonly] {
    background-color: var(--bs-secondary-bg);
    cursor: default;
}

.card-header {
    font-weight: 600;
}

.table th {
    font-weight: 600;
    font-size: 0.85rem;
}
