/* ===================================================
   ATT-style.css — نظام الحضور والانصراف
   هوية بصرية موحدة مع ECL | QB-Sentinel
   =================================================== */

:root {
    --primary: #c62828;
    --primary-dark: #8e0000;
    --accent: #fff5f5;
    --text-dark: #2d2e32;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --radius: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    background-color: #f3f4f6;
    margin: 0;
    padding: 12px;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--text-dark);
}

.form-container {
    max-width: 500px;
    margin: auto;
    animation: fadeIn 0.5s ease-out;
    padding-bottom: 30px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== HEADER ===== */
.main-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 30px 20px;
    border-radius: var(--radius) var(--radius) 20px 20px;
    text-align: center;
    color: white;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(198, 40, 40, 0.2);
}

.header-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 50%, rgba(255,255,255,0.07) 0%, transparent 70%);
    pointer-events: none;
}

.logo-area { position: relative; z-index: 2; }
.logo { width: 50px; height: auto; margin-bottom: 10px; }
.main-header h1 { font-size: 20px; margin: 0; position: relative; z-index: 2; }
.en-sub-header { font-size: 10px; letter-spacing: 2px; opacity: 0.8; margin-top: 4px; }

/* ===== CARDS ===== */
.card {
    background: white;
    margin-top: 15px;
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.card:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.05);
}

.info-card { border-top: 6px solid var(--primary); }

.label-heading {
    font-weight: 700;
    font-size: 15px;
    display: block;
    margin-bottom: 15px;
}

.required { color: var(--primary); margin-right: 3px; }



/* ===== BRANCH GRID (نفس ECL) ===== */
.branch-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.branch-grid input { display: none; }
.branch-tile {
    border: 2px solid var(--border);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.branch-grid input:checked + .branch-tile {
    border-color: var(--primary);
    background: var(--accent);
    color: var(--primary);
}



/* ===== EMPLOYEE GRID ===== */
.employee-placeholder-grid {
    grid-template-columns: 1fr !important;
}

.emp-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 28px 20px;
    background: #fafafa;
    border: 2px dashed var(--border);
    border-radius: 10px;
    color: var(--text-light);
    text-align: center;
}

.emp-placeholder i {
    width: 32px;
    height: 32px;
    opacity: 0.4;
    margin-bottom: 4px;
}

.emp-placeholder span {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
}

.emp-placeholder small {
    font-size: 11px;
    opacity: 0.7;
}

/* شبكة الموظفين الفعلية */
#employeeGrid.active-grid {
    grid-template-columns: 1fr 1fr;
}

.emp-btn {
    padding: 14px 10px;
    border: 2px solid var(--border);
    background: #ffffff;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    transition: 0.2s;
    color: var(--text-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.emp-btn:active { transform: scale(0.97); }

.emp-btn.active {
    background: var(--accent);
    border-color: var(--primary);
    color: var(--primary);
}

/* ===== USER BADGE (Saved Session) ===== */
.user-badge {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: var(--accent);
    border-radius: 10px;
    border: 1px solid rgba(198, 40, 40, 0.2);
    margin-bottom: 12px;
}

.badge-icon {
    width: 44px;
    height: 44px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.badge-icon i { color: white; width: 22px; height: 22px; }

.badge-details { display: flex; flex-direction: column; gap: 3px; }
.badge-name { font-weight: 700; font-size: 16px; color: var(--primary); }
.badge-branch { font-size: 12px; color: var(--text-light); }

.reset-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-light);
    font-size: 13px;
    font-family: inherit;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
    width: 100%;
    justify-content: center;
}

.reset-link:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--accent);
}

.reset-link i { width: 15px; height: 15px; }

/* ===== QR SCANNER CARD ===== */

/* حالة الانتظار (idle) */
.scanner-idle-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    text-align: center;
    gap: 8px;
}

.scanner-idle-icon {
    width: 72px;
    height: 72px;
    background: #f3f4f6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    border: 2px dashed var(--border);
}

.scanner-idle-icon i {
    width: 34px;
    height: 34px;
    color: var(--text-light);
    opacity: 0.5;
}

.scanner-idle-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

.scanner-idle-sub {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 16px;
}

/* خطوات الإرشاد */
.scanner-idle-steps {
    display: flex;
    align-items: center;
    gap: 6px;
    direction: rtl;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 8px;
    background: #f9fafb;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    width: 100%;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.step-num {
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}

.step-item span {
    font-size: 11px;
    color: var(--text-light);
    font-weight: 600;
}

.step-arrow i {
    width: 16px;
    height: 16px;
    color: var(--border);
}

/* حالة إذن الكاميرا */
.permission-icon {
    background: #fff3f3 !important;
    border-color: rgba(198, 40, 40, 0.3) !important;
}

.permission-icon i {
    color: var(--primary) !important;
    opacity: 0.8 !important;
}

.camera-retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: 0.2s;
    margin-top: 8px;
}

.camera-retry-btn:active { transform: scale(0.97); }
.camera-retry-btn i { width: 18px; height: 18px; }

/* الماسح الفعلي */
.scanner-wrapper {
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--primary);
    background: #000;
    margin-bottom: 12px;
}

#reader { width: 100% !important; }

#reader__header_message { display: none !important; }
#reader__status_span {
    color: var(--text-light);
    font-size: 12px;
}

.hint-text {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-light);
    font-size: 13px;
    margin: 8px 0 2px;
    padding: 10px 14px;
    background: #f9fafb;
    border-radius: 8px;
}

.hint-text i { width: 16px; height: 16px; flex-shrink: 0; }

/* ===== BACK NAV ===== */
.back-nav {
    max-width: 500px;
    margin: 10px auto;
    padding: 0 5px;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-light);
    font-size: 0.9rem;
    padding: 8px 12px;
    border-radius: var(--radius);
    transition: all 0.3s ease;
    background: white;
    border: 1px solid var(--border);
}

.back-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--accent);
    transform: translateX(-5px);
}

.back-btn i { width: 18px; height: 18px; }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.modal-content h3 { margin: 12px 0 6px; font-size: 18px; }
.modal-content p  { margin: 0 0 10px; color: var(--text-light); }

.code-input {
    width: 100%;
    padding: 12px 15px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    outline: none;
    text-align: center;
    letter-spacing: 4px;
    margin: 10px 0 15px;
    transition: 0.3s;
    direction: ltr;
}

.code-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--accent);
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-btn {
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: 0.2s;
    margin-top: 10px;
}

.modal-btn:active { transform: scale(0.97); }
.modal-btn.secondary { background: #f3f4f6; color: var(--text-dark); }

.modal-loader {
    width: 40px; height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    margin: 20px auto;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.modal-icon { margin-bottom: 5px; }
.success-icon { color: #4caf50; width: 60px; height: 60px; }
.error-icon   { color: #f44336; width: 60px; height: 60px; }
.reset-icon   { color: var(--primary); width: 50px; height: 50px; }

/* ===== UTILITIES ===== */
.hidden { display: none !important; }