/* ============================================================
   Smart Dental Clinic Management System — Stylesheet
   Palette: Deep teal #176B72 | Turquoise #DDF3F1 | Gray #F5F7F8
   Text: #24343A | No icons anywhere (3-line menu is pure CSS)
   Mobile-first, logical properties for RTL/LTR, print styles
   ============================================================ */

:root {
  --teal: #176B72;
  --teal-dark: #0F4E54;
  --teal-light: #DDF3F1;
  --white: #FFFFFF;
  --gray: #F5F7F8;
  --text: #24343A;
  --text-soft: #5B6E74;
  --border: #DDE7E8;
  --danger: #B3423A;
  --danger-bg: #FBEDEB;
  --ok: #2E7D4F;
  --ok-bg: #EAF6EF;
  --warn: #9A6B0F;
  --warn-bg: #FCF4E2;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(36, 52, 58, .08);
}

* { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Cairo', 'Segoe UI', Tahoma, 'Helvetica Neue', Arial, sans-serif;
  background: var(--gray);
  color: var(--text);
  line-height: 1.65;
  overflow-x: hidden;
}
h1, h2, h3, h4 { line-height: 1.35; margin: 0 0 .6em; font-weight: 700; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .9em; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
[dir="rtl"] body { letter-spacing: 0; }

.container { width: 100%; max-width: 1140px; margin-inline: auto; padding-inline: 16px; }

/* ---------- Buttons (text-only, no icons) ---------- */
.btn {
  display: inline-block;
  background: var(--teal);
  color: var(--white);
  border: 1px solid var(--teal);
  border-radius: var(--radius);
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease;
  min-height: 44px;
  text-align: center;
}
.btn:hover { background: var(--teal-dark); text-decoration: none; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 3px solid #7FC8CC; outline-offset: 2px;
}
.btn-outline { background: var(--white); color: var(--teal); }
.btn-outline:hover { background: var(--teal-light); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #93332C; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-soft); }
.btn-ghost:hover { background: var(--gray); }
.btn-sm { padding: 6px 12px; min-height: 36px; font-size: .85rem; }
.btn-block { display: block; width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Public site header ---------- */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.site-header .bar {
  display: flex; align-items: center; justify-content: space-between;
  padding-block: 10px; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.1rem; color: var(--teal-dark); }
.brand:hover { text-decoration: none; }
.brand-badge {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--teal); color: var(--white);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.15rem; font-weight: 800; flex: 0 0 auto;
}
.head-tools { display: flex; align-items: center; gap: 8px; }

/* 3-line hamburger — the ONLY permitted graphic mark */
.menu-btn {
  display: none;
  flex-direction: column; justify-content: center; gap: 5px;
  width: 48px; height: 44px; padding: 10px;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer;
}
.menu-btn .line { display: block; height: 3px; width: 100%; background: var(--teal-dark); border-radius: 2px; }
.menu-btn:focus-visible { outline: 3px solid #7FC8CC; }
.menu-btn[aria-expanded="true"] .line:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.menu-btn[aria-expanded="true"] .line:nth-child(2) { opacity: 0; }
.menu-btn[aria-expanded="true"] .line:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

.main-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; }
.main-nav a {
  display: block; padding: 10px 14px; border-radius: 8px;
  color: var(--text); font-weight: 600; font-size: .95rem;
}
.main-nav a:hover, .main-nav a.active { background: var(--teal-light); color: var(--teal-dark); text-decoration: none; }

@media (max-width: 900px) {
  .menu-btn { display: flex; }
  .main-nav {
    position: fixed; inset-inline: 0; top: 63px;
    background: var(--white); border-bottom: 1px solid var(--border);
    max-height: 0; overflow: hidden; transition: max-height .25s ease;
    box-shadow: var(--shadow); z-index: 49;
  }
  .main-nav.open { max-height: 480px; }
  .main-nav ul { flex-direction: column; padding: 10px 16px; gap: 2px; }
  .main-nav a { padding: 13px 14px; }
}

/* ---------- Hero / public sections ---------- */
.hero {
  background: linear-gradient(180deg, var(--teal-light), var(--gray));
  padding-block: 44px;
}
.hero h1 { font-size: clamp(1.4rem, 4vw, 2.2rem); color: var(--teal-dark); }
.hero p { font-size: 1.02rem; color: var(--text-soft); max-width: 640px; }
.section { padding-block: 34px; }
.section-title { text-align: center; margin-bottom: 22px; }
.section-title h2 { color: var(--teal-dark); }
.section-title p { color: var(--text-soft); }

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

.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px;
}
.card h3 { color: var(--teal-dark); }
.feature { border-top: 4px solid var(--teal); }

.doc-card { display: flex; flex-direction: column; gap: 8px; }
.doc-avatar {
  width: 84px; height: 84px; border-radius: 50%;
  background: var(--teal-light); color: var(--teal-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 800; overflow: hidden; flex: 0 0 auto;
}
.doc-avatar img { width: 100%; height: 100%; object-fit: cover; }
.svc-img { border-radius: 8px; background: var(--teal-light); overflow: hidden; max-height: 160px; display: flex; align-items: center; justify-content: center; color: var(--teal-dark); font-weight: 700; }
.svc-img img { width: 100%; height: 160px; object-fit: cover; }
.price-tag { font-weight: 800; color: var(--teal-dark); }
.price-note { font-size: .8rem; color: var(--text-soft); }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 700px) {
  .form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; }
}
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 5px; }
.field .hint { font-size: .78rem; color: var(--text-soft); }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=date], input[type=time],
input[type=number], input[type=url], input[type=datetime-local], select, textarea {
  width: 100%; padding: 10px 12px; min-height: 44px;
  border: 1px solid var(--border); border-radius: 8px;
  font: inherit; color: var(--text); background: var(--white);
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); }
input[disabled], select[disabled], textarea[disabled] { background: var(--gray); color: var(--text-soft); }
.checkbox-row { display: flex; gap: 10px; align-items: flex-start; }
.checkbox-row input[type=checkbox] { width: 20px; height: 20px; margin-top: 3px; flex: 0 0 auto; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 0 0 16px; }
legend { font-weight: 700; font-size: .95rem; color: var(--teal-dark); padding-inline: 6px; }

