/* ============================================================
   Power BI Manager — Light Theme
   تصميم فاتح أبيض عصري
   ============================================================ */

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

:root {
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #eff6ff;
  --primary-glow:  rgba(37,99,235,0.15);
  --secondary:     #0ea5e9;
  --accent:        #06b6d4;
  --success:       #10b981;
  --success-light: #f0fdf4;
  --warning:       #f59e0b;
  --warning-light: #fffbeb;
  --danger:        #ef4444;
  --danger-light:  #fef2f2;

  --bg:            #f8fafc;
  --bg-2:          #f1f5f9;
  --white:         #ffffff;
  --card-bg:       #ffffff;
  --sidebar-bg:    #ffffff;

  --border:        #e2e8f0;
  --border-light:  #f1f5f9;

  --text:          #1e293b;
  --text-2:        #334155;
  --text-muted:    #64748b;
  --text-light:    #94a3b8;

  --sidebar-w:     260px;
  --radius:        12px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:        0 4px 16px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg:     0 10px 32px rgba(0,0,0,0.1), 0 4px 12px rgba(0,0,0,0.06);
}

/* ── BASE ──────────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
  font-family: 'Cairo', sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  text-align: right;
  min-height: 100vh;
  margin: 0;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ── LOGIN PAGE ────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 70% 20%, rgba(37,99,235,0.06) 0%, transparent 55%),
    radial-gradient(ellipse at 10% 90%, rgba(6,182,212,0.05) 0%, transparent 50%),
    #f8fafc;
}

.login-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.5s ease;
}

.login-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary), #60a5fa);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  margin: 0 auto 24px;
  box-shadow: 0 8px 24px var(--primary-glow);
}

.login-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

/* ── FORM CONTROLS ──────────────────────────────────────── */
.form-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-2);
  margin-bottom: 6px;
}

.form-control, .form-select {
  background: var(--white);
  border: 1.5px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  font-family: 'Cairo', sans-serif;
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
  background: var(--white);
  border-color: var(--primary);
  color: var(--text);
  box-shadow: 0 0 0 3px var(--primary-glow);
  outline: none;
}

.form-control::placeholder { color: var(--text-light); }

.input-group-text {
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
}

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none;
  border-radius: 10px;
  font-family: 'Cairo', sans-serif;
  font-weight: 700;
  padding: 10px 22px;
  color: #fff;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37,99,235,0.25);
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
}

.btn-primary:active { transform: translateY(0); }

.btn-outline-primary {
  border: 1.5px solid var(--primary);
  color: var(--primary);
  border-radius: 10px;
  font-family: 'Cairo', sans-serif;
  font-weight: 600;
  background: transparent;
  transition: all 0.15s;
}

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

.btn-outline-secondary {
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  border-radius: 10px;
  font-family: 'Cairo', sans-serif;
  font-weight: 600;
  background: transparent;
}

.btn-outline-secondary:hover {
  background: var(--bg-2);
  color: var(--text);
}

.btn-warning  { border-radius: 8px; font-family: 'Cairo', sans-serif; font-weight: 600; }
.btn-success  { border-radius: 8px; font-family: 'Cairo', sans-serif; font-weight: 600; }
.btn-danger   { border-radius: 8px; font-family: 'Cairo', sans-serif; font-weight: 600; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform 0.3s;
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
}

.sidebar-brand {
  padding: 22px 20px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-light);
}

.brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), #60a5fa);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.sidebar-nav { padding: 14px 10px; flex: 1; }

.nav-section-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  padding: 10px 10px 5px;
  font-weight: 700;
}

.nav-item { margin-bottom: 2px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.875rem;
  transition: all 0.15s;
}

.nav-link i { font-size: 1rem; flex-shrink: 0; }

.nav-link:hover {
  background: var(--bg-2);
  color: var(--text);
}

.nav-link.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--border-light);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-2);
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #60a5fa);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 0.82rem;
  flex-shrink: 0;
}

.user-name { font-size: 0.83rem; font-weight: 700; color: var(--text); }
.user-role { font-size: 0.68rem; color: var(--text-muted); }

/* ── MAIN CONTENT ────────────────────────────────────────── */
.main-content {
  margin-right: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 13px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.page-body { padding: 28px; flex: 1; }

/* ── STAT CARDS ──────────────────────────────────────────── */
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
}

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

