/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Navbar */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    margin-bottom: 20px;
    padding: 15px 20px;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.navbar h2 {
    color: #667eea;
    font-size: 1.5rem;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-user span {
    font-weight: 500;
    color: #555;
}

/* Cards */
.card, .login-card {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
}

.login-card {
    max-width: 400px;
    margin: 50px auto;
}

.card h1, .card h2, .login-card h1 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.8rem;
}

.login-card h1 {
    text-align: center;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"] {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

/* Stats */
.stats {
    background: #f3f4f6;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.stats p {
    margin: 0;
    font-size: 16px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-item {
    text-align: center;
    padding: 20px;
    background: #f3f4f6;
    border-radius: 8px;
}

.stat-item h3 {
    font-size: 2.5rem;
    color: #667eea;
    margin-bottom: 5px;
}

.stat-item p {
    color: #6b7280;
    font-size: 14px;
}

/* Scanner Controls */
.scanner-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 15px;
}

#scanner-container {
    margin-top: 20px;
    text-align: center;
}

#interactive {
    position: relative;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

#interactive video {
    width: 100%;
    height: auto;
    display: block;
}

#interactive canvas {
    display: none;
}

#scanner-status {
    margin: 15px 0;
    padding: 10px;
    background: #f3f4f6;
    border-radius: 5px;
}

#scanner-status p {
    margin: 0;
    font-size: 14px;
}

#video {
    max-width: 100%;
    border-radius: 8px;
    background: #000;
}

#canvas {
    display: none;
}

/* QuaggaJS viewport styling */
#interactive {
    position: relative;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

#interactive video,
#interactive canvas {
    width: 100%;
    height: auto;
    display: block;
}

#interactive .drawingBuffer {
    position: absolute;
    top: 0;
    left: 0;
}

#scanner-wrapper {
    position: relative;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
}

#scanning-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#scanning-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 400px;
    height: 150px;
    border: 3px solid #10b981;
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    animation: pulse-border 2s ease-in-out infinite;
}

@keyframes pulse-border {
    0%, 100% {
        border-color: #10b981;
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5), 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    50% {
        border-color: #34d399;
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5), 0 0 20px 5px rgba(16, 185, 129, 0.5);
    }
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    margin-top: 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.data-table thead {
    background: #667eea;
    color: white;
}

.data-table th,
.data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.data-table th {
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tbody tr:hover {
    background: #f9fafb;
}

.barcode-data {
    max-width: 300px;
    word-break: break-all;
    font-family: monospace;
    font-size: 14px;
}

.text-center {
    text-align: center;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-admin {
    background: #fef3c7;
    color: #92400e;
}

.badge-user {
    background: #dbeafe;
    color: #1e40af;
}

.login-note {
    margin-top: 20px;
    padding: 10px;
    background: #f3f4f6;
    border-radius: 5px;
    font-size: 12px;
    color: #6b7280;
    text-align: center;
}

/* Scanner info box */
.scanner-info {
    margin-top: 15px;
    padding: 15px;
    background: #f0f9ff;
    border-left: 4px solid #3b82f6;
    border-radius: 4px;
    font-size: 14px;
}

.scanner-info ul {
    margin: 8px 0 0 20px;
    padding: 0;
}

.scanner-info li {
    margin: 5px 0;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .card, .login-card {
        padding: 20px;
    }

    .card h1, .card h2, .login-card h1 {
        font-size: 1.5rem;
    }

    .nav-container {
        flex-direction: column;
        align-items: flex-start;
    }

    .nav-user {
        width: 100%;
        justify-content: space-between;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .scanner-controls {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .data-table {
        font-size: 14px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
    }

    .barcode-data {
        max-width: 150px;
        font-size: 12px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .card, .login-card {
        padding: 15px;
    }

    .navbar {
        padding: 10px 15px;
    }

    .navbar h2 {
        font-size: 1.2rem;
    }
}

/* Region Modal */
#regionModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

#regionModal[style*="flex"] {
    display: flex !important;
}

#regionList label:hover {
    border-color: #667eea !important;
    background: #f0f9ff !important;
}

/* Receive Modal */
#receiveModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 20px;
}

#receiveModal[style*="flex"] {
    display: flex !important;
}

#receiveModal form textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
}

#receiveModal form textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#receiveModal form select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    background: white;
    cursor: pointer;
}

#receiveModal form select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

