@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #5d5fef;
    --primary-hover: #4b4ce6;
    --secondary-color: #f8f9fe;
    --text-main: #333333;
    --text-muted: #888888;
    --bg-main: #f2f5fb;
    --card-bg: #ffffff;
    --danger-color: #ff5a5f;
    --warning-color: #ffb703;
    --success-color: #06d6a0;
    --border-radius: 16px;
    --box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* Header Navbar */
.app-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(93, 95, 239, 0.2);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-logo {
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    backdrop-filter: blur(5px);
}

.header-title h1 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 2px;
}

.header-title p {
    font-size: 12px;
    opacity: 0.8;
}

.header-right {
    display: flex;
    gap: 15px;
    font-size: 18px;
}

.header-icon {
    color: white;
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
}

.header-icon:hover {
    transform: scale(1.1);
    opacity: 0.8;
}

/* Main Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(0,0,0,0.02);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.08);
}

.stat-card.danger h2 { color: var(--danger-color); }
.stat-card.warning h2 { color: var(--warning-color); }
.stat-card.primary h2 { color: var(--primary-color); }

.stat-card h2 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 5px;
}

.stat-card p {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Sections */
.section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
    margin-top: 25px;
}

/* Menu Grid */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* Default 4 columns */
    gap: 15px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    .menu-grid {
        grid-template-columns: repeat(3, 1fr); /* 3 columns on mobile */
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .menu-grid {
        grid-template-columns: repeat(3, 1fr); /* 3 columns on smaller mobile */
        gap: 10px;
    }
}

.menu-item {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    text-decoration: none;
    color: var(--text-main);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    border: 1px solid rgba(0,0,0,0.02);
    min-height: 100px;
}

.menu-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.08);
    background: var(--primary-color);
    color: white;
}

.menu-icon {
    font-size: 28px;
    margin-bottom: 12px;
    color: var(--primary-color);
    transition: var(--transition);
}

.menu-item:hover .menu-icon {
    color: white;
}

/* Specific Colors for Icons */
.icon-blue { color: #3a86ff; }
.icon-orange { color: #fb5607; }
.icon-pink { color: #ff006e; }
.icon-green { color: #38b000; }
.icon-purple { color: #8338ec; }

.menu-text {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
}

/* Custom Form & Scanner */
.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--box-shadow);
    margin-bottom: 20px;
}

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

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e5ee;
    border-radius: 10px;
    font-size: 15px;
    transition: var(--transition);
    outline: none;
    font-family: 'Inter', sans-serif;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(93, 95, 239, 0.1);
}

.btn {
    display: inline-block;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: var(--transition);
    color: white;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-color);
    box-shadow: 0 4px 10px rgba(93, 95, 239, 0.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-success {
    background: var(--success-color);
    box-shadow: 0 4px 10px rgba(6, 214, 160, 0.3);
}

.btn-success:hover {
    background: #05b88a;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #e1e5ee;
    color: var(--text-main);
}
.btn-secondary:hover {
    background: #cfd4e2;
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 20px;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 40px;
    border-top: 1px solid #e1e5ee;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}
.table th, .table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e1e5ee;
}

@media (max-width: 768px) {
    .table-responsive .table {
        min-width: 950px; /* Prevent column squeezing and enable clean horizontal scrolling on mobile */
    }
    .cart-table {
        min-width: 700px;
    }
}
.table th {
    background-color: #f8f9fe;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-muted);
}
.table tbody tr:hover {
    background-color: #fcfcfc;
}

/* Scanner specific */
#reader {
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow);
    border: 2px dashed var(--primary-color);
}
#reader video {
    border-radius: var(--border-radius);
}

.match-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    font-weight: 600;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s;
}
.match-indicator.show {
    opacity: 1;
}
.match-indicator.match { color: var(--success-color); }
.match-indicator.mismatch { color: var(--warning-color); }

/* View Toggle Classes */
.force-mobile {
    max-width: 480px !important;
    margin: 0 auto;
    box-shadow: 0 0 50px rgba(0,0,0,0.1);
    background: var(--bg-main);
    min-height: 100vh;
}
.force-mobile .menu-grid {
    grid-template-columns: repeat(3, 1fr) !important;
}
.force-mobile .stats-grid {
    grid-template-columns: 1fr !important;
}

