/* style.css - Premium Mobile-First stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600&display=swap');

:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --panel-bg: rgba(30, 41, 59, 0.7);
    --panel-border: rgba(255, 255, 255, 0.08);
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.3);
    --accent: #10b981;
    --accent-glow: rgba(16, 185, 129, 0.2);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.2);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-blur: blur(12px);
    --border-radius: 16px;
    --font-outfit: 'Outfit', sans-serif;
    --font-inter: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-inter);
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    padding-bottom: 75px; /* Space for bottom nav on mobile */
}

h1, h2, h3, h4 {
    font-family: var(--font-outfit);
    font-weight: 600;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}

/* Glassmorphism Class */
.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: var(--border-radius);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Login Screen */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    width: 100%;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 40px 30px;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

.login-logo {
    font-size: 3rem;
    margin-bottom: 10px;
    display: inline-block;
    background: linear-gradient(45deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-family: var(--font-outfit);
    font-weight: 700;
    letter-spacing: -1px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 30px;
}

/* Inputs & Forms */
.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-wrapper {
    position: relative;
}

.input-control {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 14px 16px;
    color: var(--text-main);
    font-size: 1rem;
    font-family: var(--font-inter);
    transition: all 0.3s ease;
    outline: none;
}

.input-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: rgba(15, 23, 42, 0.8);
}

.btn {
    width: 100%;
    border: none;
    border-radius: 12px;
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-outfit);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
    color: white;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent) 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid var(--panel-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 4px 14px var(--danger-glow);
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-2px);
}

/* Layout Header */
header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.4);
    border-bottom: 1px solid var(--panel-border);
    backdrop-filter: var(--glass-blur);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-logo {
    font-family: var(--font-outfit);
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(45deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-badge .role {
    font-size: 0.7rem;
    text-transform: uppercase;
    background: var(--primary);
    padding: 2px 6px;
    border-radius: 4px;
    color: white;
}

/* Main Dashboard Grid */
.dashboard-main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

/* Scanner Tab Custom Styling */
.scanner-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 900px) {
    .scanner-grid {
        grid-template-columns: 1.2fr 0.8fr;
    }
}

.scanner-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.scanner-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.scanner-title {
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Viewfinder styling */
.viewfinder-wrapper {
    position: relative;
    width: 100%;
    max-width: 480px;
    aspect-ratio: 4 / 3;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    border: 2px solid var(--panel-border);
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

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

/* Custom camera overlays (simulated) */
.scan-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
}

.scan-laser {
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(to right, transparent, var(--danger), transparent);
    box-shadow: 0 0 12px var(--danger);
    animation: laser-scan 2.5s linear infinite;
    top: 50%;
}

.viewfinder-corners {
    position: absolute;
    top: 15%;
    left: 10%;
    right: 10%;
    bottom: 15%;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.4);
}

.scanner-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.scanner-actions .btn {
    flex: 1 1 150px;
}

/* Manual Entry Panel */
.manual-card {
    padding: 24px;
}

.mode-toggle-bar {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid var(--panel-border);
}

.mode-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-outfit);
}

.mode-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px var(--primary-glow);
}

/* Session Logs inside Scan Tab */
.session-logs-card {
    padding: 20px;
    max-height: 400px;
    display: flex;
    flex-direction: column;
}

.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.logs-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.log-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    padding: 10px 14px;
    border-radius: 8px;
    animation: slideIn 0.3s ease;
}

.log-item.success {
    border-left: 4px solid var(--accent);
}

.log-item.fail {
    border-left: 4px solid var(--danger);
    opacity: 0.8;
}

.log-code {
    font-family: monospace;
    font-weight: bold;
    color: var(--text-main);
}

.log-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Notification Panel overlay */
.notification-banner {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    z-index: 1000;
    width: calc(100% - 40px);
    max-width: 450px;
    padding: 16px 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    opacity: 0;
}

.notification-banner.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.notification-banner.success {
    background: #064e3b;
    border: 1px solid var(--accent);
    color: #a7f3d0;
}

.notification-banner.danger {
    background: #7f1d1d;
    border: 1px solid var(--danger);
    color: #fca5a5;
}

/* History Tab & Users Tab Table Style */
.history-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.search-input {
    flex: 1 1 250px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.3);
    border: 1px solid var(--panel-border);
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th, .table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--panel-border);
    font-size: 0.95rem;
}

.table th {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

.badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-camera {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.badge-manual {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.delete-action-btn {
    background: transparent;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.delete-action-btn:hover {
    background: rgba(239, 68, 68, 0.15);
}

/* Pagination container */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-pages {
    display: flex;
    gap: 6px;
}

.page-btn {
    border: 1px solid var(--panel-border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.page-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
}

.page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Settings Tab Styling */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

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

.settings-card {
    padding: 24px;
}

.settings-card h3 {
    margin-bottom: 20px;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 10px;
    color: var(--text-main);
}

/* Users List (Admin Control UI) */
.user-control-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 900px) {
    .user-control-grid {
        grid-template-columns: 1.2fr 0.8fr;
    }
}

/* Bottom Navigation Bar for Mobile */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--panel-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 999;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    flex: 1;
    height: 100%;
    justify-content: center;
    transition: all 0.2s ease;
    gap: 4px;
    font-family: var(--font-outfit);
}

.nav-item.active {
    color: var(--primary);
}

.nav-item svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    transition: all 0.2s ease;
}

.nav-item.active svg {
    stroke-width: 2.5;
    transform: translateY(-2px);
}

/* Keyframes */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-15px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes laser-scan {
    0% { top: 15%; }
    50% { top: 85%; }
    100% { top: 15%; }
}

/* Utility details */
.text-danger { color: var(--danger); }
.text-success { color: var(--accent); }
.text-center { text-align: center; }
.mt-4 { margin-top: 20px; }
.flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.w-full { width: 100%; }

/* Toggle Switch */
.toggle-switch-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    gap: 10px;
    user-select: none;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255,255,255,0.1);
    transition: .3s;
    border-radius: 24px;
    border: 1px solid var(--panel-border);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}
