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

/* ── Design tokens ──────────────────────────────────────────── */
:root {
  --blue-900: #0b2a6f;
  --blue-700: #1557c0;
  --blue-600: #1e88e5;
  --glass:    rgba(255,255,255,0.9);
  --shadow:   0 25px 50px -12px rgba(0,0,0,0.15);
  --radius:   40px;
  --success:  #10b981;
  --danger:   #e11d48;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  font-family: 'Tajawal', sans-serif;
}

/* Replace global outline:none — keyboard users need focus rings */
*:focus { outline: none; }
*:focus-visible {
  outline: 2px solid var(--blue-600);
  outline-offset: 2px;
}

/* ── Base layout ────────────────────────────────────────────── */
html, body { height: 100%; margin: 0; }

body {
  display: flex;
  flex-direction: column;
  background: #eef2f7;
  color: #1e293b;
  direction: rtl;
}

/* ── Splash screen ──────────────────────────────────────────── */
#loading-screen {
  position: fixed;
  inset: 0;
  /* Brand blue background so the logo is always visible */
  background: linear-gradient(135deg, var(--blue-900) 0%, var(--blue-700) 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  transition: opacity 0.8s ease;
}

.loading-logo {
  width: clamp(100px, 15vw, 150px);
  animation: floating 3s ease-in-out infinite;
}

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

/* ── Header / Hero ──────────────────────────────────────────── */
.hero-section {
  background: linear-gradient(25deg, var(--blue-900) 0%, var(--blue-600) 100%);
  min-height: 400px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-bottom-left-radius:  80px;
  border-bottom-right-radius: 80px;
  flex-shrink: 0;
  position: relative;
}

/* ── Navbar ─────────────────────────────────────────────────── */
.navbar {
  width: 100%;
  max-width: 1100px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(15px);
  padding: 12px 25px;
  border-radius: 30px;
  border: 1px solid rgba(255,255,255,0.2);
  margin-top: 15px;
  position: relative;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: white;
  font-weight: 900;
  font-size: 24px;
  text-decoration: none;
  flex-shrink: 0;
}

.nav-brand img { width: 80px; }

/* Desktop nav-links container */
.nav-links {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Hamburger button (hidden on desktop) ───────────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: white;
  border-radius: 2px;
  transition: transform 0.25s, opacity 0.25s;
}

