/* ═══════════════════════════════════════════════
   ActionSKLAD — Industrial Utilitarian Dark Theme
   ═══════════════════════════════════════════════ */

:root {
    /* Core palette */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2036;
    --bg-card-hover: #212b47;
    --bg-input: #0f1629;
    --bg-sidebar: #0d1220;

    /* Accent / brand */
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --accent-soft: rgba(99, 102, 241, 0.1);

    /* Status */
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.12);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.12);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --info: #3b82f6;

    /* Text */
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-accent: #a5b4fc;

    /* Border */
    --border: #1e293b;
    --border-hover: #334155;

    /* Spacing */
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 16px;

    /* Fonts */
    --font-body: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Shadows */
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 30px var(--accent-glow);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ══════════════ AUTH SCREEN ══════════════ */
.auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at 50% 30%, rgba(99,102,241,0.08) 0%, transparent 60%),
                var(--bg-primary);
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-card);
}

.auth-logo {
    text-align: center;
    margin-bottom: 36px;
}

.auth-logo-icon {
    font-size: 56px;
    margin-bottom: 12px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.auth-logo h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.accent { color: var(--accent); }

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

.auth-form { display: flex; flex-direction: column; gap: 20px; }

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-error {
    color: var(--error);
    font-size: 14px;
    text-align: center;
    margin-top: 12px;
    min-height: 20px;
}

/* ══════════════ INPUTS ══════════════ */
.input-group { display: flex; flex-direction: column; gap: 6px; }

.input-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input, select, textarea {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 15px;
    font-family: var(--font-body);
    transition: all 0.2s;
    outline: none;
    width: 100%;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder { color: var(--text-muted); }

/* ══════════════ BUTTONS ══════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}
.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--error); color: white; }
.btn-warning { background: var(--warning); color: #1a1a1a; }
.btn-full { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-lg { padding: 16px 32px; font-size: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ══════════════ LAYOUT ══════════════ */
.app {
    display: flex;
    min-height: 100vh;
}

/* ══════════════ SIDEBAR ══════════════ */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px 20px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    display: none;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
}

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 8px 12px 4px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.nav-item .nav-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-info {
    font-size: 13px;
    color: var(--text-secondary);
}

.user-info strong {
    display: block;
    color: var(--text-primary);
    font-size: 14px;
}

/* ══════════════ MAIN CONTENT ══════════════ */
.main-content {
    flex: 1;
    padding: 32px;
    min-width: 0;
    overflow-y: auto;
    height: 100vh;
}

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

.page-header h2 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.page-header h2 .header-icon { margin-right: 8px; }

/* ══════════════ CARDS ══════════════ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    transition: border-color 0.2s;
}

.card:hover { border-color: var(--border-hover); }

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

.card-title {
    font-size: 16px;
    font-weight: 600;
}

/* ══════════════ STATS GRID ══════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: all 0.2s;
}

.stat-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.stat-value.text-success { color: var(--success); }
.stat-value.text-warning { color: var(--warning); }
.stat-value.text-error { color: var(--error); }

/* ══════════════ TABLE ══════════════ */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    background: var(--bg-secondary);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-card-hover); }

/* ══════════════ BADGES / TAGS ══════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: rgba(59,130,246,0.12); color: var(--info); }
.badge-default { background: rgba(148,163,184,0.12); color: var(--text-secondary); }

/* ══════════════ SCAN MODULE ══════════════ */
.scan-container {
    text-align: center;
    padding: 40px 20px;
}

.scan-status {
    padding: 24px;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    font-size: 18px;
    font-weight: 600;
    transition: all 0.3s;
}

.scan-status.idle {
    background: var(--bg-card);
    border: 2px dashed var(--border);
    color: var(--text-secondary);
}

.scan-status.active {
    background: var(--success-bg);
    border: 2px solid var(--success);
    color: var(--success);
}

.scan-input-area {
    position: relative;
    margin: 32px auto;
    max-width: 500px;
}

.scan-input {
    width: 100%;
    padding: 20px 24px;
    font-size: 24px;
    font-family: var(--font-mono);
    text-align: center;
    background: var(--bg-input);
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    color: var(--text-primary);
    letter-spacing: 2px;
    box-shadow: var(--shadow-glow);
}

.scan-input:focus {
    outline: none;
    box-shadow: 0 0 40px var(--accent-glow);
}

.scan-input::placeholder {
    color: var(--text-muted);
    letter-spacing: 0;
    font-size: 16px;
}

.scan-history {
    max-height: 400px;
    overflow-y: auto;
}

.scan-history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    animation: slideIn 0.3s ease-out;
}

.scan-history-item.success { background: var(--success-bg); }
.scan-history-item.error { background: var(--error-bg); }
.scan-history-item.info { background: rgba(59,130,246,0.12); }

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

/* ══════════════ SCAN OVERLAY ══════════════ */
.scan-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    pointer-events: none;
}

.scan-result {
    padding: 40px 60px;
    border-radius: var(--radius-lg);
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    animation: scanFlash 1.5s ease-out forwards;
}

.scan-result.success {
    background: rgba(34, 197, 94, 0.9);
    color: white;
    box-shadow: 0 0 80px rgba(34, 197, 94, 0.5);
}

.scan-result.error {
    background: rgba(239, 68, 68, 0.9);
    color: white;
    box-shadow: 0 0 80px rgba(239, 68, 68, 0.5);
    animation: scanFlash 1.5s ease-out forwards, shake 0.4s ease-in-out;
}

