/* ===== Variables ===== */
:root {
    --bg: #0f0f13;
    --bg-card: #1a1a24;
    --bg-card-hover: #22222e;
    --bg-input: #12121a;
    --border: #2a2a3a;
    --text: #e4e4ef;
    --text-muted: #8888a0;
    --primary: #d4382e;
    --primary-hover: #e04a40;
    --primary-glow: rgba(212, 56, 46, 0.3);
    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, 0.15);
    --blue: #3b82f6;
    --blue-bg: rgba(59, 130, 246, 0.15);
    --yellow: #eab308;
    --yellow-bg: rgba(234, 179, 8, 0.15);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.15);
    --radius: 12px;
    --radius-sm: 8px;
}

/* ===== Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ===== Auth Screen ===== */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #0f0f13 0%, #1a0a0a 50%, #0f0f13 100%);
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.auth-title {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
}
.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 32px;
}
.auth-switch {
    text-align: center;
    color: var(--text-muted);
    margin-top: 16px;
    font-size: 14px;
}
.auth-switch a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* ===== Form ===== */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.form-group input, .form-group select, .input-field {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}
.form-group input:focus, .input-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.error-text {
    color: var(--red);
    font-size: 13px;
    margin-top: 8px;
    text-align: center;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 20px var(--primary-glow);
}
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-outline:hover {
    background: var(--bg-card-hover);
    border-color: var(--text-muted);
}
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
}
.btn-text:hover { color: var(--red); }

/* ===== Header ===== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.logo {
    font-size: 20px;
    font-weight: 700;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-info {
    font-size: 13px;
    color: var(--text-muted);
}

/* ===== Navigation ===== */
.nav-tabs {
    display: flex;
    gap: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    overflow-x: auto;
}
.nav-tab {
    padding: 14px 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: all 0.2s;
}
.nav-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.nav-tab:hover { color: var(--text); }

/* ===== Views ===== */
.view { display: none; padding: 20px; max-width: 900px; margin: 0 auto; }
.view.active { display: block; }

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.card-header h2, .card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

/* ===== Tabs ===== */
.tab-group {
    display: flex;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 3px;
}
.tab-btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    background: none;
    border: none;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.tab-btn.active {
    background: var(--bg-card);
    color: var(--text);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Scanner ===== */
.scanner-modes {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.mode-btn {
    flex: 1;
    padding: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}
.mode-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(212, 56, 46, 0.1);
}
.scanner-container { display: none; }
.scanner-container.active { display: block; }
.scanner-input {
    width: 100%;
    padding: 16px;
    font-size: 18px;
    font-family: 'Courier New', monospace;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    text-align: center;
    letter-spacing: 2px;
    transition: border-color 0.2s;
}
.scanner-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.last-scanned {
    margin-top: 12px;
    padding: 8px 12px;
    background: var(--green-bg);
    border-radius: var(--radius-sm);
    font-size: 13px;
}
.last-scanned .label { color: var(--text-muted); }
.last-scanned .value { color: var(--green); font-weight: 600; margin-left: 4px; }
.manual-input {
    width: 100%;
    padding: 14px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    resize: vertical;
    margin-bottom: 12px;
}
.manual-input:focus {
    outline: none;
    border-color: var(--primary);
}
.camera-preview {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

/* ===== Chips ===== */
.chip-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px 0;
    margin-bottom: 12px;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    color: var(--text);
}
.chip .remove {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
}
.chip .remove:hover { color: var(--red); }

/* ===== Action Buttons ===== */
.action-buttons {
    display: flex;
    gap: 8px;
}
.action-buttons .btn { flex: 1; }
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    font-size: 12px;
    font-weight: 600;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    border-radius: 12px;
    margin-left: 6px;
}

/* ===== Results Table ===== */
.table-wrapper {
    overflow-x: auto;
    margin: 0 -20px;
    padding: 0 20px;
}
.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.results-table th {
    text-align: left;
    padding: 10px 12px;
    background: var(--bg-input);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    position: sticky;
    top: 0;
}
.results-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(42, 42, 58, 0.5);
    white-space: nowrap;
}
.results-table tr:hover td {
    background: var(--bg-card-hover);
}

