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

:root,
[data-theme="pink-vivid"] {
  --primary: #d6336c;
  --primary-dark: #a61e4d;
  --primary-soft: #fff0f6;
  --navy: #5c2a4d;
  --gold: #e8590c;
  --gold-soft: #ffe8cc;
  --secondary: #a3708c;
  --success: #2f9e44;
  --success-soft: #ebfbee;
  --warning: #e8590c;
  --warning-soft: #fff4e6;
  --danger: #e03131;
  --danger-soft: #fff0f0;
  --bg: #fdf3f7;
  --card: #ffffff;
  --text: #3d1f31;
  --muted: #9c7b93;
  --border: #f5dde8;
  --shadow-sm: 0 1px 2px rgba(166, 30, 77, 0.07);
  --shadow-md: 0 10px 26px rgba(166, 30, 77, 0.10);
  --shadow-rich: 0 16px 36px rgba(166, 30, 77, 0.18), 0 3px 10px rgba(232, 89, 12, 0.12);
  --gradient-panel: linear-gradient(155deg, #ffe3ec 0%, #ffc2da 45%, #f06595 100%);
  --dots-color: rgba(255, 255, 255, 0.55);
}

[data-theme="pink-soft"] {
  --primary: #d68fa8;
  --primary-dark: #b56b86;
  --primary-soft: #fdf1f5;
  --navy: #6b4a5a;
  --gold: #c9a876;
  --gold-soft: #f3e7d4;
  --secondary: #b199a3;
  --success: #4d9161;
  --success-soft: #eef6ec;
  --warning: #c9915a;
  --warning-soft: #faf1e6;
  --danger: #c76a5a;
  --danger-soft: #faeeea;
  --bg: #fdfaf7;
  --card: #ffffff;
  --text: #4a3540;
  --muted: #a89099;
  --border: #f0e4e8;
  --shadow-sm: 0 1px 2px rgba(107, 74, 90, 0.05);
  --shadow-md: 0 8px 22px rgba(107, 74, 90, 0.08);
  --shadow-rich: 0 14px 30px rgba(107, 74, 90, 0.14), 0 3px 8px rgba(201, 168, 118, 0.10);
  --gradient-panel: linear-gradient(155deg, #faf3ee 0%, #f3e0da 55%, #e8c9c0 100%);
  --dots-color: rgba(255, 255, 255, 0.6);
}

[data-theme="blue"] {
  --primary: #2563eb;
  --primary-dark: #1741a6;
  --primary-soft: #eff6ff;
  --navy: #0f2a4a;
  --gold: #a97416;
  --gold-soft: #f3e2c2;
  --secondary: #64748b;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --bg: #f4f7fc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(15, 42, 74, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 42, 74, 0.08);
  --shadow-rich: 0 14px 34px rgba(15, 42, 74, 0.16), 0 3px 10px rgba(169, 116, 22, 0.14);
  --gradient-panel: linear-gradient(160deg, #eaf2ff 0%, #cfe2fb 45%, #9dc4f5 100%);
  --dots-color: rgba(255, 255, 255, 0.4);
}

:root {
  --radius: 18px;
  --radius-sm: 12px;
}

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

body {
  font-family: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
  direction: rtl;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 6% 12%, color-mix(in srgb, var(--primary) 8%, transparent) 0, transparent 45%),
    radial-gradient(circle at 94% 88%, color-mix(in srgb, var(--gold) 7%, transparent) 0, transparent 45%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
  font-size: 15.5px;
}

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

.app-footer {
  text-align: center;
  margin-top: 1.5rem;
  padding: 1.25rem 1rem 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted, #8a7d86);
  font-size: 0.8rem;
}
.app-footer p { margin: 0; }

/* ============ شريط التنقّل ============ */
.navbar {
  background: var(--gradient-panel);
  background-image:
    radial-gradient(circle, var(--dots-color) 1.5px, transparent 1.5px),
    var(--gradient-panel);
  background-size: 22px 22px, auto;
  color: var(--navy);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  box-shadow: var(--shadow-rich);
  border-bottom: 3px solid var(--gold);
}
.navbar-brand { color: var(--navy); font-size: 1.25rem; font-weight: 800; }
.navbar-nav { display: flex; gap: 0.4rem; list-style: none; flex-wrap: wrap; }
.navbar-nav a {
  color: rgba(92, 42, 77, 0.8);
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.92rem;
  background: rgba(255, 255, 255, 0.45);
  transition: background 0.15s, color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.navbar-nav a:hover { background: rgba(255, 255, 255, 0.8); color: var(--navy); text-decoration: none; transform: translateY(-1px); }
.navbar-nav a.active { background: var(--navy); color: #fff; box-shadow: 0 10px 22px rgba(92, 42, 77, 0.32); }
.navbar-nav a .icon, .navbar-brand .icon, .navbar-user .icon, .btn-logout .icon { font-size: 0.95rem; vertical-align: -1px; }
.navbar-brand { display: inline-flex; align-items: center; gap: 0.45rem; }
.navbar-brand .icon { font-size: 1.35rem; }
.navbar-user { color: var(--navy); font-size: 0.88rem; display: flex; gap: 0.75rem; align-items: center; font-weight: 600; }
.btn-logout { background: rgba(255,255,255,0.6); border: 1px solid rgba(92,42,77,0.15); color: var(--navy); padding: 0.4rem 0.9rem; border-radius: 999px; cursor: pointer; font-weight: 700; font-family: inherit; display: inline-flex; align-items: center; gap: 0.35rem; }
.btn-logout:hover { background: rgba(255,255,255,0.9); }
.btn .icon { font-size: 0.95rem; vertical-align: -1px; margin-inline-end: 2px; }

/* ===== شريط علوي بصفين + قوائم منسدلة مجمّعة ===== */
.navbar { row-gap: 0.6rem; }
.navbar-brand { order: 1; }
.navbar-user { order: 2; margin-inline-start: auto; }
.navbar-nav { order: 3; width: 100%; align-items: center; }
.navbar-nav > li { position: relative; }
.nav-group { position: relative; }
.nav-group-btn {
  font-family: inherit; cursor: pointer; border: 0;
  color: rgba(92, 42, 77, 0.8); padding: 0.55rem 1.1rem; border-radius: 999px;
  font-weight: 700; font-size: 0.92rem; background: rgba(255, 255, 255, 0.45);
  transition: background 0.15s, color 0.15s, transform 0.15s, box-shadow 0.15s;
  display: inline-flex; align-items: center; gap: 0.3rem;
}
.nav-group-btn:hover, .nav-group.open > .nav-group-btn { background: rgba(255, 255, 255, 0.85); color: var(--navy); }
.nav-group-btn.active { background: var(--navy); color: #fff; box-shadow: 0 10px 22px rgba(92, 42, 77, 0.32); }
.nav-group-btn .icon { font-size: 0.95rem; vertical-align: -1px; }
.nav-caret { font-size: 0.7rem; opacity: 0.8; }
.nav-menu {
  display: none; position: absolute; top: calc(100% + 6px); inset-inline-start: 0; z-index: 60;
  min-width: 230px; padding: 0.4rem; background: #fff; border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-rich);
}
.nav-group.open > .nav-menu { display: block; }
.navbar-nav .nav-menu a.nav-menu-item { padding: 0.55rem 0.8rem; border-radius: 10px; background: transparent; color: var(--navy); transform: none; box-shadow: none; }
.navbar-nav .nav-menu a.nav-menu-item:hover { background: var(--primary-soft, #fce3ee); transform: none; }
.navbar-nav .nav-menu a.nav-menu-item.active { background: var(--navy); color: #fff; }
.nav-menu-user { min-width: 170px; }
.nav-menu-item {
  display: flex; align-items: center; gap: 0.5rem; width: 100%; text-align: right;
  padding: 0.55rem 0.8rem; border-radius: 10px; font-weight: 700; font-size: 0.9rem;
  color: var(--navy); background: transparent; border: 0; cursor: pointer; font-family: inherit;
}
.nav-menu-item:hover { background: var(--primary-soft, #fce3ee); text-decoration: none; }
.nav-menu-item.active { background: var(--navy); color: #fff; }
.nav-menu-item .icon { font-size: 0.95rem; }
.nav-menu form { margin: 0; }
.nav-user-btn { font-size: 0.88rem; }
@media (max-width: 700px) {
  .navbar-user { margin-inline-start: 0; }
  .navbar-brand { font-size: 1rem; }
}

.container { max-width: 1400px; margin: 0 auto; padding: 1.5rem; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(166, 30, 77, 0.05);
  margin-bottom: 1.25rem;
}
.card-title { font-size: 1.2rem; font-weight: 800; margin-bottom: 1rem; color: var(--navy); padding-bottom: 0.75rem; border-bottom: 1px solid var(--border); }

.alert { padding: 0.85rem 1.1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-weight: 600; }
.alert-success { background: var(--success-soft); color: #1b6b2f; border: 1px solid #b7e8c2; }
.alert-danger { background: var(--danger-soft); color: #a11c1c; border: 1px solid #f7c2c2; }
.alert-info { background: #fff0f6; color: var(--primary-dark); border: 1px solid #ffc2da; }
.alert-warning { background: var(--warning-soft); color: #a3410a; border: 1px solid #ffd8a8; }

.btn {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
  text-decoration: none;
  font-size: 0.9rem;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 6px 16px rgba(214, 51, 108, 0.32); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 8px 20px rgba(214, 51, 108, 0.38); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #237a35; }
.btn-secondary { background: #fbe4ee; color: var(--navy); }
.btn-secondary:hover { background: #f6d2e3; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: white; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-soft); }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.8rem; }

.form-group { margin-bottom: 1rem; }
.form-label { display: block; margin-bottom: 0.4rem; font-weight: 700; color: var(--navy); font-size: 0.9rem; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-family: inherit;
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(214, 51, 108, 0.14);
}
.form-textarea { resize: vertical; min-height: 100px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.7rem 0.85rem; text-align: right; border: 1px solid var(--border); font-size: 0.875rem; vertical-align: middle; }
th { background: #fce3ee; font-weight: 800; color: var(--navy); white-space: nowrap; font-size: 0.82rem; }
thead th:first-child { border-top-right-radius: var(--radius-sm); }
thead th:last-child { border-top-left-radius: var(--radius-sm); }
tbody tr:nth-child(even) { background: #fdf3f7; }
tbody tr:hover td { background: #ffe3ec; }

.badge {
  display: inline-block;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.badge-green { background: var(--success-soft); color: #1b6b2f; }
.badge-blue { background: #eef1ff; color: #4338ca; }
.badge-yellow { background: var(--warning-soft); color: #a3410a; }
.badge-red { background: var(--danger-soft); color: #a11c1c; }
.badge-gray { background: #f3e8ee; color: #7d6272; }
.badge-purple { background: #f4ecff; color: #7038c7; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
@media (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.stat-card {
  background: linear-gradient(165deg, #ffffff 0%, #fff8fb 100%);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid rgba(166, 30, 77, 0.06);
  box-shadow: var(--shadow-sm);
}
.stat-card .label { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.3rem; font-weight: 600; }
.stat-card .value { font-size: 1.85rem; font-weight: 800; color: var(--navy); }

.auth-wrap {
  min-height: 100vh;
  display: flex;
}
.auth-form-side {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background: #fff;
}
.auth-brand-side {
  flex: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 3rem;
  background: var(--gradient-panel);
  background-image:
    radial-gradient(circle, var(--dots-color) 2px, transparent 2px),
    var(--gradient-panel);
  background-size: 26px 26px, auto;
  color: var(--navy);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.auth-brand-side::before, .auth-brand-side::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
}
.auth-brand-side::before { width: 260px; height: 260px; top: -80px; inset-inline-end: -80px; }
.auth-brand-side::after { width: 180px; height: 180px; bottom: -60px; inset-inline-start: -60px; background: rgba(255, 255, 255, 0.3); }
.auth-brand-side > * { position: relative; z-index: 1; }
.auth-brand-wordmark { font-size: 2.1rem; font-weight: 800; letter-spacing: -0.5px; }
.auth-brand-tagline { font-size: 0.95rem; color: rgba(92, 42, 77, 0.8); max-width: 320px; }
@media (min-width: 820px) { .auth-brand-side { display: flex; } .auth-form-side { max-width: 50%; } }

.auth-card {
  background: white;
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}
.auth-card h2 { text-align: center; margin-bottom: 1.5rem; color: var(--navy); font-size: 1.4rem; font-weight: 800; }

.import-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.import-tile {
  background: white;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: all 0.2s;
  display: block;
  color: inherit;
}
.import-tile:hover { border-color: var(--primary); background: var(--primary-soft); text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.import-tile h3 { color: var(--primary-dark); margin-bottom: 0.4rem; font-size: 1rem; }
.import-tile p { color: var(--muted); font-size: 0.85rem; }

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mb-2 { margin-bottom: 1rem; }
.mt-2 { margin-top: 1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.strong { font-weight: 700; }

.pagination { display: flex; gap: 0.4rem; justify-content: center; margin-top: 1.25rem; }
.pagination a, .pagination span { padding: 0.45rem 0.8rem; border-radius: 999px; background: white; border: 1px solid var(--border); font-size: 0.85rem; font-weight: 600; }
.pagination .current { background: var(--navy); color: white; border-color: var(--navy); }

details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: '▸ '; color: var(--primary); }
details[open] > summary::before { content: '▾ '; }

@media print {
  .navbar, .btn, form, .no-print { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  body { background: #fff; }
}