/* Animated X when open */
.hamburger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.is-open span:nth-child(2) { opacity: 0; }
.hamburger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Main content stretch ───────────────────────────────────── */
.app {
  flex: 1 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* ── Main card ──────────────────────────────────────────────── */
.main-card {
  background: var(--glass);
  backdrop-filter: blur(20px);
  width: 95%;
  max-width: 900px;
  margin: -160px auto 60px;
  padding: 45px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.5);
  box-shadow: var(--shadow);
  animation: fadeInUp 0.7s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Form elements ──────────────────────────────────────────── */
label {
  display: block;
  font-weight: 700;
  color: var(--blue-900);
  margin: 15px 5px 8px;
}

input, textarea, select {
  width: 100%;
  padding: 14px 18px;
  border-radius: 15px;
  border: 1px solid #e2e8f0;
  font-size: 16px;
  background: #f8fafc;
  transition: border-color 0.25s, box-shadow 0.25s;
  /* Minimum 44px height for touch targets on mobile */
  min-height: 44px;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--blue-600);
  background: white;
  box-shadow: 0 0 0 4px rgba(30,136,229,0.1);
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn-primary {
  background: linear-gradient(135deg, var(--blue-600) 0%, var(--blue-700) 100%);
  color: white;
  border-radius: 18px;
  padding: 16px;
  font-weight: 800;
  font-size: 17px;
  border: none;
  cursor: pointer;
  width: 100%;
  margin-top: 20px;
  transition: transform 0.3s, box-shadow 0.3s;
  text-decoration: none;
  display: block;
  text-align: center;
  /* 48px min height — comfortable tap target on mobile */
  min-height: 48px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(30,136,229,0.3);
}

.btn-outline {
  background: white;
  color: var(--blue-900);
  border: 1px solid #e2e8f0;
  padding: 8px 18px;
  border-radius: 15px;
  text-decoration: none;
  font-weight: 700;
  transition: border-color 0.25s, color 0.25s;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

.btn-outline:hover {
  border-color: var(--blue-600);
  color: var(--blue-600);
}

.btn-pharmacist-link {
  background: rgba(255,255,255,0.15);
  color: white;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid rgba(255,255,255,0.3);
  transition: background 0.25s, color 0.25s;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

.btn-pharmacist-link:hover {
  background: white;
  color: var(--blue-900);
}

/* Specific nav button styles */
.nav-dashboard {
  font-size: 13px;
  border-radius: 12px;
  padding: 8px 16px;
  background: rgba(255,255,255,0.22);
  border: 1px solid rgba(255,255,255,0.45);
  font-weight: 800;
}

.nav-logout {
  background: #e11d48;
  border: none;
  padding: 8px 15px;
}

.nav-item {
  font-size: 13px;
  border-radius: 12px;
  padding: 8px 13px;
}

/* ── Tables ─────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

th {
  color: #64748b;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 15px;
  text-align: right;
}

tr td {
  background: white;
  padding: 16px 15px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 14px;
}

tr:last-child td { border-bottom: none; }

/* ── Footer ─────────────────────────────────────────────────── */
.footer {
  flex-shrink: 0;
  background: var(--blue-900);
  color: white;
  padding: 40px 20px;
  text-align: center;
  border-top-left-radius:  60px;
  border-top-right-radius: 60px;
}

.email-box {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.1);
  padding: 12px 25px;
  border-radius: 15px;
  color: white;
  text-decoration: none;
  margin-top: 15px;
  transition: background 0.25s;
}

.email-box:hover { background: rgba(255,255,255,0.2); }

/* ════════════════════════════════════════════════════════
   MOBILE  (≤ 768px) — patient-first responsive layout
   ════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Hero expands naturally — no fixed height fighting the open menu */
  .hero-section {
    min-height: 0;
    padding-bottom: 24px;
    border-bottom-left-radius:  50px;
    border-bottom-right-radius: 50px;
  }

  /* ── Navbar row management ───────────────────────────────────────
     HTML order: [nav-brand] [nav-links] [hamburger]
     We use CSS `order` to rearrange visually:
       Row 1: nav-brand (order 1) + hamburger (order 2)
       Row 2: nav-links (order 3, flex-basis 100% → forces new row)
     flex-wrap:wrap on the navbar makes Row 2 possible.
  ─────────────────────────────────────────────────────────────── */
  .navbar {
    padding: 10px 14px;
    margin-top: 10px;
    flex-wrap: wrap;
    align-items: center;
    border-radius: 20px;
  }

  .nav-brand {
    order: 1;
    flex: 1;           /* expands to fill Row 1, pushing hamburger right */
  }

  .nav-brand img { width: 60px; }

  /* ── Hamburger: same row as logo, at the opposite end ── */
  .hamburger {
    display: flex;
    order: 2;
    flex-shrink: 0;
    margin-right: auto; /* in RTL this pushes it to the left end of Row 1 */
  }

  /* ── Nav-links: always a full-width Row 2, collapsed by default ── */
  .nav-links {
    order: 3;
    flex-basis: 100%;      /* forces wrap to new row */
    width: 100%;
    /* Collapsed state */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    gap: 8px;
    padding: 0 2px;
    transition: max-height 0.32s ease, opacity 0.22s ease, padding 0.22s ease;
  }

  /* Expanded state */
  .nav-links.nav-open {
    max-height: 700px;
    opacity: 1;
    pointer-events: auto;
    padding: 10px 2px 2px;
  }

  /* Each link inside the dropdown: full-width, large tap target */
  .nav-links .btn-outline,
  .nav-links .btn-pharmacist-link {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 13px 16px;
    font-size: 15px;
    border-radius: 13px;
    min-height: 50px;
    box-sizing: border-box;
  }

  /* Outline buttons need to be readable on the dark navy background */
  .nav-links .btn-outline {
    background: rgba(255,255,255,0.13);
    color: white;
    border-color: rgba(255,255,255,0.28);
  }

  .nav-links .btn-outline:hover,
  .nav-links .btn-outline:active {
    background: rgba(255,255,255,0.22);
    color: white;
    border-color: rgba(255,255,255,0.55);
  }

  /* ── Card sits below the hero with a comfortable gap ── */
  .main-card {
    padding: 22px 16px;
    margin-top: 20px;
    border-radius: 28px;
    width: 93%;
  }

  /* ── Typography ── */
  h2 { font-size: 20px; }
  h3 { font-size: 16px; }

  /* ── Buttons — bigger tap targets ── */
  .btn-primary {
    font-size: 16px;
    padding: 16px;
    border-radius: 16px;
  }

  /* ── Form inputs — comfortable on mobile ── */
  input, textarea {
    font-size: 16px; /* prevents iOS auto-zoom on focus */
    padding: 13px 15px;
    border-radius: 12px;
  }

  /* ── Table: hide less-critical columns, allow x-scroll ── */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  th, tr td { padding: 12px 10px; font-size: 13px; }

  /* ── Home page buttons — vertical stack, full width ── */
  .btn-group {
    flex-direction: column;
    gap: 12px;
  }

  /* ── Footer ── */
  .footer {
    border-top-left-radius:  40px;
    border-top-right-radius: 40px;
    padding: 30px 16px;
  }
}

/* ══════════════════════════════════════════════
   Very small screens (≤ 400px)
══════════════════════════════════════════════ */
@media (max-width: 400px) {
  .main-card { padding: 18px 12px; margin-top: 16px; }
  .hero-section { padding-bottom: 22px; }
}
