/* ══════════════════════════════════════════
   iClinicOS — Common Styles (v2)
   Shared between dashboard & patient pages
   ══════════════════════════════════════════ */

/* ─── DESIGN TOKENS ─── */
:root {
  --bg: #050914;
  --bg-2: #0A1525;
  --sidebar: #08111F;
  --card: #0F1C30;
  --card2: #152840;
  --surface-3: #1B3352;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);

  /* Brand + status colors */
  --primary: #00D4B4;
  --primary2: rgba(0, 212, 180, 0.1);
  --primary-glow: rgba(0, 212, 180, 0.25);
  --green: #00D4B4;
  --green2: rgba(0, 212, 180, 0.1);
  --blue: #5B8DEF;
  --blue2: rgba(91, 141, 239, 0.1);
  --orange: #F59E0B;
  --orange2: rgba(245, 158, 11, 0.1);
  --red: #EF4444;
  --red2: rgba(239, 68, 68, 0.1);
  --purple: #8B5CF6;
  --purple2: rgba(139, 92, 246, 0.1);

  /* Typography */
  --white: #FFFFFF;
  --text: #E8EEF5;
  --text-dim: #94A3B8;
  --gray: #64748B;
  --gray2: #94A3B8;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.18);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.38);

  /* Easing */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-sharp: cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg: #F0F4F8;
  --bg-2: #FFFFFF;
  --sidebar: #0F1C30;
  --card: #FFFFFF;
  --card2: #F8FAFC;
  --surface-3: #EEF2F6;
  --border: #E0E8F0;
  --border-strong: #D0DAE6;
  --text: #0F172A;
  --text-dim: #475569;
  --gray: #64748B;
  --gray2: #64748B;
  --white: #0F172A;
}

/* ─── RESET ─── */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Cairo', -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  display: flex;
  transition: background 0.3s, color 0.3s;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle mesh gradient on dark body */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 800px 400px at 0% 0%, rgba(0, 212, 180, 0.04), transparent 60%),
    radial-gradient(ellipse 800px 400px at 100% 100%, rgba(91, 141, 239, 0.04), transparent 60%);
  pointer-events: none;
  z-index: 0;
}
[data-theme="light"] body::before { opacity: 0; }

/* ─── SIDEBAR ─── */
.sidebar {
  width: 232px;
  height: 100vh;
  background: var(--sidebar);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--gray); }
.sb-logo {
  padding: 22px 18px 18px;
  border-bottom: 1px solid var(--border);
}
.sb-logo h1 { font-size: 19px; font-weight: 900; color: #fff; letter-spacing: -0.3px; }
.sb-logo h1 span { color: var(--primary); }
.sb-clinic {
  font-size: 12.5px;
  color: var(--white);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
}
.online-dot {
  width: 7px; height: 7px;
  background: var(--primary);
  border-radius: 50%;
  animation: blink 2s infinite;
  box-shadow: 0 0 8px var(--primary);
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.sb-section, .sb-sec {
  padding: 14px 16px 6px;
  font-size: 9px;
  color: var(--gray);
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  margin: 2px 8px;
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  text-decoration: none;
  position: relative;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--white);
  transform: translateX(-2px);
}
[dir="ltr"] .nav-item:hover { transform: translateX(2px); }
.nav-item.active {
  background: var(--primary2);
  color: var(--primary);
}
.nav-item.active::after {
  content: '';
  position: absolute;
  right: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  background: var(--primary);
  border-radius: 2px 0 0 2px;
  box-shadow: -2px 0 8px var(--primary-glow);
}
[dir="ltr"] .nav-item.active::after {
  right: auto;
  left: 0;
  border-radius: 0 2px 2px 0;
  box-shadow: 2px 0 8px var(--primary-glow);
}
.nav-ic { font-size: 15px; width: 20px; text-align: center; }
.nav-badge {
  margin-right: auto;
  background: var(--primary);
  color: var(--bg);
  font-size: 9px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 100px;
}
[dir="ltr"] .nav-badge { margin-right: 0; margin-left: auto; }
.sb-bottom {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
}

/* ─── MAIN LAYOUT ─── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 1;
}
.content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--card2) transparent;
}
.content::-webkit-scrollbar { width: 6px; }
.content::-webkit-scrollbar-thumb { background: var(--card2); border-radius: 3px; }
.content::-webkit-scrollbar-thumb:hover { background: var(--surface-3); }

/* ─── CARDS ─── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 14px;
  transition: border-color 0.25s var(--ease-out), transform 0.25s var(--ease-out);
}
.card:last-child { margin-bottom: 0; }
.card:hover { border-color: var(--border-strong); }
.card-hd {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-ttl {
  font-size: 13px;
  font-weight: 800;
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.2px;
}
.card-ic {
  width: 26px; height: 26px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.card-act {
  font-size: 11px;
  color: var(--primary);
  cursor: pointer;
  font-weight: 700;
  background: none;
  border: none;
  font-family: inherit;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}
.card-act:hover { background: var(--primary2); }
.card-bd { padding: 16px 18px; }

/* ─── GRID LAYOUTS ─── */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.g31 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-bottom: 14px; }