/* ---------- Alerts / flash ---------- */
.alert { border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; border: 1px solid transparent; font-size: .95rem; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: #CBE7D6; }
.alert-err { background: var(--danger-bg); color: var(--danger); border-color: #EFCFCC; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: #EBDDB7; }
.alert-info { background: var(--teal-light); color: var(--teal-dark); border-color: #C4E4E2; }

/* ---------- Dashboard layout ---------- */
.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex: 0 0 250px;
  background: var(--teal-dark); color: #D7ECEE;
  padding: 18px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { color: var(--white); padding-inline: 18px; margin-bottom: 14px; }
.sidebar .brand-badge { background: var(--teal-light); color: var(--teal-dark); }
.sidebar nav a {
  display: block; padding: 12px 18px; color: #CFE7E8; font-weight: 600; font-size: .95rem;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.sidebar nav a.active { background: var(--teal); color: var(--white); border-inline-start: 4px solid var(--teal-light); }
.sidebar .side-section { padding: 10px 18px 2px; font-size: .75rem; text-transform: uppercase; opacity: .7; }
.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  position: sticky; top: 0; z-index: 40;
}
.admin-topbar .who { font-size: .88rem; color: var(--text-soft); }
.admin-content { padding: 18px 16px; flex: 1; }
@media (max-width: 900px) {
  .sidebar {
    position: fixed; inset-inline-start: 0; top: 0; z-index: 60;
    transform: translateX(var(--side-close, -105%));
    transition: transform .25s ease; box-shadow: 0 0 20px rgba(0,0,0,.25);
  }
  [dir="rtl"] .sidebar { --side-close: 105%; }
  .sidebar.open { transform: translateX(0); }
  .side-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; }
  .side-backdrop.show { display: block; }
}
.side-toggle { display: none; }
@media (max-width: 900px) { .side-toggle { display: inline-flex; } }

/* Demo banner */
.demo-banner {
  background: var(--warn-bg); color: var(--warn);
  border-bottom: 1px solid #EBDDB7;
  padding: 8px 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: .9rem;
}
.demo-banner .note { font-weight: 400; font-size: .85rem; }

/* ---------- Stats & cards ---------- */
.stat-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 960px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.stat .num { font-size: 1.45rem; font-weight: 800; color: var(--teal-dark); }
.stat .lbl { font-size: .82rem; color: var(--text-soft); }
.stat.accent { border-top: 4px solid var(--teal); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 640px; }
th, td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--teal-light); color: var(--teal-dark); font-weight: 700; white-space: nowrap; }
tbody tr:hover { background: #FAFCFC; }
tbody tr:last-child td { border-bottom: 0; }
.num-cell { white-space: nowrap; }
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 700; white-space: nowrap;
}
.badge-pending { background: var(--warn-bg); color: var(--warn); }
.badge-confirmed { background: var(--teal-light); color: var(--teal-dark); }
.badge-completed, .badge-paid { background: var(--ok-bg); color: var(--ok); }
.badge-cancelled, .badge-no_show, .badge-cancelled2 { background: var(--danger-bg); color: var(--danger); }
.badge-draft { background: var(--gray); color: var(--text-soft); }
.badge-issued { background: var(--teal-light); color: var(--teal-dark); }
.badge-partially_paid { background: var(--warn-bg); color: var(--warn); }
.badge-recorded { background: var(--gray); color: var(--text-soft); }

