/* ============================================
   APLIKASI ABSENSI - USER (Mobile-First)
   Design System: Clean & Consistent
   ============================================ */

/* === RESET & BASE === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Primary */
    --primary-50: #EFF6FF;
    --primary-100: #DBEAFE;
    --primary-500: #3B82F6;
    --primary-600: #2563EB;
    --primary-700: #1D4ED8;

    /* Semantic */
    --success: #10B981;
    --success-light: #D1FAE5;
    --success-dark: #065F46;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --warning-dark: #92400E;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --danger-dark: #991B1B;
    --info: #06B6D4;
    --info-light: #CFFAFE;
    --info-dark: #155E75;

    /* Neutral */
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    --white: #FFFFFF;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 999px;

    /* Shadow */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);

    /* Transition */
    --transition: 200ms ease-in-out;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary-600);
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
}

/* === TOP BAR === */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--white);
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 var(--space-4);
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid var(--gray-100);
}

.topbar-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-900);
    flex: 1;
    text-align: center;
}

.topbar-back {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--gray-700);
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: background var(--transition);
}

.topbar-back:hover {
    background: var(--gray-100);
}

.topbar-action {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--gray-700);
    cursor: pointer;
    border-radius: var(--radius-md);
}

/* === BOTTOM NAV === */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--white);
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    box-shadow: 0 -1px 3px rgba(0,0,0,0.08);
    border-top: 1px solid var(--gray-100);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-2) var(--space-3);
    color: var(--gray-400);
    text-decoration: none;
    font-size: 0.6875rem;
    font-weight: 500;
    transition: color var(--transition);
    border-radius: var(--radius-md);
}

.bottom-nav-item svg {
    width: 24px;
    height: 24px;
}

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

.bottom-nav-item:hover {
    color: var(--primary-500);
}

/* === CONTENT === */
.content {
    padding: var(--space-4);
    padding-bottom: calc(64px + var(--space-4));
    min-height: calc(100vh - 56px);
}

/* === CARD === */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-100);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-sm);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: var(--space-3);
}

.card-subtitle {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-bottom: var(--space-4);
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-family);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary-600);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-700);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #DC2626;
}

.btn-secondary {
    background: var(--white);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
}

.btn-secondary:hover {
    background: var(--gray-50);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

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

/* === FORM === */
.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    height: 44px;
    padding: 10px 14px;
    font-size: 1rem;
    font-family: var(--font-family);
    color: var(--gray-800);
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.form-input::placeholder {
    color: var(--gray-400);
}

.form-input.error {
    border-color: var(--danger);
}

.form-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 4px;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-input {
    height: auto;
    min-height: 80px;
    resize: vertical;
}

/* === ALERT / FLASH === */
.alert {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: var(--space-4);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    border-left: 4px solid;
}

.alert-success {
    background: var(--success-light);
    color: var(--success-dark);
    border-color: var(--success);
}

.alert-danger {
    background: var(--danger-light);
    color: var(--danger-dark);
    border-color: var(--danger);
}

.alert-warning {
    background: var(--warning-light);
    color: var(--warning-dark);
    border-color: var(--warning);
}

.alert-info {
    background: var(--info-light);
    color: var(--info-dark);
    border-color: var(--info);
}

/* === BADGE === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-full);
}

.badge-success {
    background: var(--success-light);
    color: var(--success-dark);
}

.badge-warning {
    background: var(--warning-light);
    color: var(--warning-dark);
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger-dark);
}

.badge-info {
    background: var(--info-light);
    color: var(--info-dark);
}

.badge-primary {
    background: var(--primary-50);
    color: var(--primary-700);
}

/* === SCANNER === */
.scanner-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--gray-900);
    aspect-ratio: 1;
}

.scanner-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#reader {
    width: 100%;
}

#reader video {
    border-radius: var(--radius-lg);
}

#reader__scan_region {
    min-height: 250px;
}

#reader__dashboard {
    display: none !important;
}

.scan-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 220px;
    height: 220px;
    border: 3px solid var(--primary-500);
    border-radius: var(--radius-lg);
    pointer-events: none;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.3);
}

.scan-overlay::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border: 3px solid transparent;
    border-radius: var(--radius-lg);
}

.scan-line {
    position: absolute;
    top: 0;
    left: 10%;
    width: 80%;
    height: 2px;
    background: var(--primary-500);
    animation: scanLine 2s ease-in-out infinite;
    box-shadow: 0 0 8px var(--primary-500);
}

@keyframes scanLine {
    0%, 100% { top: 10%; }
    50% { top: 90%; }
}