/* ─── BADGES ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.2px;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; }
.bg-green { background: var(--green2); color: var(--green); } .bg-green::before { background: var(--green); }
.bg-blue { background: var(--blue2); color: var(--blue); } .bg-blue::before { background: var(--blue); }
.bg-orange { background: var(--orange2); color: var(--orange); } .bg-orange::before { background: var(--orange); }
.bg-red { background: var(--red2); color: var(--red); } .bg-red::before { background: var(--red); }
.bg-purple { background: var(--purple2); color: var(--purple); } .bg-purple::before { background: var(--purple); }

/* ─── ICON BACKGROUNDS ─── */
.si-green { background: var(--green2); color: var(--green); }
.si-blue { background: var(--blue2); color: var(--blue); }
.si-orange { background: var(--orange2); color: var(--orange); }
.si-purple { background: var(--purple2); color: var(--purple); }

/* ─── BUTTONS ─── */
.btn {
  padding: 8px 16px;
  border-radius: 9px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s var(--ease-out);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-green { background: var(--green2); color: var(--green); border: 1px solid rgba(0, 212, 180, 0.2); }
.btn-green:hover { background: var(--green); color: var(--bg); border-color: var(--green); }
.btn-red { background: var(--red2); color: var(--red); border: 1px solid rgba(239, 68, 68, 0.2); }
.btn-red:hover { background: var(--red); color: #fff; border-color: var(--red); }

/* ─── TABLE ─── */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: right;
  padding: 11px 14px;
  font-size: 9.5px;
  color: var(--gray);
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.015);
  border-bottom: 1px solid var(--border);
}
[dir="ltr"] th { text-align: left; }
td {
  padding: 12px 14px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
tr:last-child td { border-bottom: none; }
tr.clickable-row { cursor: pointer; transition: background 0.15s var(--ease-out); }
tr.clickable-row:hover td { background: rgba(0, 212, 180, 0.04); }

/* ─── FORMS ─── */
.fg { margin-bottom: 12px; }
.fg label {
  display: block;
  font-size: 10px;
  font-weight: 800;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.fg input, .fg select, .fg textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--card2);
  border: 1.5px solid var(--border-strong);
  border-radius: 9px;
  color: var(--white);
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
  transition: all 0.2s var(--ease-out);
}
.fg input:focus, .fg select:focus, .fg textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 212, 180, 0.1);
  background: var(--surface-3);
}
.fg input::placeholder, .fg textarea::placeholder { color: var(--gray); }
.fg-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
[data-theme="light"] .fg input,
[data-theme="light"] .fg select,
[data-theme="light"] .fg textarea {
  background: #fff;
  border-color: #E0E8F0;
  color: #0F172A;
}

