/* ═══════════════════════════════════════════════
   DPS Dashboard — style.css  (2025 redesign)
═══════════════════════════════════════════════ */
:root {
    --primary:       #4361ee;
    --primary-light: #6b7de8;
    --secondary:     #3f37c9;
    --success:       #22c55e;
    --warning:       #f8961e;
    --danger:        #f72585;
    --danger-dark:   #d81b6b;
    --light:         #f8f9fa;
    --dark:          #1e293b;
    --dark-light:    #334155;
    --gray:          #64748b;
    --gray-light:    #e2e8f0;
    --sidebar-width: 260px;
    --navbar-h:      60px;
    --radius:        12px;
    --transition:    all 0.3s cubic-bezier(0.4,0,0.2,1);
    --shadow-sm:     0 2px 8px rgba(0,0,0,.06);
    --shadow-md:     0 4px 16px rgba(0,0,0,.10);
    --shadow-lg:     0 8px 32px rgba(0,0,0,.15);
}

/* ─── Reset ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Tajawal', 'Segoe UI', sans-serif;
    background: linear-gradient(135deg,#f6f9ff 0%,#f0f4ff 100%);
    color: var(--dark);
    min-height: 100vh;
    direction: rtl;
    padding-top: var(--navbar-h);
    overflow-x: hidden;
}

/* ─── Navbar ────────────────────────────────── */
.navbar {
    position: fixed;
    top: 0; right: 0; left: 0;
    height: var(--navbar-h);
    background: white;
    border-bottom: 1px solid var(--gray-light);
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 1100;
    box-shadow: var(--shadow-sm);
    gap: 16px;
}
.navbar-brand {
    font-size: 17px;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}
.navbar-brand span { color: var(--dark); }
.navbar-user {
    font-size: 13px;
    color: var(--gray);
    display: flex;
    align-items: center;
    gap: 8px;
}
.navbar-avatar {
    width: 34px; height: 34px;
    background: linear-gradient(135deg,var(--primary),var(--secondary));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 700; font-size: 14px;
}
.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    color: var(--dark);
    font-size: 22px;
    transition: var(--transition);
}
.hamburger:hover { background: var(--light); }

/* ─── Sidebar ───────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    border-left: 1px solid var(--gray-light);
    box-shadow: 3px 0 20px rgba(67,97,238,.07);
    position: fixed;
    top: var(--navbar-h);
    right: 0;
    height: calc(100vh - var(--navbar-h));
    overflow-y: auto;
    z-index: 1000;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    padding-bottom: 20px;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--primary-light); border-radius: 2px; }

.sidebar-section {
    font-size: 10px;
    font-weight: 700;
    color: var(--gray);
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 20px 20px 6px;
}
.sidebar nav { padding: 8px 12px; flex: 1; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--dark-light);
    text-decoration: none;
    border-radius: var(--radius);
    margin-bottom: 4px;
    font-weight: 500;
    font-size: 14px;
    transition: var(--transition);
    position: relative;
}
.sidebar nav a .nav-icon { font-size: 18px; width: 22px; text-align: center; }
.sidebar nav a:hover {
    background: rgba(67,97,238,.06);
    color: var(--primary);
    padding-right: 20px;
}
.sidebar nav a.active {
    background: linear-gradient(90deg,rgba(67,97,238,.12),rgba(67,97,238,.05));
    color: var(--primary);
    font-weight: 600;
}
.sidebar nav a.active::after {
    content: '';
    position: absolute;
    right: 0; top: 20%; height: 60%;
    width: 4px;
    background: var(--primary);
    border-radius: 2px 0 0 2px;
}
.sidebar-logout {
    margin: 0 12px;
    padding: 12px 16px;
    display: flex; align-items: center; gap: 12px;
    color: var(--danger);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}
.sidebar-logout:hover { background: rgba(247,37,133,.07); }
.db-status {
    font-size: 11px;
    color: var(--gray);
    text-align: center;
    padding: 10px 20px 0;
    border-top: 1px solid var(--gray-light);
    margin: 0 12px;
}

/* ─── Main Content ──────────────────────────── */
.content {
    margin-right: var(--sidebar-width);
    padding: 28px 32px;
    min-height: calc(100vh - var(--navbar-h));
    transition: var(--transition);
}
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-light);
}
.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
}
.last-update { font-size: 12px; color: var(--gray); }