.scan-result.warning {
    background: rgba(245, 158, 11, 0.9);
    color: #1a1a1a;
    box-shadow: 0 0 80px rgba(245, 158, 11, 0.5);
}

@keyframes scanFlash {
    0% { opacity: 0; transform: scale(0.8); }
    20% { opacity: 1; transform: scale(1.05); }
    80% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.95); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-12px); }
    50% { transform: translateX(12px); }
    75% { transform: translateX(-8px); }
}

/* ══════════════ DISCREPANCY FORM ══════════════ */
.discrepancy-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.discrepancy-form .input-group { flex: 1; min-width: 150px; }
.discrepancy-form .input-group.small { flex: 0 0 120px; }

/* ══════════════ MODAL ══════════════ */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-card);
    animation: modalIn 0.3s ease-out;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@keyframes modalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ══════════════ TOAST ══════════════ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    animation: toastIn 0.3s ease-out, toastOut 0.3s ease-in 2.7s forwards;
    max-width: 400px;
}

.toast.success { background: var(--success); color: white; }
.toast.error { background: var(--error); color: white; }
.toast.info { background: var(--info); color: white; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-20px); }
}

/* ══════════════ LOADING ══════════════ */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: var(--text-muted);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════ EMPTY STATE ══════════════ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* ══════════════ TOGGLE SWITCH ══════════════ */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

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

.toggle-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border);
    border-radius: 24px;
    transition: all 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.3s;
}

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

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

/* ══════════════ ATTENDANCE BIG BUTTONS ══════════════ */
.att-big-btn {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px 20px;
    border-radius: 16px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.25s;
    background: none;
    font-family: var(--font-body);
}

.att-big-btn--in {
    background: linear-gradient(135deg, rgba(34,197,94,0.08) 0%, rgba(34,197,94,0.02) 100%);
    border-color: rgba(34,197,94,0.25);
}

.att-big-btn--in:hover {
    background: linear-gradient(135deg, rgba(34,197,94,0.15) 0%, rgba(34,197,94,0.05) 100%);
    border-color: rgba(34,197,94,0.5);
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(34,197,94,0.2);
}

.att-big-btn--out {
    background: linear-gradient(135deg, rgba(239,68,68,0.08) 0%, rgba(239,68,68,0.02) 100%);
    border-color: rgba(239,68,68,0.25);
}

.att-big-btn--out:hover {
    background: linear-gradient(135deg, rgba(239,68,68,0.15) 0%, rgba(239,68,68,0.05) 100%);
    border-color: rgba(239,68,68,0.5);
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(239,68,68,0.2);
}

.att-big-btn-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

.att-big-btn-label {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.3px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.att-big-btn--in .att-big-btn-label { color: var(--success); }
.att-big-btn--out .att-big-btn-label { color: var(--error); }

.att-big-btn-desc {
    font-size: 13px;
    color: var(--text-muted);
}

/* ══════════════ ATTENDANCE CALENDAR ══════════════ */
.att-cal-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
}

.att-cal-month {
    flex: 1;
    min-width: 280px;
}

.att-cal-month-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.att-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.att-cal-header {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 4px 0 8px;
    letter-spacing: 0.5px;
}

.att-cal-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: default;
    transition: all 0.15s;
    position: relative;
    border: 2px solid transparent;
    background: rgba(255,255,255,0.02);
    min-height: 44px;
}

.att-cal-day--empty {
    background: transparent;
    border: none;
}

.att-cal-day--in-period {
    border-color: rgba(99, 102, 241, 0.25);
}

.att-cal-day--today {
    box-shadow: 0 0 0 2px var(--accent), 0 0 12px var(--accent-glow);
}

.att-cal-day--present {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.att-cal-day--present.att-cal-day--short {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.att-cal-day--absent {
    background: rgba(239, 68, 68, 0.12);
    color: var(--error);
}

.att-cal-day--day-off {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

.att-cal-day--sick {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.att-cal-day--weekend {
    background: rgba(100, 116, 139, 0.08);
    color: var(--text-muted);
    opacity: 0.6;
}

.att-cal-day:not(.att-cal-day--empty):hover {
    transform: scale(1.08);
    z-index: 2;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.att-cal-num {
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}

.att-cal-hours {
    font-size: 9px;
    font-weight: 600;
    margin-top: 2px;
    font-family: var(--font-mono);
    opacity: 0.8;
    line-height: 1;
}

/* Legend dots */
.cal-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 4px;
}

.cal-dot--present { background: rgba(34, 197, 94, 0.5); }
.cal-dot--absent { background: rgba(239, 68, 68, 0.5); }
.cal-dot--day-off { background: rgba(59, 130, 246, 0.5); }
.cal-dot--sick { background: rgba(245, 158, 11, 0.5); }
.cal-dot--weekend { background: rgba(100, 116, 139, 0.3); }
.cal-dot--period {
    background: transparent;
    border: 2px solid rgba(99, 102, 241, 0.5);
}

/* ══════════════ RESPONSIVE ══════════════ */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -260px;
        transition: left 0.3s;
        z-index: 200;
    }
    .sidebar.open { left: 0; }
    .sidebar-toggle { display: block; }
    .main-content { padding: 20px 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .page-header { flex-direction: column; align-items: flex-start; }
    .scan-input { font-size: 18px; padding: 16px; }
    .att-cal-wrapper { flex-direction: column; }
    .att-cal-day { min-height: 36px; }
    .att-cal-hours { display: none; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .auth-card { padding: 32px 24px; }
}

