/**
 * نظام التحقق من بطاقات الموظفين بتقنية NFC
 * ملف التنسيقات الحديثة للوحة التحكم (Modern Admin Stylesheet)
 */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&display=swap');

:root {
    --primary: #00897b;
    --primary-hover: #00796b;
    --primary-light: #e0f2f1;
    --accent: #e65100;
    --secondary: #0f172a;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --info: #0284c7;
    --info-bg: #e0f2fe;
    
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --radius-sm: 6px;
    --radius: 12px;
    --radius-lg: 16px;
}

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

body, input, button, select, textarea, optgroup, table {
    font-family: 'Cairo', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.6;
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* الترويسة وشريط التنقل */
.navbar {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    gap: 1.5rem;
}

.nav-brand-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-toggle {
    display: none;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    cursor: pointer;
    color: var(--secondary);
    transition: all 0.2s ease;
}

.nav-toggle:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--primary);
    text-decoration: none;
}

.nav-brand .logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), #3b82f6);
    color: #fff;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.nav-collapse {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    gap: 1rem;
}

.nav-links {
    display: flex;
    align-items: center;
    list-style: none;
    gap: 6px;
    flex-wrap: wrap;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary);
    background: var(--primary-light);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-badge {
    background: var(--bg-page);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--secondary);
    white-space: nowrap;
}

/* الحاوية الرئيسية */
.container {
    max-width: 1240px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    width: 100%;
    flex: 1;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--secondary);
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* بطاقات الإحصائيات (KPI Cards) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-info h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 6px;
}

.stat-info .stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--secondary);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.success { background: var(--success-bg); color: var(--success); }
.stat-icon.danger { background: var(--danger-bg); color: var(--danger); }
.stat-icon.warning { background: var(--warning-bg); color: var(--warning); }

/* البطاقات العامة والمحتوى */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafbfc;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--secondary);
}

.card-body {
    padding: 1.5rem;
}

/* الجداول */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

table th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: right;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

table tr:hover td {
    background: #f8fafc;
}

/* الشارات (Badges) */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 700;
}

.badge-active, .badge-success { background: var(--success-bg); color: var(--success); }
.badge-suspended, .badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-unknown, .badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }

.uid-code {
    font-family: monospace, monospace;
    font-size: 0.9rem;
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 4px;
    color: #0f172a;
    font-weight: bold;
    letter-spacing: 1px;
}

/* الأزرار */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-secondary { background: #e2e8f0; color: #334155; }
.btn-secondary:hover { background: #cbd5e1; }

.btn-sm {
    padding: 4px 10px;
    font-size: 0.82rem;
}

/* النماذج (Forms) */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.95rem;
    color: var(--secondary);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--text-main);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* التنبيهات */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.alert-info { background: var(--info-bg); color: var(--info); border: 1px solid #bae6fd; }

/* صورة الموظف المصغرة */
.avatar-thumb {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

/* حاوية أزرار النماذج */
.form-actions {
    margin-top: 2rem;
    display: flex;
    gap: 12px;
    align-items: center;
}

/* بطاقة تسجيل الدخول */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
}

.login-card {
    background: #ffffff;
    width: 100%;
    max-width: 440px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem 2rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header .logo-badge {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

/* التذييل */
footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
    background: #fff;
    margin-top: auto;
}

/* النوافذ المنبثقة (Modals) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    animation: modalIn 0.25s ease-out;
}

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

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafbfc;
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    border-radius: 4px;
}

.modal-close:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: #fafbfc;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* شارات الأدوار (Role Badges) */
.badge-role-verifier {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.badge-role-admin {
    background: #f3e8ff;
    color: #7e22ce;
    border: 1px solid #e9d5ff;
}

.badge-role-superadmin {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fde68a;
}

/* ==========================================================================
   التجاوب مع الشاشات والأجهزة الذكية (Responsive Mobile Design)
   ========================================================================== */

/* أجهزة التابلت والشاشات المتوسطة والصغيرة */
@media (max-width: 992px) {
    .navbar {
        flex-direction: column;
        align-items: stretch;
        padding: 0.75rem 1.25rem;
        gap: 0;
    }

    .nav-brand-container {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .nav-toggle {
        display: flex;
        order: 2;
    }

    .nav-brand {
        order: 1;
    }

    .nav-collapse {
        display: none;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        margin-top: 0.75rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--border-color);
        gap: 0.75rem;
    }

    .nav-collapse.show {
        display: flex;
        animation: slideDown 0.25s ease-out;
    }

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

    .nav-links {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 4px;
    }

    .nav-links li {
        width: 100%;
    }

    .nav-links a {
        padding: 10px 14px;
        width: 100%;
        font-size: 1rem;
        border-radius: var(--radius-sm);
    }

    .nav-user {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-top: 0.75rem;
        border-top: 1px solid var(--border-color);
        width: 100%;
    }

    .container {
        padding: 0 1rem;
        margin: 1.25rem auto;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
}

/* الهواتف الذكية */
@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        margin-bottom: 1.25rem;
    }

    .page-header .btn,
    .page-header a.btn {
        width: 100%;
        justify-content: center;
    }

    .page-title {
        font-size: 1.45rem;
    }

    .card-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding: 1rem;
    }

    .card-header .btn,
    .card-header a.btn {
        width: 100%;
        justify-content: center;
    }

    .card-body {
        padding: 1rem;
    }

    .stat-card {
        padding: 1.1rem;
        flex-direction: column-reverse;
        align-items: flex-start;
        gap: 0.6rem;
    }

    .stat-info .stat-value {
        font-size: 1.6rem;
    }

    .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 1.25rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .form-actions {
        flex-direction: column-reverse;
        gap: 8px;
    }

    .form-actions .btn,
    .form-actions a.btn {
        width: 100%;
        justify-content: center;
    }

    .table-responsive {
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
        -webkit-overflow-scrolling: touch;
        margin-bottom: 0.5rem;
    }

    table th, table td {
        padding: 10px 12px;
        font-size: 0.88rem;
    }

    /* تحسين إمكانية النقر للأزرار في الجوال */
    .btn-sm {
        padding: 6px 12px;
        font-size: 0.85rem;
        min-height: 36px;
    }

    /* فلاتر البحث في الجداول */
    .filter-bar, .search-form {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar select, .filter-bar input, .filter-bar button {
        width: 100%;
    }

    /* المودال في الجوال */
    .modal-card {
        max-width: 96vw;
        margin: 0.5rem;
        max-height: 85vh;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        flex-direction: column-reverse;
        padding: 0.75rem 1rem;
    }

    .modal-footer .btn {
        width: 100%;
        justify-content: center;
    }
}

/* الشاشات الصغيرة جداً */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .navbar {
        padding: 0.5rem 0.75rem;
    }

    .container {
        padding: 0 0.5rem;
    }

    .card {
        border-radius: var(--radius-sm);
    }
}

