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

:root {
  --brand: #254a85;
  --accent: #f5a623;
  --bg: #f4f6fa;
  --muted: #6b7280;
  --card: #ffffff;
  --border: #e6e9ef;
}

* {
  box-sizing: border-box;
  font-family: 'Almarai', sans-serif;
}

html, body {
  font-family: 'Almarai', sans-serif;
  min-height: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(180deg, #f7f9fc 0%, var(--bg) 100%);
  color: #0b1220;
}

[dir="rtl"] body, body[dir="rtl"], html[dir="rtl"] body {
  text-align: right;
}

[dir="ltr"] body, body[dir="ltr"], html[dir="ltr"] body {
  text-align: left;
}

.site {
  max-width: 980px;
  margin: 28px auto;
  padding: 20px;
}

.card {
  background: var(--card);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 24px 60px rgba(16, 24, 40, 0.08);
}

.header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

.logo {
  height: 62px;
}

.brand-title {
  font-weight: 900;
  font-size: 24px;
  color: var(--brand);
  font-family: 'Almarai', sans-serif;
}

.lead {
  margin-top: 6px;
  color: var(--muted);
  font-size: 15px;
  font-family: 'Almarai', sans-serif;
}

/* === Brand Hero (Logo above title) === */
.brand-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center !important;
  padding: 18px 16px 14px;
  margin: 0 0 22px;
  background: transparent;
  border: none;
}

.brand-hero * {
  text-align: center;
}

.brand-hero-bg { display: none; }

.brand-logo-frame {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: auto;
  aspect-ratio: 2046 / 430;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 6px auto 12px;
  z-index: 1;
  background: transparent;
  box-shadow: none;
}

.brand-logo-frame::before {
  content: '';
  position: absolute;
  inset: -20px -10% -20px -10%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(245, 166, 35, 0.14), transparent 65%);
  z-index: -1;
  pointer-events: none;
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 6px 14px rgba(37, 74, 133, 0.16));
}

@keyframes brandFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.brand-hero-text {
  position: relative;
  z-index: 1;
}

.brand-hero-location {
  display: block;
  margin: 0 0 12px;
  color: var(--brand);
  font-size: 16px;
  font-weight: 900;
  font-family: 'Almarai', sans-serif;
  letter-spacing: 0.2px;
}

.brand-hero-title {
  margin: 0;
  font-family: 'Almarai', sans-serif;
  font-size: 24px;
  font-weight: 900;
  color: var(--brand);
  letter-spacing: -0.3px;
  line-height: 1.25;
}

.accent-quote {
  color: var(--accent);
  font-weight: 900;
}

.brand-hero-tag {
  display: inline-block;
  margin: 10px 0 0;
  padding: 6px 14px;
  background: rgba(37, 74, 133, 0.08);
  color: var(--brand);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  font-family: 'Almarai', sans-serif;
}

@media (max-width: 560px) {
  .brand-hero {
    padding: 14px 12px 10px;
    margin: 0 0 18px;
  }
  .brand-logo-frame {
    max-width: 280px;
  }
  .brand-hero-title {
    font-size: 19px;
  }
  .brand-hero-tag {
    font-size: 12px;
  }
}

.page-header {
  background: linear-gradient(135deg, rgba(37, 74, 133, 0.12), rgba(37, 74, 133, 0.02));
  border: 1px solid rgba(37, 74, 133, 0.12);
  border-radius: 22px;
  padding: 28px 32px;
  margin-bottom: 24px;
}

.badge {
  display: inline-block;
  background: rgba(37, 74, 133, 0.12);
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
  padding: 8px 14px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.page-header h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.1;
  color: #14213d;
}

.page-header p {
  margin: 14px 0 0;
  max-width: 760px;
  line-height: 1.75;
  color: #4b5563;
}