.stat-icon {
  width: 50px; height: 50px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.blue  { background: #eff6ff; color: var(--primary); }
.stat-icon.green { background: #f0fdf4; color: var(--success); }
.stat-icon.amber { background: #fffbeb; color: var(--warning); }
.stat-icon.cyan  { background: #ecfeff; color: var(--accent);  }

.stat-value { font-size: 1.75rem; font-weight: 900; color: var(--text); line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 3px; font-weight: 600; }

/* ── DATA TABLE ──────────────────────────────────────────── */
.data-table {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.data-table table { width: 100%; border-collapse: collapse; margin: 0; }

.data-table thead th {
  background: var(--bg-2);
  padding: 12px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.data-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.875rem;
  vertical-align: middle;
  color: var(--text-2);
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg); }

/* ── BADGES ──────────────────────────────────────────────── */
.badge-active   { background: #f0fdf4; color: #16a34a; }
.badge-inactive { background: #fef2f2; color: #dc2626; }
.badge-admin    { background: #eff6ff; color: var(--primary); }
.badge-user     { background: var(--bg-2); color: var(--text-muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.73rem;
  font-weight: 700;
}

/* ── CARD (Generic) ──────────────────────────────────────── */
.pbi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

/* ── DASHBOARD CARDS (User View) ─────────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.dash-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: block;
  box-shadow: var(--shadow-sm);
}

.dash-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 100%; height: 3px;
  background: var(--card-accent, var(--primary));
  border-radius: var(--radius) var(--radius) 0 0;
}

.dash-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--card-accent, var(--primary));
  color: inherit;
}

.dash-card-icon {
  width: 52px; height: 52px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  margin-bottom: 14px;
}

.dash-card-title {
  font-size: 0.97rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.dash-card-desc {
  font-size: 0.81rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 14px;
}

.dash-card-category {
  font-size: 0.7rem;
  color: var(--text-light);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dash-card-arrow {
  position: absolute;
  bottom: 20px;
  left: 20px;
  font-size: 1.1rem;
  opacity: 0;
  transition: opacity 0.2s, bottom 0.2s;
}

.dash-card:hover .dash-card-arrow { opacity: 1; bottom: 16px; }

/* ── ALERTS ──────────────────────────────────────────────── */
.alert {
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 12px 16px;
}

.alert-success { background: var(--success-light); color: #15803d; border-right: 3px solid var(--success); }
.alert-danger  { background: var(--danger-light);  color: #b91c1c; border-right: 3px solid var(--danger); }
.alert-warning { background: var(--warning-light); color: #b45309; border-right: 3px solid var(--warning); }
.alert-info    { background: var(--primary-light); color: var(--primary-dark); border-right: 3px solid var(--primary); }

.btn-close { filter: none; }

/* ── PAGE HEADER ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  margin: 0;
}

.page-header-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── PERMISSION CHECKBOXES ───────────────────────────────── */
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.perm-item {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}

.perm-item:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
}

.perm-item input[type=checkbox] { accent-color: var(--primary); width: 17px; height: 17px; }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 55px 20px; }
.empty-state i { font-size: 3rem; color: var(--text-light); }
.empty-state h5 { margin-top: 14px; color: var(--text-muted); font-weight: 600; }

/* ── SIDEBAR TOGGLE (mobile) ─────────────────────────────── */
.sidebar-toggle { display: none; }

/* ── LOG ACTION BADGE ────────────────────────────────────── */
.log-action {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 0.73rem;
  font-weight: 700;
  background: var(--primary-light);
  color: var(--primary);
}

/* ── MISC ────────────────────────────────────────────────── */
hr { border-color: var(--border); }
.form-text { color: var(--text-muted); font-size: 0.78rem; }
.text-danger { color: var(--danger) !important; }
.text-muted  { color: var(--text-muted) !important; }

/* ── LOADING OVERLAY ─────────────────────────────────────── */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: opacity 0.4s;
}

.spinner-ring {
  width: 48px; height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── ANIMATIONS ──────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-up { animation: fadeUp 0.35s ease both; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-right: 0; }
  .sidebar-toggle {
    display: flex;
    align-items: center;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.3rem;
    cursor: pointer;
  }
  .page-body { padding: 16px; }
  .dash-grid { grid-template-columns: 1fr; }
  .login-card { padding: 32px 24px; margin: 16px; }
}

/* ── SCROLLBAR ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }


/* ── إصلاح input-group في RTL ─────────────────────────── */
.input-group .form-control {
  border-radius: 0 !important;
}

.input-group .input-group-text:first-child {
  border-radius: 0 10px 10px 0 !important;
}

.input-group .input-group-text:last-child {
  border-radius: 10px 0 0 10px !important;
}

.input-group > .form-control:last-child {
  border-radius: 10px 0 0 10px !important;
}

.input-group > .form-control:first-child {
  border-radius: 0 10px 10px 0 !important;
}

/* حالة input بين عنصرين */
.input-group > .input-group-text + .form-control {
  border-radius: 0 !important;
}

.input-group > .form-control + .input-group-text {
  border-radius: 10px 0 0 10px !important;
}