/* ─── MODAL ─── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 9, 20, 0.75);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.modal.active { display: flex; }
.modal-box {
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 28px;
  width: 480px;
  max-width: 90vw;
  animation: mIn 0.35s var(--ease-out);
  box-shadow: var(--shadow-lg);
}
@keyframes mIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-ttl {
  font-size: 16px;
  font-weight: 900;
  color: var(--white);
  margin-bottom: 20px;
  letter-spacing: -0.3px;
}
.modal-acts { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.btn-cancel {
  background: var(--card2);
  color: var(--text-dim);
  border: 1px solid var(--border-strong);
  padding: 10px 20px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}
.btn-cancel:hover { background: var(--surface-3); color: var(--white); }
.btn-save {
  background: var(--primary);
  color: #041812;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  box-shadow: 0 4px 16px rgba(0, 212, 180, 0.2);
}
.btn-save:hover { background: #1EE0C0; transform: translateY(-1px); box-shadow: 0 8px 24px rgba(0, 212, 180, 0.35); }

/* ─── TOAST ─── */
.toast {
  position: fixed;
  top: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  background: var(--card);
  color: var(--white);
  padding: 14px 22px 14px 18px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  z-index: 9999;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
  max-width: 90vw;
  border: 1px solid var(--border);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255,255,255,0.04);
  opacity: 0;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast .toast-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 900;
  flex-shrink: 0;
}
.toast .toast-msg { line-height: 1.3; }
.toast.toast-success { border-color: var(--primary); box-shadow: 0 18px 50px rgba(0,0,0,0.45), 0 0 28px rgba(0, 212, 180, 0.35); }
.toast.toast-success .toast-icon { background: var(--primary); color: #041812; }
.toast.toast-error { border-color: #ef4444; box-shadow: 0 18px 50px rgba(0,0,0,0.45), 0 0 28px rgba(239, 68, 68, 0.35); }
.toast.toast-error .toast-icon { background: #ef4444; color: #fff; }

/* ─── PATIENT AVATAR ─── */
.pat-av {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

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

/* ─── EMPTY STATE ─── */
.empty {
  text-align: center;
  padding: 36px 24px;
  color: var(--gray);
  font-size: 13px;
  line-height: 1.7;
}

/* ─── LIGHT MODE OVERRIDES ─── */
[data-theme="light"] .sidebar { background: #0F1C30; }
[data-theme="light"] .sb-logo { border-bottom-color: rgba(255, 255, 255, 0.1); }
[data-theme="light"] .sb-bottom { border-top-color: rgba(255, 255, 255, 0.1); }
[data-theme="light"] .card-ttl { color: #0F172A; }
[data-theme="light"] .modal-box { background: #fff; }
[data-theme="light"] .modal-ttl { color: #0F172A; }
[data-theme="light"] .toast { background: #fff; color: #0F172A; }

/* ═══ MOBILE HAMBURGER ═══ */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 160;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: var(--primary);
  color: var(--bg);
  border: none;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: var(--shadow-md), 0 0 20px rgba(0, 212, 180, 0.3);
}
[dir="ltr"] .mobile-menu-btn { right: auto; left: 14px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 9, 20, 0.6);
  z-index: 140;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 768px) {
  html, body { overflow: auto; height: auto; }
  body { display: block; }

  .mobile-menu-btn { display: flex; align-items: center; justify-content: center; }
  .sidebar-overlay.show { display: block; }

  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 268px;
    z-index: 150;
    transform: translateX(100%);
    transition: transform 0.35s var(--ease-out);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.5);
  }
  [dir="ltr"] .sidebar { right: auto; left: 0; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }

  .main { width: 100%; overflow: visible; }
  .content { padding: 16px 14px; overflow: visible; }

  .g2, .g31 { grid-template-columns: 1fr !important; gap: 12px; }

  .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 500px; }
  th, td { padding: 10px 12px; font-size: 12px; }

  .fg-row { grid-template-columns: 1fr !important; }

  .modal-box { width: 95%; max-width: 95vw; padding: 22px; max-height: 90vh; overflow-y: auto; }

  .lang-switcher { bottom: 14px !important; right: 14px !important; padding: 3px !important; }
  [dir="ltr"] .lang-switcher { right: auto !important; left: 14px !important; }
  .lang-btn { padding: 6px 11px !important; font-size: 11px !important; }
}

@media (max-width: 480px) {
  .sidebar { width: 88%; }
  .content { padding: 12px 10px; }
  .card { border-radius: 14px; }
  .card-hd { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  .card-bd { padding: 12px 14px; }
  table { min-width: 420px; }
}