/* ─── KPI / Stat Cards ──────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px,1fr));
    gap: 20px;
    margin-bottom: 28px;
}
.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 22px 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-light);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; right: 0; left: 0;
    height: 3px;
    background: linear-gradient(90deg,var(--primary),var(--primary-light));
}
.stat-card:nth-child(2)::before { background: linear-gradient(90deg,var(--success),#86efac); }
.stat-card:nth-child(3)::before { background: linear-gradient(90deg,var(--warning),#fcd34d); }
.stat-card:nth-child(4)::before { background: linear-gradient(90deg,var(--danger),var(--danger-dark)); }
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.stat-icon-wrap {
    width: 52px; height: 52px;
    border-radius: 14px;
    background: rgba(67,97,238,.1);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    transition: var(--transition);
}
.stat-card:hover .stat-icon-wrap { transform: scale(1.1) rotate(5deg); }
.stat-card:nth-child(2) .stat-icon-wrap { background: rgba(34,197,94,.1); }
.stat-card:nth-child(3) .stat-icon-wrap { background: rgba(248,150,30,.1); }
.stat-card:nth-child(4) .stat-icon-wrap { background: rgba(247,37,133,.1); }
/* legacy compat */
.stat-icon { font-size: 24px; }
.stat-info { flex: 1; min-width: 0; }
.stat-label { font-size: 12px; color: var(--gray); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--dark); line-height: 1; }

/* ─── Charts ────────────────────────────────── */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px,1fr));
    gap: 20px;
    margin-bottom: 28px;
}
.chart-container {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-light);
}
.chart-container h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ─── Tables ────────────────────────────────── */
.table-container {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-light);
    overflow: hidden;
    margin-bottom: 24px;
}
.table-container .table-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.table-container .table-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--dark);
}
/* make legacy <table> look like .table-container */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-light);
}
table thead {
    background: linear-gradient(135deg,var(--primary),var(--secondary));
    color: white;
}
table th, table td { padding: 14px 16px; text-align: right; }
table th {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .3px;
    white-space: nowrap;
    border: none;
}
table td {
    font-size: 13px;
    color: var(--dark-light);
    border-bottom: 1px solid var(--gray-light);
    vertical-align: middle;
}
table tbody tr:last-child td { border-bottom: none; }
table tbody tr:hover { background: rgba(67,97,238,.04); }
table code {
    background: rgba(67,97,238,.07);
    color: var(--primary);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 12px;
}

/* ─── Status Badges ─────────────────────────── */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .3px;
}
.status-online, .badge-success  { background:#dcfce7; color:#166534; }
.status-offline, .badge-danger   { background:#ffe4e6; color:#9f1239; }
.status-warning, .badge-warning  { background:#fef9c3; color:#854d0e; }

/* ─── Forms ─────────────────────────────────── */
.form-group  { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--dark-light);
    margin-bottom: 6px;
}
.form-control, .form-select,
input[type=text], input[type=email],
input[type=password], input[type=number],
select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-light);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: var(--light);
    color: var(--dark);
    transition: var(--transition);
    outline: none;
}
.form-control:focus, .form-select:focus,
input[type=text]:focus, input[type=email]:focus,
input[type=password]:focus, input[type=number]:focus,
select:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(67,97,238,.12);
}

/* ─── Buttons ───────────────────────────────── */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    font-family: inherit;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    text-decoration: none;
}
.btn-primary {
    background: linear-gradient(135deg,var(--primary),var(--secondary));
    color: white;
    box-shadow: 0 4px 12px rgba(67,97,238,.25);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(67,97,238,.35); color: white; }