.force-desktop .menu-grid {
    grid-template-columns: repeat(4, 1fr) !important;
}
.force-desktop .stats-grid {
    grid-template-columns: repeat(3, 1fr) !important;
}
.force-desktop {
    max-width: 1200px !important;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.modal-overlay.active {
    display: flex;
    opacity: 1;
}
.modal-box {
    background: var(--card-bg);
    width: 90%;
    max-width: 500px;
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}
.modal-overlay.active .modal-box {
    transform: translateY(0);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.modal-header h3 {
    margin: 0;
    color: var(--text-main);
    font-size: 20px;
}
.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
}
.close-modal:hover { color: var(--danger-color); }

/* Small buttons for action bar and table */
.btn-sm {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: auto;
}
.btn-danger {
    background: var(--danger-color);
    box-shadow: 0 4px 10px rgba(255, 90, 95, 0.3);
}
.btn-danger:hover { background: #e0484d; transform: translateY(-2px); }

.btn-warning {
    background: var(--warning-color);
    box-shadow: 0 4px 10px rgba(255, 183, 3, 0.3);
    color: #333;
}
.btn-warning:hover { background: #e6a500; transform: translateY(-2px); }

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

/* Custom Scanner UI styles */
.scanner-wrapper {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto 15px auto;
    border-radius: var(--border-radius);
    overflow: hidden;
    background: #000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    aspect-ratio: 4 / 3;
}

#reader {
    width: 100% !important;
    height: 100% !important;
    border: none !important;
}

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

/* Custom overlay on top of scanner video */
.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
}

.scanner-overlay-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 70%;
    max-width: 280px;
    max-height: 280px;
    border: 2px dashed rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5); /* Dim surrounding area */
    border-radius: 12px;
}

/* Corner highlights */
.scanner-corner {
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: #06d6a0; /* green border */
    border-style: solid;
    pointer-events: none;
}
.scanner-corner.top-left {
    top: -2px;
    left: -2px;
    border-width: 4px 0 0 4px;
    border-top-left-radius: 8px;
}
.scanner-corner.top-right {
    top: -2px;
    right: -2px;
    border-width: 4px 4px 0 0;
    border-top-right-radius: 8px;
}
.scanner-corner.bottom-left {
    bottom: -2px;
    left: -2px;
    border-width: 0 0 4px 4px;
    border-bottom-left-radius: 8px;
}
.scanner-corner.bottom-right {
    bottom: -2px;
    right: -2px;
    border-width: 0 4px 4px 0;
    border-bottom-right-radius: 8px;
}

/* Scanning laser animation */
.scanner-laser {
    position: absolute;
    width: 100%;
    height: 3px;
    background: linear-gradient(to right, transparent, #06d6a0, transparent);
    box-shadow: 0 0 8px #06d6a0;
    animation: scanning 2s linear infinite;
    z-index: 11;
}

@keyframes scanning {
    0% { top: 0%; }
    50% { top: 100%; }
    100% { top: 0%; }
}

/* Mode Scan Selector Segmented Control */
.scan-mode-container {
    display: flex;
    background: #e2e8f0;
    padding: 4px;
    border-radius: 12px;
    margin-bottom: 20px;
    gap: 4px;
}

.scan-mode-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.scan-mode-btn.active {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Flashlight & Cam Toggle Control */
.scanner-controls {
    position: absolute;
    bottom: 10px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 15px;
    z-index: 12;
}

.scanner-btn {
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    backdrop-filter: blur(5px);
    transition: all 0.2s ease;
    pointer-events: auto;
}

.scanner-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

/* Toast Notification Styles */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 90%;
    max-width: 400px;
    pointer-events: none;
}

.toast-alert {
    background: #1e293b;
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transform: translateY(-20px);
    animation: toast-fade-in 0.3s forwards, toast-fade-out 0.3s 2.7s forwards;
    pointer-events: auto;
    border-left: 4px solid var(--success-color);
}

.toast-alert.error {
    border-left-color: var(--danger-color);
}

.toast-icon {
    font-size: 18px;
    color: var(--success-color);
}
.toast-alert.error .toast-icon {
    color: var(--danger-color);
}

.toast-content {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

@keyframes toast-fade-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toast-fade-out {
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

