body {
    margin: 0;
    background: #111;
    color: #fff;
    font-family: Arial, sans-serif;
}

.topbar {
    background: #c62828;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: bold;
    position: relative;
}

.topbar .logo {
    font-size: 18px;
    font-weight: bold;
}

.top-nav {
    display: flex;
    gap: 8px;
    flex: 1;
    justify-content: center;
    margin: 0 12px;
}

.nav-tab {
    padding: 6px 12px;
    color: #fff;
    text-decoration: none;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
}

.nav-tab:hover,
.nav-tab.active {
    background: rgba(255, 255, 255, 0.2);
}

.topbar .user {
    font-size: 12px;
    white-space: nowrap;
}

.content {
    padding: 16px;
    min-height: calc(100vh - 120px);
}

/* Form Styles */
.form-container {
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: #ccc;
}

.form-group input {
    width: 100%;
    padding: 12px;
    margin-bottom: 0;
    border-radius: 6px;
    border: 1px solid #444;
    background: #222;
    color: #fff;
    font-size: 14px;
    box-sizing: border-box;
}

/* QR Code Styles */
.qr-container {
    margin: 20px 0;
    text-align: center;
}

.qr-box {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    margin: 0 auto 16px;
    max-width: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-image {
    width: 100%;
    max-width: 250px;
    height: auto;
}

.vin-number {
    font-size: 14px;
    color: #fff;
    margin-top: 12px;
    font-family: monospace;
    letter-spacing: 1px;
}

.qr-info {
    color: #fff;
    margin-top: 16px;
}

.plate-no {
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    margin-bottom: 8px;
}

.vehicle-info {
    font-size: 14px;
    color: #ccc;
    margin-bottom: 16px;
}

.htmx-indicator {
    display: none;
    color: #4caf50;
    font-size: 14px;
    margin-top: 12px;
    text-align: center;
}

.htmx-indicator.htmx-request {
    display: block;
}

.btn-generate,
.btn-regenerate,
.btn-update,
.btn-print,
.btn-share {
    width: 100%;
    padding: 14px;
    background: #c62828;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    margin-top: 12px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    display: block;
    text-align: center;
    text-decoration: none;
    box-sizing: border-box;
}

.btn-share {
    background: #2196F3;
}

.print-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.print-actions .btn-print,
.print-actions .btn-share {
    flex: 1;
    margin-top: 0;
}

.btn-generate:active,
.btn-update:active,
.btn-print:active {
    opacity: 0.9;
    transform: scale(0.98);
}

/* Camera Styles */
.camera-container {
    position: relative;
    width: 100%;
    margin-bottom: 24px;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

#reader {
    width: 100%;
    min-height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.camera-scanner {
    width: 100%;
    min-height: 300px;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

#reader video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 8px;
}

.scan-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.scan-frame {
    width: 250px;
    height: 250px;
    border: 3px solid #4caf50;
    border-radius: 8px;
    position: relative;
}

.corner-tl,
.corner-tr,
.corner-bl,
.corner-br {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 3px solid #4caf50;
}

.corner-tl {
    top: -3px;
    left: -3px;
    border-right: none;
    border-bottom: none;
    border-top-left-radius: 8px;
}

.corner-tr {
    top: -3px;
    right: -3px;
    border-left: none;
    border-bottom: none;
    border-top-right-radius: 8px;
}

.corner-bl {
    bottom: -3px;
    left: -3px;
    border-right: none;
    border-top: none;
    border-bottom-left-radius: 8px;
}

.corner-br {
    bottom: -3px;
    right: -3px;
    border-left: none;
    border-top: none;
    border-bottom-right-radius: 8px;
}

.scan-text {
    margin-top: 20px;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
}

.scan-controls {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    background: rgba(0, 0, 0, 0.7);
}

.start-scan-btn {
    padding: 15px 30px;
    background: #c62828;
    color: white;
    border: none;
    border-radius: 50px;
    font-weight: bold;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s;
}

.start-scan-btn:active {
    transform: scale(0.95);
}

/* Update Location Styles */
.update-section {
    margin-top: 20px;
}

.section-title {
    font-size: 20px;
    margin: 0 0 4px 0;
    color: #fff;
}

.section-subtitle {
    font-size: 14px;
    color: #aaa;
    margin: 0 0 16px 0;
}

.stall-input {
    width: 100%;
    padding: 12px;
    margin-bottom: 16px;
    border-radius: 6px;
    border: 1px solid #444;
    background: #fff;
    color: #000;
    font-size: 14px;
    box-sizing: border-box;
}

/* Thermal Print Styles (58mm) */
@media print {

    /* Hide ALL elements except the QR container */
    body>*:not(.content),
    .content>*:not(#qr-result),
    #qr-result>*:not(.qr-container) {
        display: none !important;
    }

    .qr-container {
        display: block !important;
        width: 58mm !important;
        margin: 0 auto !important;
        padding: 5mm 0 !important;
        background: #fff !important;
        color: #000 !important;
        position: relative !important;
        visibility: visible !important;
    }

    .qr-container * {
        visibility: visible !important;
        color: #000 !important;
        background: #fff !important;
    }

    .qr-box {
        padding: 0 !important;
        margin-bottom: 5mm !important;
        background: #fff !important;
        border: none !important;
        box-shadow: none !important;
    }

    .qr-image {
        width: 48mm !important;
        height: auto !important;
        display: block !important;
        margin: 0 auto !important;
    }

    .vin-number,
    .plate-no,
    .vehicle-info,
    .slot-info,
    .activity-info {
        font-family: 'Courier New', Courier, monospace !important;
        margin-top: 1mm !important;
        margin-bottom: 1mm !important;
        font-size: 10pt !important;
        text-align: center !important;
        display: block !important;
    }

    .plate-no {
        font-size: 14pt !important;
        font-weight: bold !important;
    }

    .slot-info {
        font-size: 12pt !important;
    }

    .btn-print {
        display: none !important;
    }

    @page {
        margin: 0;
        size: 58mm auto;
    }

    body {
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        width: 58mm !important;
    }
}

.vehicle-details {
    margin-top: 24px;
    text-align: left;
}

.vehicle-details .section-title {
    margin-bottom: 16px;
    text-align: left;
}

.vehicle-details .history-details strong {
    color: #333 !important;
    font-weight: 700;
    text-align: left !important;
}

.vehicle-details .history-card {
    text-align: left;
}

/* History Styles */
.history-title {
    font-size: 20px;
    margin: 0 0 8px 0;
    color: #fff;
}

.date {
    font-size: 14px;
    color: #aaa;
    margin: 0 0 20px 0;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-card {
    background: #fff;
    color: #000;
    padding: 16px;
    border-radius: 8px;
    text-align: left !important;
    display: block;
    width: 100%;
    box-sizing: border-box;
}

.history-plate {
    font-weight: bold;
    font-size: 18px;
    margin-bottom: 8px;
    text-align: left !important;
    display: block;
    color: #000;
}

.history-details {
    font-size: 14px;
    color: #555;
    text-align: left !important;
    line-height: 1.5;
    display: block;
}

.history-details strong {
    color: #000 !important;
    font-weight: 800 !important;
    text-align: left !important;
}

.search-result-row {
    display: flex !important;
    justify-content: flex-start !important;
    align-items: flex-start !important;
    width: 100% !important;
    text-align: left !important;
    margin-bottom: 6px !important;
}

.search-result-label {
    min-width: 90px !important;
    font-weight: 800 !important;
    color: #000 !important;
    text-align: left !important;
}

.search-result-value {
    color: #333 !important;
    text-align: left !important;
    flex: 1;
}

.status-in {
    color: #2e7d32;
    font-weight: bold;
}

.status-out {
    color: #c62828;
    font-weight: bold;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: #222;
    display: flex;
    border-top: 1px solid #333;
    z-index: 100;
}

.nav-link {
    flex: 1;
    padding: 12px 8px;
    text-align: center;
    color: #fff;
    text-decoration: none;
    font-size: 12px;
    transition: background 0.2s;
}

.nav-link:hover,
.nav-link.active {
    background: #c62828;
}

/* Sidebar & Mobile Menu */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0 8px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

.sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 260px;
    height: 100vh;
    background: #a41b1b;
    z-index: 1000;
    transition: left 0.3s ease;
    padding: 20px;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    color: #fff;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sidebar.active {
    left: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.sidebar-title {
    font-size: 20px;
    font-weight: bold;
    color: #fff;
}

.close-sidebar {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sidebar-link {
    color: #fff;
    text-decoration: none;
    font-size: 16px;
    padding: 12px;
    border-radius: 6px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: rgba(255, 255, 255, 0.2);
    /* White overlay on hover */
    color: #fff;
    font-weight: bold;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .topbar {
        padding: 12px 16px;
        justify-content: space-between;
    }

    .top-nav {
        display: none;
        /* Hide horizontal nav on mobile */
    }

    .menu-toggle {
        display: block;
        /* Show hamburger menu */
    }

    .topbar .logo {
        font-size: 18px;
    }

    .topbar .user {
        display: block;
        font-size: 11px;
    }

    /* Content adjustments */
    .content {
        padding: 16px;
        min-height: calc(100vh - 60px);
    }

    /* Form adjustments */
    .form-group input,
    .stall-input {
        font-size: 16px;
    }

    /* QR Code & Camera adjustments */
    .qr-box {
        max-width: 100%;
        box-sizing: border-box;
    }

    .qr-image {
        max-width: 100%;
    }

    .camera-container,
    .camera-scanner {
        min-height: 250px;
    }

    /* Section titles */
    .section-title {
        font-size: 20px;
    }
}

/* Error/Warning Box Styles */
.error-box {
    background-color: #fff3cd;
    color: #856404;
    padding: 20px;
    border: 1px solid #ffeeba;
    border-radius: 8px;
    margin-top: 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.error-box h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.2rem;
    color: #856404;
}

.error-box p {
    margin: 0;
    font-size: 1rem;
}

/* --- PRINT STYLES FOR THERMAL PRINTER (58mm) --- */
@media print {

    /* Hide all non-essential UI elements */
    .topbar,
    .bottom-nav,
    .menu-toggle,
    .btn-print,
    .generate-header,
    .history-title,
    .warning-banner,
    form,
    .sidebar,
    .sidebar-overlay,
    .user,
    #loading,
    .camera-container,
    .update-section,
    .btn-update,
    .section-title,
    .section-subtitle {
        display: none !important;
    }

    /* Reset global styles for printing */
    body,
    html {
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        color: black !important;
        font-size: 10pt !important;
    }

    .content {
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Thermal printer container (58mm approx) */
    .qr-container {
        width: 48mm !important;
        /* Leaving some margin for 58mm paper */
        margin: 0 auto !important;
        padding: 5px 0 15mm 0 !important;
        /* Added 15mm bottom padding for tear-off */
        box-shadow: none !important;
        border: none !important;
        background: white !important;
        text-align: center !important;
        display: block !important;
        border-bottom: 1px dashed #000 !important;
        /* Visual cut line */
    }

    .qr-box {
        background: white !important;
        padding: 5px !important;
        display: block !important;
        margin: 0 auto !important;
    }

    .qr-image {
        width: 40mm !important;
        /* Scale to fit thermal width */
        height: auto !important;
        display: block !important;
        margin: 0 auto !important;
    }

    .qr-info {
        font-family: 'Courier New', Courier, monospace !important;
        font-size: 10pt !important;
        line-height: 1.2 !important;
        margin-top: 5px !important;
    }

    .vin-number {
        font-size: 8pt !important;
        margin-bottom: 2px !important;
    }

    .plate-no {
        font-size: 16pt !important;
        font-weight: bold !important;
        margin: 5px 0 !important;
        border-top: 1px dashed #000;
        border-bottom: 1px dashed #000;
        padding: 3px 0;
    }

    .vehicle-info {
        font-size: 10pt !important;
        margin-bottom: 2px !important;
    }

    .slot-info,
    .activity-info {
        font-size: 11pt !important;
        color: black !important;
        margin-top: 3px !important;
    }
}