/* =================================
   1. GLOBAL STYLES & VARIABLES
   ================================= */
:root {
    --primary-color: #0d6efd;
    --dark-color: #212529;
    --sidebar-bg: #111827;
    --sidebar-text: #d1d5db;
    --sidebar-text-hover: #ffffff;
    --content-bg: #f9fafb;
    --sidebar-width: 260px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Tajawal', sans-serif; background-color: #f0f2f5; direction: rtl; }

/* =================================
   2. LOGIN PAGE STYLES
   ================================= */
.login-container { width: 100%; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { max-width: 450px; width: 100%; background-color: #fff; border-radius: 15px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1); overflow: hidden; text-align: center; }
.login-card .card-header { background-color: var(--primary-color); color: white; padding: 30px 25px; }
.logo-container { display: flex; align-items: center; justify-content: center; margin-bottom: 1rem; position: relative; height: 60px; }
.logo-icon { font-size: 3.2rem; color: #fff; z-index: 2; position: relative; right: -20px; text-shadow: 2px 2px 5px rgba(0,0,0,0.3); }
.gate-icon { font-size: 5rem; color: rgba(255, 255, 255, 0.7); z-index: 1; position: relative; }
.login-card .card-body { padding: 30px 35px; }
.input-group { display: flex; margin-bottom: 20px; border: 1px solid #ced4da; border-radius: 8px; overflow: hidden; }
.input-group:focus-within { border-color: var(--primary-color); box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25); }
.input-icon { background-color: #f8f9fa; padding: 10px 15px; display: flex; align-items: center; justify-content: center; color: #495057; border-left: 1px solid #ced4da; }
.input-group input { flex-grow: 1; border: none; padding: 15px; font-size: 16px; font-family: 'Tajawal', sans-serif; }
.input-group input:focus { outline: none; }
.login-card .card-footer { background-color: #f8f9fa; color: #6c757d; padding: 15px; font-size: 14px; }

/* =================================
   3. RESPONSIVE DASHBOARD LAYOUT
   ================================= */
.page-wrapper { display: flex; background-color: var(--content-bg); }
.sidebar { width: var(--sidebar-width); background-color: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; height: 100vh; position: fixed; top: 0; right: 0; z-index: 1020; transition: transform 0.3s ease-in-out; }
.sidebar-header { padding: 1.5rem; display: flex; align-items: center; gap: 10px; font-size: 1.5rem; color: #fff; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.sidebar-menu { list-style: none; padding: 1rem 0; margin: 0; flex-grow: 1; }
.sidebar-menu li a { display: flex; align-items: center; gap: 15px; padding: 0.9rem 1.5rem; color: var(--sidebar-text); text-decoration: none; transition: background-color 0.2s, color 0.2s; }
.sidebar-menu li a:hover { background-color: rgba(255, 255, 255, 0.05); color: var(--sidebar-text-hover); }
.sidebar-menu li.active a { background-color: var(--primary-color); color: #fff; font-weight: bold; }
.sidebar-menu li a i { font-size: 1.2rem; }
.sidebar-footer { padding: 1rem; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.logout-btn { display: flex; align-items: center; gap: 10px; padding: 0.75rem; background-color: rgba(220, 53, 69, 0.2); color: #f8d7da; border-radius: 8px; text-decoration: none; justify-content: center; transition: background-color 0.2s; }
.logout-btn:hover { background-color: rgba(220, 53, 69, 0.4); }
.main-content { flex-grow: 1; margin-right: var(--sidebar-width); height: 100vh; overflow-y: auto; transition: margin-right 0.3s ease-in-out; }
.top-bar { background: #fff; padding: 1rem 2rem; border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; }
.welcome-message { display: flex; align-items: center; gap: 1rem; }
.content-body { padding: 2.5rem; }
.menu-toggle { display: none; background: none; border: none; color: #343a40; font-size: 1.5rem; cursor: pointer; }
@media (max-width: 992px) {
    .sidebar { transform: translateX(100%); }
    .sidebar.is-open { transform: translateX(0); box-shadow: 0 0 20px rgba(0,0,0,0.2); }
    .main-content { margin-right: 0; }
    .menu-toggle { display: block; }
    .sidebar-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); z-index: 1010; display: none; }
    .sidebar-overlay.is-visible { display: block; }
}

/* =================================
   4. RESPONSIVE GRID SYSTEM
   ================================= */
.row { display: flex; flex-wrap: wrap; margin: 0 -15px; }
[class*="col-"] { width: 100%; padding: 0 15px; margin-bottom: 1.5rem; }
@media (min-width: 768px) { .col-md-5 { width: 41.66%; } .col-md-7 { width: 58.33%; } }
@media (min-width: 992px) { .col-lg-4 { width: 33.33%; } .col-lg-5 { width: 41.66%; } .col-lg-7 { width: 58.33%; } .col-lg-8 { width: 66.66%; } }

/* =================================
   5. REUSABLE COMPONENTS (BUTTONS, ALERTS, FORMS, etc.)
   ================================= */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; font-weight: 500; text-decoration: none; transition: all 0.2s; padding: 0.8rem 1.5rem; border: none; border-radius: 8px; font-size: 1rem; cursor: pointer; }
.btn-primary { background-color: var(--primary-color); color: #fff; }
.btn-primary:hover { background-color: #0b5ed7; }
.btn-success { background-color: #198754; color: #fff; padding: 0.7rem 1.2rem; }
.btn-success:hover { background-color: #157347; }
.alert { padding: 1rem; margin-bottom: 1.5rem; border-radius: 8px; border: 1px solid transparent; }
.alert-danger { color: #842029; background-color: #f8d7da; border-color: #f5c2c7; }
.alert-success { color: #0f5132; background-color: #d1e7dd; border-color: #badbcc; }
.alert-warning { background-color: #fff3cd; color: #664d03; border-color: #ffc107; }
.page-header { margin-bottom: 2rem; padding-bottom: 1rem; border-bottom: 1px solid #dee2e6; }
.page-header h2 { margin: 0 0 0.5rem 0; color: #343a40; }
.page-header p { margin: 0; font-size: 1.1rem; color: #6c757d; }
.card { background-color: #fff; border: 1px solid #e5e7eb; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.card-header { padding: 1rem 1.5rem; border-bottom: 1px solid #e5e7eb; background-color: #f9fafb; }
.card-header h3 { margin: 0; font-size: 1.1rem; color: #374151; display: flex; align-items: center; gap: 10px; }
.card-body { padding: 1.5rem; }
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 0.9rem 1rem; text-align: right; border-bottom: 1px solid #e5e7eb; vertical-align: middle; }
.table thead th { background-color: #f9fafb; color: #6b7280; font-weight: 500; }
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: #374151; }
.form-control { width: 100%; padding: 0.75rem 1rem; border: 1px solid #d1d5db; border-radius: 8px; font-size: 1rem; transition: border-color 0.2s, box-shadow 0.2s; }
.form-control:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15); }
.filter-form { display: flex; align-items: flex-end; gap: 1.5rem; flex-wrap: wrap; }
.filter-form .form-group { flex-grow: 1; margin-bottom: 0; }
.filter-form button, .filter-form a { height: fit-content; }
.badge { padding: 0.3em 0.7em; border-radius: 12px; font-size: 0.8em; background-color: #e5e7eb; color: #374151; }
.text-center { text-align: center; }

/* =================================
   6. PAGE-SPECIFIC & UNIQUE COMPONENTS
   ================================= */
/* --- User Management Action Buttons (btn-action) --- */
.actions-cell { white-space: nowrap; }
.btn-action { display: inline-block; width: 36px; height: 36px; line-height: 36px; text-align: center; border-radius: 50%; color: #fff; text-decoration: none; margin: 0 2px; font-size: 0.9rem; border: none; cursor: pointer; transition: transform 0.2s, opacity 0.2s; }
.btn-action:hover { transform: scale(1.1); opacity: 0.9; }
.btn-action.edit { background-color: #3b82f6; }
.btn-action.delete { background-color: #ef4444; }
.btn-action.status.activate { background-color: #10b981; }
.btn-action.status.deactivate { background-color: #f59e0b; }
.status { padding: 0.3em 0.8em; border-radius: 15px; font-size: 0.85em; font-weight: 500; }
.status-active { background-color: rgba(16, 185, 129, 0.1); color: #059669; }
.status-inactive { background-color: rgba(107, 114, 128, 0.1); color: #4b5563; }
.text-muted { color: #9ca3af; font-style: italic; }

/* --- Admin Quick Links --- */
.admin-links a { display: flex; align-items: center; gap: 15px; padding: 1rem; margin-bottom: 0.75rem; background-color: #f8f9fa; border: 1px solid #e9ecef; border-radius: 8px; text-decoration: none; color: #343a40; font-size: 1.1rem; font-weight: 500; transition: all 0.2s ease-in-out; }
.admin-links a:hover { background-color: var(--primary-color); color: #fff; border-color: var(--primary-color); transform: scale(1.03); }
.admin-links a i { font-size: 1.5rem; width: 30px; text-align: center; color: var(--primary-color); transition: color 0.2s ease-in-out; }
.admin-links a:hover i { color: #fff; }

/* --- Live Dashboard Flow --- */
@keyframes count-update-animation { 0% { transform: scale(1); } 50% { transform: scale(1.3); } 100% { transform: scale(1); } }
@keyframes glow-animation-gray { 0%, 100% { box-shadow: 0 0 5px #6c757d, 0 0 10px #6c757d; } 50% { box-shadow: 0 0 20px #6c757d, 0 0 30px #6c757d; } }
@keyframes glow-animation-orange { 0%, 100% { box-shadow: 0 0 5px #fd7e14, 0 0 10px #fd7e14; } 50% { box-shadow: 0 0 20px #fd7e14, 0 0 30px #fd7e14; } }
@keyframes glow-animation-green { 0%, 100% { box-shadow: 0 0 5px #198754, 0 0 10px #198754; } 50% { box-shadow: 0 0 20px #198754, 0 0 30px #198754; } }
.flow-dashboard-wrapper { background: #f8f9fa; border-radius: 12px; padding: 2rem; overflow-x: auto; }
.flow-dashboard-container { display: flex; align-items: stretch; justify-content: space-between; gap: 1rem; min-width: 900px; }
.flow-stage { background-color: #fff; border-radius: 10px; box-shadow: 0 5px 20px rgba(0,0,0,0.08); display: flex; align-items: center; padding: 1.5rem 2rem; flex: 1; border-left: 8px solid; transition: all 0.3s ease; }
.flow-stage.glowing { transform: translateY(-5px); }
.flow-stage.waiting.glowing { animation: glow-animation-gray 2.5s infinite ease-in-out; }
.flow-stage.pending.glowing { animation: glow-animation-orange 2.5s infinite ease-in-out; }
.flow-stage.ready.glowing { animation: glow-animation-green 2.5s infinite ease-in-out; }
.flow-icon { font-size: 3.5rem; margin-left: 1.5rem; }
.flow-content { text-align: right; }
.flow-count { font-size: 5rem; font-weight: 700; margin: 0; line-height: 1; }
.flow-count.updated { animation: count-update-animation 0.3s ease-in-out; }
.flow-title { margin: 0.5rem 0 0 0; color: #6c757d; font-size: 1.3rem; }
.flow-stage.waiting { border-left-color: #6c757d; } .flow-stage.waiting .flow-icon { color: #6c757d; }
.flow-stage.pending { border-left-color: #fd7e14; } .flow-stage.pending .flow-icon { color: #fd7e14; }
.flow-stage.ready { border-left-color: #198754; } .flow-stage.ready .flow-icon { color: #198754; }
.flow-connector { display: flex; align-items: center; justify-content: center; font-size: 2.5rem; color: #ced4da; padding: 0 1rem; }

/* Stat Cards */
.dashboard-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; }
.stat-card { background-color: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 1.5rem; display: flex; align-items: center; gap: 1rem; transition: transform 0.2s, box-shadow 0.2s; }
.stat-card:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.07); }
.stat-card .icon { font-size: 2rem; width: 60px; height: 60px; display: grid; place-items: center; border-radius: 50%; }
.stat-card .info h3 { margin: 0 0 5px 0; font-size: 1rem; color: #6b7280; }
.stat-card .info p { margin: 0; font-size: 2rem; font-weight: 700; color: var(--dark-color); }
.stat-card.blue .icon { background-color: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.stat-card.green .icon { background-color: rgba(16, 185, 129, 0.1); color: #10b981; }
.stat-card.yellow .icon { background-color: rgba(245, 158, 11, 0.1); color: #f59e0b; }

/* Modal Styles */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(30, 41, 59, 0.8); display: none; justify-content: center; align-items: center; z-index: 1050; backdrop-filter: blur(5px); }
.modal-content { background-color: #fff; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); width: 90%; max-width: 650px; display: flex; flex-direction: column; animation: slide-down 0.4s cubic-bezier(0.25, 0.8, 0.25, 1); }
@keyframes slide-down { from { transform: translateY(-50px) scale(0.95); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid #e5e7eb; background-color: #f9fafb; }
.modal-header h4 { margin: 0; font-size: 1.25rem; color: #1f2937; font-weight: 700; }
.modal-close { background: #e5e7eb; border: none; font-size: 1.2rem; color: #4b5563; cursor: pointer; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; transition: background-color 0.2s, color 0.2s; }
.modal-close:hover { background-color: #ef4444; color: #fff; }
.modal-body { padding: 1.5rem; max-height: 60vh; overflow-y: auto; }
.modal-loader, .modal-error { text-align: center; padding: 2rem; color: #6b7280; font-size: 1.1rem; }
.modal-body .tooltip-table { width: 100%; border-collapse: collapse; color: #374151; }
.modal-body .tooltip-table th, .modal-body .tooltip-table td { padding: 0.8rem 1rem; text-align: right; border-bottom: 1px solid #f3f4f6; font-size: 1rem; }
.modal-body .tooltip-table thead th { background-color: #f9fafb; font-weight: 700; color: #4b5563; }
.modal-body .tooltip-table tbody tr:nth-of-type(even) { background-color: #f9fafb; }
.modal-footer { padding: 1rem 1.5rem; background-color: #f9fafb; border-top: 1px solid #e5e7eb; text-align: left; font-size: 1.2rem; font-weight: bold; display: flex; justify-content: space-between; }
.clickable-row { cursor: pointer; transition: background-color 0.2s; }
.clickable-row:hover { background-color: #f1f5f9; }

/* Timeline List in Modal */
.timeline-list { list-style: none; padding: 0; margin: 0; }
.timeline-list li { display: flex; align-items: flex-start; position: relative; padding-bottom: 1.5rem; }
.timeline-list li:not(:last-child)::before { content: ''; position: absolute; top: 15px; right: 14px; width: 2px; height: 100%; background-color: #e5e7eb; }
.timeline-icon { font-size: 1.6rem; width: 30px; text-align: center; margin-left: 1.2rem; z-index: 1; background-color: #fff; }
.timeline-content strong { display: block; font-size: 1.2rem; color: #374151; margin-bottom: 5px; }
.timeline-content small { color: #6b7280; font-size: 1rem; font-weight: 500; }
/* =================================
   IMPROVED MINI FLOW ON ADMIN INDEX
   ================================= */
.mini-flow-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}
.mini-flow-card {
    background-color: #f8f9fa;
    border-radius: 10px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    border-top: 5px solid; /* الشريط العلوي الملون */
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}
.mini-flow-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}
.mini-flow-card .icon-wrapper {
    font-size: 2.5rem;
}
.mini-flow-card .info-wrapper .count {
    display: block;
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
    color: #343a40;
}
.mini-flow-card .info-wrapper .label {
    color: #6c757d;
    font-size: 1.1rem;
}
/* ألوان المراحل */
.mini-flow-card.waiting { border-top-color: #6c757d; }
.mini-flow-card.waiting .icon-wrapper { color: #6c757d; }

.mini-flow-card.pending { border-top-color: #fd7e14; }
.mini-flow-card.pending .icon-wrapper { color: #fd7e14; }

.mini-flow-card.ready { border-top-color: #198754; }
.mini-flow-card.ready .icon-wrapper { color: #198754; }