/* ===== Status Badges ===== */
.summary-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.summary-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 12px;
    font-weight: 600;
}
.summary-badge.scanned {
    background: var(--blue-bg);
    color: var(--blue);
}
.summary-badge.pickup {
    background: var(--green-bg);
    color: var(--green);
}
.summary-badge.cancel {
    background: var(--red-bg);
    color: var(--red);
}
.summary-badge.gagal {
    background: var(--yellow-bg);
    color: var(--yellow);
}
.summary-badge.total {
    background: rgba(255,255,255,0.08);
    color: var(--text-muted);
}
.status-cell {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.status-cell.scanned {
    background: var(--blue-bg);
    color: var(--blue);
}
.status-cell.pickup {
    background: var(--green-bg);
    color: var(--green);
}
.status-cell.cancel {
    background: var(--red-bg);
    color: var(--red);
}
.status-cell.gagal {
    background: var(--yellow-bg);
    color: var(--yellow);
}
.status-cell.total {
    background: rgba(255,255,255,0.08);
    color: var(--text-muted);
}

/* ===== History ===== */
.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid rgba(42, 42, 58, 0.5);
    gap: 12px;
}
.history-item:last-child { border-bottom: none; }
.history-item .info {
    flex: 1;
    min-width: 0;
}
.history-item .action-type {
    font-weight: 600;
    font-size: 14px;
    text-transform: capitalize;
}
.history-item .meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}
.history-item .actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.text-muted { color: var(--text-muted); font-size: 13px; }

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}
.modal.active { display: flex; }
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    max-width: 480px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
}
.modal-content h3 {
    margin-bottom: 12px;
    font-size: 18px;
}
.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}
.modal-actions .btn { flex: 1; }

/* ===== Admin ===== */
.session-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}
.session-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.session-badge.active {
    background: var(--green-bg);
    color: var(--green);
}
.session-badge.active .dot { background: var(--green); }
.session-badge.inactive {
    background: var(--red-bg);
    color: var(--red);
}
.session-badge.inactive .dot { background: var(--red); }
.admin-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}
.admin-msg {
    margin-top: 8px;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
}
.admin-msg.success { background: var(--green-bg); color: var(--green); }
.admin-msg.error { background: var(--red-bg); color: var(--red); }
.admin-msg.info { background: var(--blue-bg); color: var(--blue); }

/* ===== Toggle Switch ===== */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
}
.toggle-label input { display: none; }
.toggle-switch {
    width: 44px;
    height: 24px;
    background: var(--border);
    border-radius: 12px;
    position: relative;
    transition: background 0.3s;
    flex-shrink: 0;
}
.toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
}
.toggle-label input:checked + .toggle-switch {
    background: var(--primary);
}
.toggle-label input:checked + .toggle-switch::after {
    transform: translateX(20px);
}

/* ===== Settings ===== */
.settings-row {
    margin-bottom: 16px;
}
.settings-label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.time-inputs {
    display: flex;
    gap: 16px;
}
.time-inputs label {
    font-size: 13px;
    color: var(--text-muted);
}
.time-inputs input[type="time"] {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    margin-left: 8px;
}
.day-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.day-checkboxes label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
}
.day-checkboxes input[type="checkbox"] {
    accent-color: var(--primary);
}

/* ===== Report ===== */
.report-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
}
.report-controls input[type="date"] {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
}
.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.report-table th {
    text-align: left;
    padding: 10px 12px;
    background: var(--bg-input);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--text-muted);
}
.report-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(42, 42, 58, 0.5);
}

/* ===== User List ===== */
.user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(42, 42, 58, 0.5);
}
.user-item:last-child { border-bottom: none; }
.user-item .info .name {
    font-weight: 600;
    font-size: 14px;
}
.user-item .info .role {
    font-size: 12px;
    color: var(--text-muted);
}
.user-item .btn-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
}
.user-item .btn-delete:hover { color: var(--red); }

/* ===== Loading ===== */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 19, 0.85);
    z-index: 300;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    backdrop-filter: blur(4px);
}
.loading-overlay.active { display: flex; }
.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
    color: var(--text-muted);
    font-size: 14px;
}

/* ===== Row Styles ===== */
.row-notfound td {
    opacity: 0.7;
    font-style: italic;
}

/* ===== Scan Time Info ===== */
.scan-time-info {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--blue-bg);
    color: var(--blue);
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
}
.scan-time-info.restricted {
    background: var(--yellow-bg);
    color: var(--yellow);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .card { padding: 16px; }
    .header { padding: 12px 16px; }
    .nav-tabs { padding: 0 12px; }
    .view { padding: 12px; }
    .auth-card { padding: 28px 20px; }
    .action-buttons { flex-direction: column; }
    .time-inputs { flex-direction: column; }
    .report-controls { flex-direction: column; align-items: stretch; }
    .modal-content { padding: 20px; }
}