.btn-sm  { padding: 6px 14px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn-delete {
    background: linear-gradient(135deg,var(--danger),var(--danger-dark));
    color: white;
    padding: 5px 12px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}
.btn-delete:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(247,37,133,.3); }
.btn-reset {
    background: linear-gradient(135deg,#3b82f6,#2563eb);
    color: white;
    padding: 5px 12px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}
.btn-reset:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(59,130,246,.3); }

/* ─── Cards (form wrappers) ─────────────────── */
.card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-light);
    margin-bottom: 24px;
    transition: var(--transition);
}
.card h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-light);
}

/* ─── Alerts ────────────────────────────────── */
.alert {
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-success { background:#dcfce7; color:#166534; border: 1px solid #86efac; }
.alert-error   { background:#ffe4e6; color:#9f1239; border: 1px solid #fda4af; }

/* ─── Activity List ─────────────────────────── */
.activity-list { list-style: none; }
.activity-list li {
    padding: 12px 4px;
    border-bottom: 1px solid var(--gray-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}
.activity-list li:last-child { border-bottom: none; }
.activity-type {
    background: rgba(67,97,238,.1);
    color: var(--primary);
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.activity-message { flex: 1; color: var(--dark-light); }
.activity-time    { font-size: 11px; color: var(--gray); white-space: nowrap; }

/* ─── Pagination ────────────────────────────── */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.pagination a {
    padding: 7px 14px;
    background: white;
    border: 1px solid var(--gray-light);
    border-radius: 8px;
    text-decoration: none;
    color: var(--primary);
    font-size: 13px;
    transition: var(--transition);
}
.pagination a:hover  { background: rgba(67,97,238,.07); transform: translateY(-1px); }
.pagination a.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ─── Login Page ────────────────────────────── */
.login-page {
    background: linear-gradient(135deg,var(--primary) 0%,var(--secondary) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    padding-top: 20px; /* override body padding-top */
}
.login-container { width: 100%; max-width: 420px; }
.login-box {
    background: white;
    border-radius: 20px;
    padding: 44px 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-logo {
    width: 64px; height: 64px;
    background: linear-gradient(135deg,var(--primary),var(--secondary));
    border-radius: 18px;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px;
    margin: 0 auto 16px;
    box-shadow: 0 8px 20px rgba(67,97,238,.3);
}
.login-header h1 { font-size: 22px; color: var(--dark); margin-bottom: 6px; }
.login-header p  { font-size: 13px; color: var(--gray); }
.login-form .form-group { margin-bottom: 18px; }
.login-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--dark-light);
    margin-bottom: 7px;
}
.login-form input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--gray-light);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    background: var(--light);
    transition: var(--transition);
    outline: none;
}
.login-form input:focus { border-color: var(--primary); background: white; box-shadow: 0 0 0 4px rgba(67,97,238,.12); }

/* ─── Sidebar Overlay (mobile) ──────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 999;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ─── Responsive ────────────────────────────── */
@media (max-width: 992px) {
    .hamburger { display: block; }
    .sidebar {
        transform: translateX(110%);
        top: 0 !important;
        height: 100dvh !important;
        z-index: 1050;
        box-shadow: none;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: -8px 0 32px rgba(0,0,0,.22);
    }
    .content { margin-right: 0 !important; padding: 20px 16px; }
}
@media (max-width: 640px) {
    .stats-grid  { grid-template-columns: repeat(2,1fr); gap: 12px; }
    .charts-grid { grid-template-columns: 1fr; }
    .content     { padding: 14px 10px; }
    .page-header h1 { font-size: 18px; }
    .stat-value  { font-size: 22px; }
    table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .login-box   { padding: 32px 24px; }
}
@media (max-width: 400px) {
    .stats-grid  { grid-template-columns: 1fr; }
}

/* ─── Print ─────────────────────────────────── */
@media print {
    .sidebar, .navbar, .hamburger, .sidebar-overlay,
    .btn, .btn-delete, .btn-reset, form[method=POST] { display: none !important; }
    .content { margin: 0 !important; padding: 0 !important; }
    body { background: white !important; padding-top: 0 !important; }
    table thead { background: #334155 !important; color: white !important; }
    table th, table td { border: 1px solid #ccc !important; }
}
