/* ==========================================
   Modern CSS Design System - Attendance System
   RTL First, Glassmorphic, Modern Typography
   ========================================== */

:root {
    --bg-primary: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-blue: #0284c7;
    --accent-light: #38bdf8;
    --accent-green: #10b981;
    --accent-amber: #f59e0b;
    --accent-red: #ef4444;
    --accent-purple: #8b5cf6;
    --border-color: #334155;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-subtle: 0 4px 12px rgba(0, 0, 0, 0.25);
    --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.2);
    --transition-fast: 0.2s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    direction: rtl;
    text-align: right;
    min-height: 100vh;
}

/* Typography & Links */
a {
    color: var(--accent-light);
    text-decoration: none;
    transition: var(--transition-fast);
}
a:hover {
    color: #7dd3fc;
}

/* Layout Containers */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--bg-surface);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    z-index: 100;
    transition: var(--transition-fast);
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--border-color);
}
.sidebar-header .logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-light));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    box-shadow: var(--shadow-glow);
}
.sidebar-header h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}
.sidebar-header p {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Navigation Links */
.nav-list {
    list-style: none;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    overflow-y: auto;
}
.nav-item a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    transition: var(--transition-fast);
}
.nav-item a i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}
.nav-item a:hover, .nav-item.active a {
    background-color: rgba(56, 189, 248, 0.12);
    color: var(--accent-light);
}
.nav-item.active a {
    border-right: 4px solid var(--accent-light);
    font-weight: 700;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}
.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--accent-purple);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
}
.user-info h4 {
    font-size: 14px;
    color: var(--text-primary);
}
.user-info span {
    font-size: 12px;
    color: var(--accent-light);
    background: rgba(2, 132, 199, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
}

/* Main Content Area */
.main-content {
    margin-right: 280px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: 70px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
}
.page-title {
    font-size: 20px;
    font-weight: 700;
}
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.content-body {
    padding: 32px;
    flex: 1;
}

/* Cards & Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-subtle);
    transition: var(--transition-fast);
}
.stat-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent-light);
}
.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}
.stat-icon.blue { background: rgba(2, 132, 199, 0.2); color: var(--accent-light); }
.stat-icon.green { background: rgba(16, 185, 129, 0.2); color: var(--accent-green); }
.stat-icon.amber { background: rgba(245, 158, 11, 0.2); color: var(--accent-amber); }
.stat-icon.red { background: rgba(239, 68, 68, 0.2); color: var(--accent-red); }
.stat-icon.purple { background: rgba(139, 92, 246, 0.2); color: var(--accent-purple); }

.stat-info h3 {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 2px;
}
.stat-info p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Sections & Panel Layouts */
.panel {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 32px;
    box-shadow: var(--shadow-subtle);
}
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}
.panel-header h3 {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Form Controls & Buttons */
.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}
.form-control {
    width: 100%;
    padding: 12px 16px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    transition: var(--transition-fast);
}
.form-control:focus {
    outline: none;
    border-color: var(--accent-light);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: var(--transition-fast);
}
.btn-primary {
    background-color: var(--accent-blue);
    color: #fff;
}
.btn-primary:hover {
    background-color: #0369a1;
}
.btn-secondary {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background-color: #475569;
}
.btn-danger {
    background-color: var(--accent-red);
    color: #fff;
}
.btn-danger:hover {
    background-color: #dc2626;
}
.btn-block {
    width: 100%;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}
.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}
.table th, .table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    text-align: right;
    font-size: 14px;
}
.table th {
    background-color: rgba(15, 23, 42, 0.6);
    color: var(--text-secondary);
    font-weight: 700;
}
.table tr:hover {
    background-color: rgba(51, 65, 85, 0.3);
}

/* Status Badges */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.badge-success { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-info { background: rgba(2, 132, 199, 0.15); color: #38bdf8; }

/* RFID Card Pairing Pulsing Animation */
.rfid-pulse-container {
    display: flex;
    justify-content: center;
    align-items: center;
}
.rfid-pulse-icon {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    color: #fff;
    box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7);
    animation: rfidPulse 1.6s infinite;
}

@keyframes rfidPulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 24px rgba(56, 189, 248, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(56, 189, 248, 0);
    }
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-fast);
}
.modal-backdrop.show {
    opacity: 1;
    visibility: visible;
}
.modal-dialog {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    transform: translateY(-20px);
    transition: var(--transition-fast);
}
.modal-backdrop.show .modal-dialog {
    transform: translateY(0);
}
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}
.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}
.modal-body {
    padding: 24px;
}
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.code-block {
    background-color: #090d16;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    font-family: 'Consolas', 'Courier New', Courier, monospace;
    font-size: 13px;
    color: #38bdf8;
    max-height: 350px;
    overflow-y: auto;
    direction: ltr;
    text-align: left;
    white-space: pre;
}

.d-none { display: none !important; }