/* ---------- Filters bar ---------- */
.filter-bar {
  display: grid; gap: 10px; grid-template-columns: 1fr;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; margin-bottom: 16px;
}
@media (min-width: 720px) { .filter-bar { grid-template-columns: repeat(4, 1fr); } .filter-bar .f-actions { grid-column: span 4; display: flex; gap: 8px; } }
.filter-bar .field label { font-size: .8rem; }

/* ---------- Pagination ---------- */
.pagination { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.pagination a { padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--white); }
.pagination a.active { background: var(--teal); color: var(--white); border-color: var(--teal); }
.pg-dots { padding: 7px 4px; color: var(--text-soft); }

/* ---------- Schedule ---------- */
.sched-table td, .sched-table th { text-align: center; }
.sched-slot { display: block; border-radius: 8px; padding: 8px 6px; font-size: .82rem; margin: 2px 0; }
.sched-slot.pending { background: var(--warn-bg); color: var(--warn); }
.sched-slot.confirmed { background: var(--teal-light); color: var(--teal-dark); }
.sched-slot.completed { background: var(--ok-bg); color: var(--ok); }
.sched-slot a { color: inherit; font-weight: 700; }

/* ---------- Auth & standalone pages ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 420px; background: var(--white); border: 1px solid var(--border); border-radius: 14px; padding: 26px; box-shadow: var(--shadow); }
.auth-card h1 { text-align: center; color: var(--teal-dark); }

/* ---------- Print ---------- */
.print-area { background: var(--white); }
.print-header { display: flex; justify-content: space-between; border-bottom: 2px solid var(--teal); padding-bottom: 10px; margin-bottom: 14px; }
.print-header .pn { font-weight: 800; font-size: 1.1rem; color: var(--teal-dark); }
@media print {
  body { background: var(--white); }
  .site-header, .sidebar, .admin-topbar, .no-print, .demo-banner, .btn-row, .filter-bar, .pagination, footer.site-footer { display: none !important; }
  .admin-shell { display: block; }
  .admin-content { padding: 0; }
  .card, .table-wrap { box-shadow: none; border: 1px solid #999; break-inside: avoid; }
  main { max-width: 100% !important; }
  a { color: #000; text-decoration: none; }
}

/* ---------- Footer ---------- */
footer.site-footer { background: var(--teal-dark); color: #D7ECEE; padding-block: 28px; margin-top: 30px; }
footer.site-footer a { color: #CDE9EA; }
footer.site-footer h4 { color: var(--white); }
footer.site-footer .cols { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 760px) { footer.site-footer .cols { grid-template-columns: 2fr 1fr 1fr; } }
.footer-note { border-top: 1px solid rgba(255,255,255,.15); margin-top: 18px; padding-top: 14px; font-size: .82rem; opacity: .8; }

/* ---------- Misc ---------- */
.muted { color: var(--text-soft); font-size: .88rem; }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }
.flex-between { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.page-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.page-title h1 { margin: 0; }
.item-row { display: grid; grid-template-columns: 3fr 1fr 1fr 1fr auto; gap: 8px; align-items: end; margin-bottom: 8px; }
@media (max-width: 700px) {
  .item-row { grid-template-columns: 1fr 1fr; }
  .item-row .f-name { grid-column: 1 / -1; }
}
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; }
@media (max-width: 560px) { .kv { grid-template-columns: 1fr; } .kv dt { font-weight: 700; margin-top: 6px; } }
.kv dt { color: var(--text-soft); font-size: .88rem; }
.kv dd { margin: 0; font-weight: 600; }
.conf-box { background: var(--danger-bg); border: 1px solid #EFCFCC; border-radius: 8px; padding: 12px; color: var(--danger); font-weight: 600; }
.chart-bars { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding: 10px 4px 0; }
.chart-bars .bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart-bars .bar { width: 70%; max-width: 46px; background: var(--teal); border-radius: 6px 6px 0 0; }
.chart-bars .bar.exp { background: #C77E78; }
.chart-bars .lbl { font-size: .75rem; color: var(--text-soft); white-space: nowrap; }
.legend { display: flex; gap: 16px; font-size: .8rem; color: var(--text-soft); margin-top: 8px; }
.legend .dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--teal); vertical-align: middle; margin-inline-end: 5px; }
.legend .dot.exp { background: #C77E78; }
.ltr-num { direction: ltr; unicode-bidi: isolate; display: inline-block; }

/* ===== Executive dashboard additions (v3) ===== */
.period-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.period-bar .p-lbl { font-weight: 700; color: var(--text-soft); font-size: .9rem; }
.period-bar .p-chip { padding: 7px 14px; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; font-weight: 700; font-size: .86rem; color: var(--text-soft); background: #fff; }
.period-bar .p-chip.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.period-bar .p-range { color: var(--text-soft); font-size: .85rem; margin-inline-start: auto; }
a.link-stat { text-decoration: none; display: block; }
a.link-stat:hover { border-color: var(--teal); box-shadow: 0 8px 20px rgba(14,154,167,.12); }
.stat.warm { border-inline-start-color: #d97706; }
.stat.money .num { font-size: 1.25rem; }
.alert-panel { border: 1px solid var(--border); border-radius: 10px; background: #fff; padding: 14px; display: grid; gap: 8px; }
.alert-panel h3 { margin: 0 0 4px; color: var(--teal-dark); }
.alert-item { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; padding: 10px 14px; border-radius: 8px; text-decoration: none; font-size: .92rem; border: 1px solid transparent; }
a.alert-item:hover { text-decoration: underline; }
.alert-item .a-title { font-weight: 800; }
.alert-item .a-body { color: var(--text-soft); }
.alert-item.level-crit { background: #fdf0ef; border-color: #f2c8c4; color: #93332c; }
.alert-item.level-warn { background: #fdf7e8; border-color: #f0dca6; color: #8a6116; }
.alert-item.level-info { background: #eef5fb; border-color: #c8ddef; color: #1f5b86; }
.alert-item.level-ok { background: #edf8f0; border-color: #bfe4c9; color: #22693a; }
.nav-count { font-weight: 800; color: var(--teal-dark); }
.sidebar .side-section { margin-top: 14px; }

/* ===== Print (invoices/reports) ===== */
@media print {
  .sidebar, .admin-topbar, .demo-banner, .no-print, .filter-bar, .page-title .btn, .btn-row { display: none !important; }
  .admin-shell { display: block; }
  .admin-content { padding: 0 !important; }
  body { background: #fff; }
  .card, .table-wrap, table { box-shadow: none !important; border-color: #ddd !important; }
  a { color: inherit; text-decoration: none; }
}