.section-card {
  background: linear-gradient(180deg, #ffffff, #fdfdff);
  border: 1px solid #e8eef8;
  border-radius: 24px;
  padding: 28px;
  margin-bottom: 18px;
  box-shadow: 0 16px 40px rgba(16, 24, 40, 0.08);
}

.section-card.captcha-card {
  border-color: rgba(37, 74, 133, 0.18);
  background: linear-gradient(180deg, #f8fbff, #ffffff);
}

.section-head {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 16px;
  font-weight: 900;
  color: #0f172a;
  margin-bottom: 18px;
}

.section-head span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(37, 74, 133, 0.12);
  color: var(--brand);
  font-weight: 900;
}

.section-note {
  color: var(--muted);
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.captcha-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  background: #ffffff;
  border: 2px solid #d8dee8;
  border-radius: 14px;
  max-width: 480px;
}

.captcha-question {
  font-weight: 800;
  font-size: 18px;
  color: var(--brand);
  font-family: 'Almarai', sans-serif;
  margin: 0;
  flex: 1;
  min-width: 160px;
}

.captcha-input {
  width: 110px;
  text-align: center;
  font-size: 18px;
  font-weight: 800;
  padding: 10px 12px;
  border: 2px solid #b6c0d0;
  border-radius: 10px;
  font-family: 'Almarai', sans-serif;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.captcha-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(37, 74, 133, 0.18);
}

@media (max-width: 560px) {
  .captcha-row {
    max-width: 100%;
    padding: 14px 16px;
  }
  .captcha-input {
    width: 100%;
  }
}

label {
  display: block;
  font-weight: 700;
  color: #0e1a35;
  font-family: 'Almarai', sans-serif;
}

h1 {
  font-family: 'Almarai', sans-serif;
}

h2 {
  font-family: 'Almarai', sans-serif;
}

h3 {
  font-family: 'Almarai', sans-serif;
}

input,
select,
textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-top: 10px;
  background: #fff;
  color: #102a43;
  font-size: 14px;
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

textarea {
  min-height: 180px;
  resize: vertical;
}

.radio-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.radio-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 2px solid #e6e9ef;
  border-radius: 16px;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.22s ease, background 0.22s ease, box-shadow 0.22s ease;
  min-height: 64px;
  position: relative;
  background: #ffffff;
}

.radio-card:hover {
  transform: translateY(-1px);
  border-color: rgba(37, 74, 133, 0.35);
  background: #fafbff;
}

/* أخفي زر الراديو الأصلي وأبني واحدًا مخصصًا متجاوبًا */
.radio-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.radio-card span {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 800;
  color: #475569;
  font-family: 'Almarai', sans-serif;
  transition: color 0.2s ease;
}

.radio-card span::before {
  content: '';
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid #cbd5e1;
  transition: all 0.25s cubic-bezier(.2, .9, .3, 1.2);
  flex-shrink: 0;
  box-shadow: inset 0 0 0 0 var(--brand);
}

/* الحالة المختارة — البطاقة كلها */
.radio-card:has(input:checked) {
  border-color: var(--brand);
  background: linear-gradient(135deg, rgba(37, 74, 133, 0.09), rgba(245, 166, 35, 0.06));
  box-shadow: 0 8px 22px rgba(37, 74, 133, 0.12);
  transform: translateY(-1px);
}

.radio-card:has(input:checked) span {
  color: var(--brand);
}

/* الدائرة البيضاء — تتفاعل بالكامل */
.radio-card:has(input:checked) span::before {
  background: var(--brand);
  border-color: var(--brand);
  box-shadow:
    inset 0 0 0 4px #ffffff,
    0 0 0 4px rgba(37, 74, 133, 0.18);
  transform: scale(1.05);
}

.radio-card:focus-within {
  outline: 3px solid rgba(37, 74, 133, 0.25);
  outline-offset: 2px;
}

#requestTypeOtherBox,
#requestAreaOtherBox {
  margin-top: 18px;
}

@media (max-width: 840px) {
  .form-grid,
  .radio-group {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .page-header {
    padding: 20px 20px;
  }

  .section-card {
    padding: 20px;
  }
}

.full {
  grid-column: 1 / -1;
}

.controls {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}

.btn {
  border: none;
  padding: 12px 20px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 800;
  font-size: 14px;
}

.btn.primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 14px 30px rgba(37, 74, 133, 0.18);
}

.btn.ghost {
  background: transparent;
  border: 1px solid #d7dde8;
  color: var(--brand);
}

.status {
  margin-bottom: 18px;
  padding: 14px 16px;
  background: #f8fafc;
  border: 1px solid #e6edf7;
  border-radius: 14px;
  color: #334155;
}