.scan-instruction {
    text-align: center;
    margin-top: var(--space-4);
    color: var(--gray-500);
    font-size: 0.875rem;
}

/* === STAT CARDS === */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    border: 1px solid var(--gray-100);
    text-align: center;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 2px;
}

.stat-card.primary .stat-number { color: var(--primary-600); }
.stat-card.success .stat-number { color: var(--success); }
.stat-card.warning .stat-number { color: var(--warning); }
.stat-card.danger .stat-number { color: var(--danger); }

/* === LIST === */
.list-item {
    display: flex;
    align-items: center;
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--gray-100);
    gap: var(--space-3);
}

.list-item:last-child {
    border-bottom: none;
}

.list-item-content {
    flex: 1;
    min-width: 0;
}

.list-item-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-subtitle {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 2px;
}

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: var(--space-8) var(--space-4);
    color: var(--gray-400);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: var(--space-2);
}

.empty-state-text {
    font-size: 0.875rem;
}

/* === LOGIN PAGE === */
.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
    background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
}

.login-logo {
    width: 80px;
    height: 80px;
    background: var(--white);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-5);
    box-shadow: var(--shadow-lg);
}

.login-logo svg {
    width: 48px;
    height: 48px;
    color: var(--primary-600);
}

.login-title {
    color: var(--white);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--space-2);
    text-align: center;
}

.login-subtitle {
    color: rgba(255,255,255,0.8);
    font-size: 0.875rem;
    margin-bottom: var(--space-8);
    text-align: center;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-lg);
}

/* === SCHEDULE CARD === */
.schedule-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-100);
    padding: var(--space-4);
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.schedule-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--primary-50);
    color: var(--primary-600);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.schedule-info {
    flex: 1;
    min-width: 0;
}

.schedule-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-800);
}

.schedule-meta {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 2px;
}

/* === PROFILE === */
.profile-header {
    text-align: center;
    padding: var(--space-6) 0;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    background: var(--primary-100);
    color: var(--primary-600);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-3);
    font-size: 2rem;
    font-weight: 700;
}

.profile-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
}

.profile-email {
    font-size: 0.875rem;
    color: var(--gray-500);
}

/* === SUCCESS ANIMATION === */
.success-animation {
    text-align: center;
    padding: var(--space-8);
}

.success-icon {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    background: var(--success-light);
    color: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-4);
    animation: scaleIn 0.3s ease-out;
}

@keyframes scaleIn {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

/* === UTILITY === */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.d-flex { display: flex; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.flex-1 { flex: 1; }
.w-full { width: 100%; }

/* === LOADING SPINNER === */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* === RESPONSIVE === */
@media (min-width: 768px) {
    .content {
        max-width: 480px;
        margin: 0 auto;
    }
}

/* === TOAST NOTIFICATIONS === */
.toast-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: calc(100% - 32px);
    max-width: 420px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 18px;
    border-radius: 14px;
    background: var(--white);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.08);
    pointer-events: auto;
    opacity: 0;
    transform: scale(0.85);
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-left: 5px solid var(--gray-300);
    position: relative;
    overflow: hidden;
}

.toast-show {
    opacity: 1;
    transform: scale(1);
}

.toast-hide {
    opacity: 0;
    transform: scale(0.85);
    transition: all 0.25s ease-in;
}

.toast-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-message {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--gray-800);
    padding-top: 5px;
}

.toast-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: var(--gray-100);
    color: var(--gray-500);
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin-top: 2px;
}

.toast-close:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}

/* Toast types */
.toast-success {
    border-left-color: var(--success);
}
.toast-success .toast-icon {
    background: var(--success-light);
    color: var(--success);
}
.toast-success::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--success);
    animation: toastProgress 5s linear forwards;
}

.toast-danger {
    border-left-color: var(--danger);
}
.toast-danger .toast-icon {
    background: var(--danger-light);
    color: var(--danger);
}
.toast-danger::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--danger);
    animation: toastProgress 5s linear forwards;
}

.toast-warning {
    border-left-color: var(--warning);
}
.toast-warning .toast-icon {
    background: var(--warning-light);
    color: var(--warning);
}
.toast-warning::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--warning);
    animation: toastProgress 5s linear forwards;
}

.toast-info {
    border-left-color: var(--primary-500);
}
.toast-info .toast-icon {
    background: var(--primary-50);
    color: var(--primary-600);
}
.toast-info::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--primary-500);
    animation: toastProgress 5s linear forwards;
}

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

/* Pulse animation for success */
.toast-success .toast-icon {
    animation: toastPulse 0.6s ease-out;
}

@keyframes toastPulse {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}