.status.visible {
  display: block;
}

/* بانر النجاح/الخطأ — كبير وواضح بعد الإرسال */
.status-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 26px;
  border-radius: 18px;
  margin: 0 0 22px;
  font-family: 'Almarai', sans-serif;
  box-shadow: 0 18px 40px rgba(16, 24, 40, 0.10);
  animation: statusPop 0.5s cubic-bezier(.2, .9, .3, 1.2);
  position: relative;
  overflow: hidden;
}

@keyframes statusPop {
  from { opacity: 0; transform: translateY(-14px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.status-banner.success {
  background: linear-gradient(135deg, #10b981, #047857);
  color: #ffffff;
  border: 2px solid #065f46;
}

.status-banner.error {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  border: 2px solid #92400e;
}

.status-banner::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top left, rgba(255,255,255,0.22), transparent 60%);
  pointer-events: none;
}

.status-icon-large {
  font-size: 42px;
  line-height: 1;
  flex-shrink: 0;
  z-index: 1;
}

.status-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 1;
}

.status-title {
  font-size: 19px;
  font-weight: 900;
}

.status-text span {
  font-size: 14.5px;
  opacity: 0.96;
  line-height: 1.6;
}

@media (max-width: 560px) {
  .status-banner { padding: 18px; gap: 12px; }
  .status-icon-large { font-size: 34px; }
  .status-title { font-size: 17px; }
}

.honeypot {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.char {
  font-size: 13px;
  color: var(--muted);
}

@media (max-width: 760px) {
  .form-grid,
  .radio-group {
    grid-template-columns: 1fr;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* === Modern Dashboard Design === */
.dashboard-body {
  background: linear-gradient(180deg, #eef2f8 0%, #f5f7fb 100%);
  min-height: 100vh;
}

.top-bar {
  background: linear-gradient(120deg, #1e3a5f 0%, #254a85 100%);
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12);
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-bar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  backdrop-filter: blur(8px);
}

.brand-logo-topbar {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18), 0 0 0 2px rgba(245, 166, 35, 0.55);
  flex-shrink: 0;
}

.brand-logo-topbar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-title-sm {
  font-family: 'Almarai', sans-serif;
  font-weight: 900;
  font-size: 18px;
  line-height: 1.2;
}

.brand-sub {
  font-size: 12px;
  opacity: 0.78;
  margin-top: 2px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 6px;
  background: rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  font-family: 'Almarai', sans-serif;
  font-weight: 700;
  font-size: 13px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #1e293b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 14px;
  text-transform: uppercase;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 10px;
}

.btn.outline {
  background: transparent;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.45);
}

.btn.outline:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn.ghost.btn-sm {
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn.email {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.25);
}

.btn.email:hover { background: #1d4ed8; }

.btn.whatsapp {
  background: #25d366;
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(37, 211, 102, 0.25);
}

.btn.whatsapp:hover { background: #1faa54; }

.btn .btn-icon {
  margin-left: 6px;
  font-size: 16px;
}

.btn.btn-block {
  width: 100%;
  display: inline-flex;
  justify-content: center;
}

.dashboard {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.dashboard-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.dashboard-hero h1 {
  margin: 0;
  font-family: 'Almarai', sans-serif;
  font-size: 26px;
  color: #0f172a;
  font-weight: 900;
}

.hero-sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 22px;
  border-radius: 22px;
  color: #ffffff;
  overflow: hidden;
  box-shadow: 0 14px 38px rgba(16, 24, 40, 0.12);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.stat-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top left, rgba(255,255,255,0.18), transparent 60%);
  pointer-events: none;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 22px 50px rgba(16, 24, 40, 0.18);
}

.stat-card.grad-blue { background: linear-gradient(135deg, #2563eb, #1e3a8a); }
.stat-card.grad-amber { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-card.grad-green { background: linear-gradient(135deg, #10b981, #047857); }
.stat-card.grad-gray { background: linear-gradient(135deg, #64748b, #334155); }

.stat-icon-wrap {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  z-index: 1;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
}

.stat-icon-wrap svg {
  width: 28px;
  height: 28px;
  color: #ffffff;
  stroke: #ffffff;
}

.stat-content {
  display: flex;
  flex-direction: column;
  z-index: 1;
}

.stat-label {
  font-family: 'Almarai', sans-serif;
  font-size: 13px;
  font-weight: 700;
  opacity: 0.92;
}

.stat-number {
  font-size: 34px;
  font-weight: 900;
  line-height: 1.1;
  margin-top: 2px;
  font-family: 'Almarai', sans-serif;
}

.panel {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.05);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.panel-count {
  font-weight: 800;
  color: var(--muted);
  font-size: 13px;
  background: #f1f5f9;
  padding: 6px 12px;
  border-radius: 999px;
}

.tabs {
  display: inline-flex;
  background: #f1f5f9;
  padding: 6px;
  border-radius: 14px;
  gap: 4px;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  padding: 9px 18px;
  border-radius: 10px;
  text-decoration: none;
  color: #475569;
  font-weight: 800;
  font-size: 13px;
  font-family: 'Almarai', sans-serif;
  transition: background 0.2s ease, color 0.2s ease;
}

.tab-btn:hover { color: var(--brand); }

.tab-btn.active {
  background: #ffffff;
  color: var(--brand);
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
}

.table-wrap {
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid var(--border);
}

.messages-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  min-width: 900px;
}

.messages-table thead th {
  background: #f8fafc;
  color: #0f172a;
  font-weight: 800;
  font-family: 'Almarai', sans-serif;
  padding: 14px 12px;
  text-align: start;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  font-size: 13px;
  position: sticky;
  top: 0;
}

.messages-table tbody td {
  padding: 14px 12px;
  border-bottom: 1px solid #eef2f7;
  vertical-align: middle;
  color: #1f2937;
}

.messages-table tbody tr {
  transition: background 0.15s ease;
  cursor: pointer;
}

.messages-table tbody tr:hover { background: #f8fbff; }

.messages-table tbody tr.unread { background: #fffbeb; }
.messages-table tbody tr.unread:hover { background: #fef3c7; }
.messages-table tbody tr.unread .cell-name { font-weight: 900; color: #0f172a; }

.messages-table tbody tr.deleted-row { background: #fafafa; }
.messages-table tbody tr.deleted-row:hover { background: #f3f4f6; }

.col-num {
  width: 50px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.col-actions {
  width: 200px;
  text-align: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  font-family: 'Almarai', sans-serif;
  white-space: nowrap;
}

.pill-read {
  background: #dcfce7;
  color: #166534;
}

.pill-unread {
  background: #fef3c7;
  color: #92400e;
}

.sender-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #f1f5f9;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #334155;
}

.sender-emoji { font-size: 14px; }

.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  font-family: 'Almarai', sans-serif;
}

.tag-type {
  background: rgba(37, 74, 133, 0.1);
  color: var(--brand);
}

.tag-area {
  background: rgba(245, 166, 35, 0.14);
  color: #92400e;
}

.cell-name { font-weight: 700; }

.cell-preview {
  max-width: 280px;
  color: #475569;
  font-size: 13px;
}

.cell-date {
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
  direction: ltr;
  text-align: end;
}

.row-actions {
  display: inline-flex;
  gap: 6px;
  justify-content: center;
}

.action-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  padding: 0;
}

.action-btn svg {
  width: 17px;
  height: 17px;
}

.action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(16, 24, 40, 0.08);
}

.action-btn.view { color: #0369a1; }
.action-btn.view:hover { background: #e0f2fe; border-color: #bae6fd; }

.action-btn.email { color: #1d4ed8; }
.action-btn.email:hover { background: #dbeafe; border-color: #bfdbfe; }

.action-btn.whatsapp { color: #15803d; }
.action-btn.whatsapp:hover { background: #dcfce7; border-color: #bbf7d0; }

.action-btn.delete { color: #b91c1c; }
.action-btn.delete:hover { background: #fee2e2; border-color: #fecaca; }

.action-btn.restore { color: #047857; }
.action-btn.restore:hover { background: #d1fae5; border-color: #a7f3d0; }

.action-btn.delete-perm {
  color: #ffffff;
  background: #b91c1c;
  border-color: #991b1b;
}
.action-btn.delete-perm:hover {
  background: #991b1b;
  border-color: #7f1d1d;
  box-shadow: 0 6px 18px rgba(185, 28, 28, 0.35);
}

.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--muted);
  border-radius: 16px;
  background: #f8fafc;
  border: 1px dashed var(--border);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state h3 {
  margin: 0 0 6px;
  color: #0f172a;
  font-family: 'Almarai', sans-serif;
}

/* === Modal (Letter Style) === */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.show { display: flex; }

.modal-content {
  background: #ffffff;
  border-radius: 22px;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.35);
  animation: modalIn 0.28s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-content.letter {
  border-top: 6px solid var(--accent);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 26px;
  background: linear-gradient(120deg, rgba(37, 74, 133, 0.06), transparent);
  border-bottom: 1px solid var(--border);
}

.letter-mark {
  display: flex;
  align-items: center;
  gap: 14px;
}

.letter-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--brand), #1e3a5f);
  color: #ffffff;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 19px;
  color: var(--brand);
  font-family: 'Almarai', sans-serif;
  font-weight: 900;
}

.letter-meta-line {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.close-btn {
  background: #f1f5f9;
  border: none;
  width: 36px;
  height: 36px;
  font-size: 22px;
  color: #475569;
  cursor: pointer;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s ease;
}

.close-btn:hover {
  background: #fee2e2;
  color: #b91c1c;
}

.modal-body {
  padding: 24px 26px;
  overflow-y: auto;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.detail-row {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.detail-row.full { grid-column: 1 / -1; }

.detail-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.detail-value {
  color: #0f172a;
  font-weight: 700;
  font-family: 'Almarai', sans-serif;
}

.letter-body {
  background: #fefce8;
  border: 1px dashed #facc15;
  border-radius: 14px;
  padding: 18px 20px;
}

.letter-body-label {
  font-size: 12px;
  font-weight: 800;
  color: #854d0e;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.letter-body-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.8;
  color: #1f2937;
  font-size: 15px;
  font-family: 'Almarai', sans-serif;
}

.modal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 18px 26px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #0f172a;
  color: #ffffff;
  padding: 12px 22px;
  border-radius: 12px;
  font-family: 'Almarai', sans-serif;
  font-weight: 700;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 2000;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-success { background: #047857; }
.toast-error { background: #b91c1c; }

/* === Auth (login + forgot password) === */
.auth-card {
  max-width: 480px;
  margin: 30px auto;
  padding: 36px 32px;
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-icon {
  width: 70px;
  height: 70px;
  margin: 0 auto 14px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--brand), #1e3a5f);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  box-shadow: 0 14px 30px rgba(37, 74, 133, 0.25);
}

.auth-header h1 {
  margin: 0 0 6px;
  font-size: 22px;
  color: var(--brand);
  font-family: 'Almarai', sans-serif;
  font-weight: 900;
}

.auth-sub {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label {
  font-weight: 800;
  color: #0f172a;
  font-size: 13px;
  font-family: 'Almarai', sans-serif;
}
.form-field input {
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  font-family: 'Almarai', sans-serif;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.form-field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(37, 74, 133, 0.14);
}

.form-field .hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.otp-input {
  text-align: center;
  letter-spacing: 8px;
  font-size: 22px !important;
  font-weight: 900;
  direction: ltr;
}

.auth-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  flex-wrap: wrap;
  gap: 8px;
}

.auth-link {
  font-size: 13px;
  font-weight: 800;
  color: var(--brand);
  text-decoration: none;
  padding: 6px 0;
}

.auth-link.muted { color: var(--muted); }
.auth-link:hover { text-decoration: underline; }

.alert {
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
  font-family: 'Almarai', sans-serif;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.alert-info {
  background: #e0f2fe;
  color: #075985;
  border: 1px solid #bae6fd;
}

.auth-done { text-align: center; padding: 14px 0; }
.auth-done-icon { font-size: 48px; margin-bottom: 8px; }
.auth-done p { margin: 0 0 18px; color: #0f172a; font-weight: 700; }

/* === Language Toggle === */
.lang-toggle-wrap {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 100;
}

[dir="ltr"] .lang-toggle-wrap {
  left: auto;
  right: 16px;
}

.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: #ffffff;
  color: var(--brand);
  border: 1.5px solid var(--brand);
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
  font-family: 'Almarai', 'Inter', sans-serif;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 6px 18px rgba(37, 74, 133, 0.12);
}

.lang-toggle:hover {
  background: var(--brand);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(37, 74, 133, 0.22);
}

.lang-globe {
  font-size: 16px;
  line-height: 1;
}

.lang-toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 800;
}

@media (max-width: 640px) {
  .lang-toggle-wrap {
    top: 10px;
    left: 10px;
  }
  [dir="ltr"] .lang-toggle-wrap {
    left: auto;
    right: 10px;
  }
  .lang-toggle {
    padding: 7px 12px;
    font-size: 12px;
  }
}

/* === Cross-browser fixes === */
* {
  -webkit-tap-highlight-color: rgba(37, 74, 133, 0.15);
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

input, select, textarea, button {
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

input[type="text"], input[type="tel"], input[type="email"], input[type="password"], textarea {
  -webkit-user-select: text;
  user-select: text;
  font-size: 16px; /* يمنع Safari من تكبير الصفحة عند التركيز */
}

select {
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(0% + 14px) calc(50%), calc(0% + 20px) calc(50%);
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-left: 32px;
}

.btn { -webkit-appearance: none; appearance: none; }

img { max-width: 100%; height: auto; }

.modal {
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.brand-logo, .stat-icon-wrap {
  -webkit-backdrop-filter: blur(6px);
}

@supports not (backdrop-filter: blur(4px)) {
  .modal { background: rgba(15, 23, 42, 0.85); }
}

textarea {
  resize: vertical;
  min-height: 120px;
  font-family: inherit;
}

/* === Tablet (iPad) — 768px to 1024px === */
@media (max-width: 1024px) {
  .dashboard { padding: 22px 18px 50px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .stat-card { padding: 18px; }
  .stat-number { font-size: 30px; }
  .messages-table { min-width: 760px; }
  .col-actions { width: 170px; }
}

/* === Large tablets / small desktops === */
@media (max-width: 900px) {
  .top-bar-inner { padding: 14px 18px; }
  .dashboard-hero h1 { font-size: 22px; }
  .auth-card { margin: 20px 14px; }
}

/* === Mobile — below 640px === */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .top-bar-inner { flex-direction: column; align-items: stretch; gap: 12px; padding: 12px 14px; }
  .top-actions { justify-content: space-between; flex-wrap: wrap; }
  .user-chip { font-size: 12px; }
  .user-name { display: none; } /* فقط الـ avatar على الموبايل */
  .user-chip { padding: 4px; }
  .dashboard { padding: 18px 12px 40px; }
  .dashboard-hero { flex-direction: column; align-items: stretch; gap: 12px; }
  .dashboard-hero .btn { align-self: flex-start; }
  .stats-grid { grid-template-columns: 1fr; gap: 12px; }
  .stat-card { padding: 18px; }
  .stat-number { font-size: 28px; }
  .stat-icon-wrap { width: 50px; height: 50px; font-size: 24px; }
  .panel { padding: 14px; border-radius: 16px; }
  .panel-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .tabs { width: 100%; }
  .tab-btn { flex: 1; justify-content: center; padding: 9px 10px; font-size: 12px; }
  /* === تحويل الجدول إلى بطاقات على الجوال === */
  .table-wrap {
    overflow-x: visible;
    border: none;
    border-radius: 0;
    background: transparent;
  }
  .messages-table { min-width: 0; font-size: 14px; }
  .messages-table thead { display: none; }
  .messages-table, .messages-table tbody, .messages-table tr { display: block; width: 100%; }
  .messages-table tr.message-row {
    background: #ffffff !important;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    margin-bottom: 14px;
    padding: 14px 16px;
    box-shadow: 0 4px 14px rgba(16, 24, 40, 0.04);
    position: relative;
  }
  .messages-table tr.message-row.unread {
    border-right: 4px solid #f59e0b;
    background: linear-gradient(90deg, rgba(254, 243, 199, 0.4), #ffffff 50%) !important;
  }
  .messages-table tr.message-row.read { border-right: 4px solid #10b981; }
  .messages-table tr.deleted-row { border-right: 4px solid #94a3b8; }
  .messages-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    border-bottom: 1px dashed #f1f5f9;
    text-align: start;
    font-size: 13px;
    gap: 12px;
  }
  .messages-table tbody td:last-child { border-bottom: none; }
  .messages-table tbody td::before {
    content: attr(data-label);
    font-weight: 800;
    color: #64748b;
    font-size: 12px;
    font-family: 'Almarai', sans-serif;
    flex-shrink: 0;
  }
  .messages-table tbody td.col-num {
    background: #f1f5f9;
    border-radius: 8px;
    padding: 6px 12px;
    margin-bottom: 4px;
    font-weight: 900;
    color: var(--brand);
    font-size: 13px;
  }
  .messages-table tbody td.col-num::before { color: var(--brand); }
  .messages-table tbody td.cell-preview {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    line-height: 1.6;
    text-align: start;
  }
  .messages-table tbody td.cell-preview::before {
    align-self: flex-start;
  }
  .messages-table tbody td.col-actions {
    padding-top: 10px;
    border-bottom: none;
  }
  .messages-table tbody td.col-actions::before { display: none; }
  .row-actions { width: 100%; justify-content: space-between; gap: 8px; }
  .action-btn { width: 40px; height: 40px; flex: 1; max-width: 56px; }
  .action-btn svg { width: 16px; height: 16px; }
  .modal { padding: 12px; align-items: flex-end; }
  .modal-content { max-height: 92vh; border-radius: 18px 18px 0 0; max-width: 100%; }
  .modal-content.letter { border-top: none; border-top: 6px solid var(--accent); }
  .modal-header { padding: 14px 16px; }
  .modal-header h2 { font-size: 16px; }
  .letter-icon { width: 40px; height: 40px; font-size: 18px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; flex-direction: column; gap: 8px; }
  .modal-footer .btn { width: 100%; justify-content: center; padding: 11px 14px; }
  .detail-grid { grid-template-columns: 1fr; gap: 8px; }
  .detail-row { padding: 10px 12px; }
  .letter-body { padding: 14px 16px; }
  .letter-body-text { font-size: 14px; line-height: 1.7; }
  .toast { bottom: 16px; left: 16px; right: 16px; transform: translateY(20px); width: auto; max-width: none; font-size: 13px; }
  .toast.show { transform: translateY(0); }
  .brand-hero { margin: -4px -4px 16px; }
  .brand-title-sm { font-size: 16px; }
  .brand-sub { font-size: 11px; }
}

/* === Very small phones (≤380px) === */
@media (max-width: 380px) {
  .top-actions .btn { padding: 6px 10px; font-size: 11px; }
  .brand-logo-topbar { width: 44px; height: 44px; }
  .stat-number { font-size: 24px; }
  .stat-label { font-size: 12px; }
  .form-grid { grid-template-columns: 1fr; }
}

/* === Print === */
@media print {
  .top-bar, .row-actions, .col-actions, .panel-head, .pagination, .dashboard-hero .btn, .modal { display: none !important; }
  .dashboard-body { background: white; }
  .panel { box-shadow: none; border: 1px solid #ccc; }
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 22px;
  padding: 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  flex-wrap: wrap;
}

.pagination .page-btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 18px;
  background: var(--brand);
  color: #ffffff;
  border-radius: 10px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.1s ease;
  font-family: 'Almarai', sans-serif;
}

.pagination .page-btn:hover:not(.disabled) {
  background: #1e3a5f;
  transform: translateY(-1px);
}

.pagination .page-btn.disabled {
  background: #cbd5e1;
  color: #64748b;
  pointer-events: none;
  cursor: not-allowed;
}

.pagination .page-info {
  font-weight: 700;
  color: #0f172a;
  font-family: 'Almarai', sans-serif;
  font-size: 14px;
}

@media (max-width: 560px) {
  .pagination {
    gap: 10px;
    padding: 12px;
  }
  .pagination .page-btn {
    padding: 8px 14px;
    font-size: 13px;
  }
  .pagination .page-info {
    width: 100%;
    text-align: center;
    order: -1;
  }
}
