/* ==========================================================================
   MediCare AI Pro — Design System (PHP theme port of src/styles.css)
   Palette: Teal · Gold · Ivory
   ========================================================================== */

:root {
  --brand-teal-50:  #eff8f7;
  --brand-teal-100: #d7ecea;
  --brand-teal-200: #a9d8d3;
  --brand-teal-400: #4fb3a9;
  --brand-teal-500: #128a80;
  --brand-teal-600: #0e6f66;
  --brand-teal-700: #0a5850;
  --brand-teal-900: #073b36;

  --brand-gold-300: #e4c67a;
  --brand-gold-500: #c69a43;
  --brand-gold-600: #a67d2f;

  --ivory-50:  #fbfaf5;
  --ivory-100: #f5f1e6;
  --ivory-200: #ece5d0;

  --ink-900: #0b1f1d;
  --ink-700: #1f3a37;
  --ink-500: #46615d;
  --ink-400: #6b8683;
  --ink-200: #cad6d4;

  --danger:   #b3261e;
  --success:  #1f7a4d;
  --warning:  #a76c00;

  --bg:        var(--ivory-50);
  --surface:   #ffffff;
  --surface-2: var(--ivory-100);
  --border:    rgba(11, 31, 29, 0.08);
  --text:      var(--ink-900);
  --muted:     var(--ink-500);
  --primary:   var(--brand-teal-600);
  --primary-contrast: #ffffff;
  --accent:    var(--brand-gold-500);

  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(11, 31, 29, .06), 0 1px 3px rgba(11, 31, 29, .04);
  --shadow:    0 8px 24px rgba(11, 31, 29, .08);
  --shadow-lg: 0 24px 60px rgba(11, 31, 29, .16);

  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Fraunces", "Times New Roman", Georgia, serif;
  --font-arabic: "Tajawal", "Cairo", "Segoe UI", Tahoma, sans-serif;

  --container: 1200px;
}

:root[data-theme="dark"] {
  --bg:        #06110f;
  --surface:   #0a1a17;
  --surface-2: #0f2622;
  --border:    rgba(255, 255, 255, .08);
  --text:      #eef4f2;
  --muted:     #9db0ac;
  --primary:   var(--brand-teal-400);
  --primary-contrast: #06110f;
  --accent:    var(--brand-gold-300);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
  --shadow:    0 12px 32px rgba(0,0,0,.5);
  --shadow-lg: 0 30px 80px rgba(0,0,0,.6);
}

html[lang^="ar"] body,
body.rtl { font-family: var(--font-arabic); }

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--brand-gold-300); outline-offset: 3px; border-radius: 4px; }

h1, h2, h3, h4 { font-family: var(--font-display); color: var(--text); margin: 0 0 .5em; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 4vw + .5rem, 3.4rem); }
h2 { font-size: clamp(1.6rem, 2.5vw + .5rem, 2.4rem); }
h3 { font-size: 1.4rem; }
p  { margin: 0 0 1rem; color: var(--text); }
small, .muted { color: var(--muted); }

.container { max-width: var(--container); margin: 0 auto; padding: 0 1.25rem; }
.section   { padding: clamp(3rem, 6vw, 5.5rem) 0; }
.section-tight { padding: clamp(2rem, 4vw, 3.5rem) 0; }
.eyebrow {
  display: inline-flex; align-items: center; gap: .5rem;
  font-size: .78rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--brand-teal-600); font-weight: 600;
}
:root[data-theme="dark"] .eyebrow { color: var(--brand-teal-400); }

/* --- Buttons --- */
.btn {
  --btn-bg: var(--primary);
  --btn-fg: var(--primary-contrast);
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .8rem 1.25rem; border-radius: 999px; border: 1px solid transparent;
  background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 600; font-size: .95rem; cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
  box-shadow: var(--shadow-sm);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); text-decoration: none; }
.btn-outline { --btn-bg: transparent; --btn-fg: var(--text); border-color: var(--border); }
.btn-ghost   { --btn-bg: transparent; --btn-fg: var(--text); box-shadow: none; }
.btn-gold    { --btn-bg: var(--accent); --btn-fg: #1b1300; }
.btn-lg      { padding: 1rem 1.6rem; font-size: 1rem; }

/* --- Cards --- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.5rem; box-shadow: var(--shadow-sm); transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card-icon {
  width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center;
  background: color-mix(in oklab, var(--primary) 12%, transparent); color: var(--primary);
  margin-bottom: 1rem;
}

/* --- Grid --- */
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* --- Header / Nav --- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in oklab, var(--surface) 85%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 0;
}
.nav-brand { display: inline-flex; align-items: center; gap: .6rem; font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--text); }
.nav-brand:hover { text-decoration: none; }
.brand-dot { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--brand-teal-500), var(--brand-gold-500)); }
.nav-menu { display: none; gap: 1.75rem; align-items: center; list-style: none; margin: 0; padding: 0; }
.nav-menu a { color: var(--text); font-weight: 500; font-size: .95rem; }
.nav-menu > li { position: relative; }
.nav-cta { display: none; gap: .6rem; align-items: center; }
.nav-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer;
}
@media (min-width: 960px) {
  .nav-menu { display: flex; }
  .nav-cta { display: inline-flex; }
  .nav-toggle { display: none; }
}

/* Mega menu */
.mega {
  position: absolute; top: calc(100% + 8px); inset-inline-start: -1rem;
  width: min(680px, 80vw); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.25rem; box-shadow: var(--shadow-lg);
  display: none; grid-template-columns: 1fr 1fr; gap: 1rem;
}
.nav-menu li:hover > .mega,
.nav-menu li:focus-within > .mega { display: grid; }
.mega a { display: block; padding: .55rem .6rem; border-radius: 10px; color: var(--text); }
.mega a:hover { background: var(--surface-2); text-decoration: none; }
.mega h4 { font-family: var(--font-sans); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

/* Mobile drawer */
.mobile-drawer {
  position: fixed; inset: 0; z-index: 100; background: color-mix(in oklab, var(--bg) 96%, transparent);
  padding: 1.25rem; display: none; flex-direction: column; gap: 1rem; overflow-y: auto;
}
.mobile-drawer.open { display: flex; }
.mobile-drawer a { display: block; padding: .75rem 0; border-bottom: 1px solid var(--border); color: var(--text); font-weight: 600; }

/* --- Hero --- */
.hero {
  padding: clamp(3rem, 7vw, 6rem) 0 clamp(2.5rem, 5vw, 4rem);
  background:
    radial-gradient(60% 60% at 20% 10%, color-mix(in oklab, var(--brand-teal-400) 22%, transparent), transparent 60%),
    radial-gradient(50% 50% at 90% 30%, color-mix(in oklab, var(--brand-gold-300) 22%, transparent), transparent 60%),
    var(--bg);
}
.hero-grid { display: grid; grid-template-columns: 1fr; gap: 2rem; align-items: center; }
@media (min-width: 960px) { .hero-grid { grid-template-columns: 1.15fr .95fr; gap: 3rem; } }
.hero h1 span { background: linear-gradient(90deg, var(--brand-teal-600), var(--brand-gold-500)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-media {
  border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--brand-teal-100), var(--ivory-100));
  aspect-ratio: 4/3; box-shadow: var(--shadow-lg);
}

/* --- Stats --- */
.stat { text-align: center; }
.stat b { display: block; font-family: var(--font-display); font-size: 2.4rem; color: var(--primary); }

/* --- Footer --- */
.site-footer { background: var(--surface-2); border-top: 1px solid var(--border); padding: 3rem 0 1.25rem; margin-top: 4rem; }
.footer-grid { display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.footer-grid h4 { font-family: var(--font-sans); font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.footer-grid a { display: block; padding: .3rem 0; color: var(--text); }
.footer-bottom { border-top: 1px solid var(--border); margin-top: 2rem; padding-top: 1rem; display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; color: var(--muted); font-size: .875rem; }

/* --- Utilities --- */
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--text); }
.badge-primary { background: color-mix(in oklab, var(--primary) 16%, transparent); color: var(--primary); }
.badge-gold    { background: color-mix(in oklab, var(--accent) 20%, transparent); color: var(--brand-gold-600); }
.divider { height: 1px; background: var(--border); margin: 1.5rem 0; border: none; }
.text-center { text-align: center; }
.hide-mobile { display: none; }
@media (min-width: 720px) { .hide-mobile { display: initial; } }

/* --- Floating WhatsApp --- */
.wa-fab {
  position: fixed; inset-inline-end: 1.25rem; bottom: 1.25rem; z-index: 60;
  width: 56px; height: 56px; border-radius: 50%;
  background: #25D366; color: white; display: grid; place-items: center;
  box-shadow: var(--shadow-lg); border: none; cursor: pointer;
}
.wa-fab:hover { text-decoration: none; }

/* --- Emergency banner --- */
.emergency {
  background: linear-gradient(135deg, #7a1414, #b3261e); color: white; padding: 1.25rem;
  border-radius: var(--radius-lg); display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.emergency a { color: white; text-decoration: underline; font-weight: 700; }

/* --- Forms --- */
input, select, textarea {
  width: 100%; padding: .8rem 1rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit;
}
label { display: block; margin: .75rem 0 .4rem; font-weight: 600; font-size: .9rem; }

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --- Chat surface (AI Assistant) --- */
.chat-shell { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; height: 70vh; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
.chat-log { flex: 1; padding: 1rem; overflow-y: auto; display: flex; flex-direction: column; gap: .75rem; }
.chat-msg { max-width: 80%; padding: .75rem 1rem; border-radius: 18px; line-height: 1.5; }
.chat-msg.user { align-self: flex-end; background: var(--primary); color: var(--primary-contrast); border-bottom-right-radius: 6px; }
.chat-msg.bot  { align-self: flex-start; background: var(--surface-2); color: var(--text); border-bottom-left-radius: 6px; }
.chat-form { display: flex; gap: .5rem; padding: .75rem; border-top: 1px solid var(--border); background: var(--surface); }
.chat-form input { flex: 1; }

/* --- Skip link --- */
.skip-link { position: absolute; left: -9999px; top: 0; padding: .75rem 1rem; background: var(--primary); color: var(--primary-contrast); border-radius: 0 0 12px 0; z-index: 200; }
.skip-link:focus { left: 0; }
/* --- Theme toggle icons (sun/moon) --- */
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 40px; font-size: 1.15rem; line-height: 1; background: transparent; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; color: var(--text); }
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle .theme-icon-sun  { display: none; }
.theme-toggle .theme-icon-moon { display: inline; }
[data-theme="dark"] .theme-toggle .theme-icon-sun  { display: inline; color: var(--gold, #d4af37); }
[data-theme="dark"] .theme-toggle .theme-icon-moon { display: none; }
.badge.lang-switch { display: inline-flex; align-items: center; height: 40px; padding: 0 .85rem; border-radius: 999px; font-weight: 600; text-decoration: none; }

/* KiviCare shortcode wrappers respect the theme surface */
.kivicare-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; box-shadow: var(--shadow); }

/* --- User menu (header) --- */
.user-menu { position: relative; display: inline-flex; }
.user-chip { display: inline-flex; align-items: center; gap: .5rem; height: 40px; padding: 0 .75rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 600; }
.user-chip:hover { background: var(--surface-2); }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; display: inline-block; }
.user-avatar-fallback { display: inline-flex; align-items: center; justify-content: center; background: var(--primary); color: var(--primary-contrast); font-weight: 700; font-size: .85rem; }
.user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.user-caret { font-size: .75rem; opacity: .7; }
.user-dropdown { position: absolute; top: calc(100% + .4rem); right: 0; min-width: 180px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: .35rem; z-index: 60; display: flex; flex-direction: column; }
[dir="rtl"] .user-dropdown { right: auto; left: 0; }
.user-dropdown a { padding: .55rem .75rem; border-radius: 8px; color: var(--text); text-decoration: none; font-size: .9rem; }
.user-dropdown a:hover { background: var(--surface-2); }

/* --- Floating AI chatbot --- */
.mc-chatbot { position: fixed; right: 20px; bottom: 20px; z-index: 90; }
[dir="rtl"] .mc-chatbot { right: auto; left: 20px; }
.mc-chatbot-fab { width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--primary); color: var(--primary-contrast); box-shadow: 0 12px 32px rgba(0,0,0,.25); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: transform .18s ease; }
.mc-chatbot-fab:hover { transform: translateY(-2px) scale(1.03); }
.mc-chatbot-panel { position: absolute; bottom: 76px; right: 0; width: min(380px, calc(100vw - 32px)); max-height: 70vh; display: flex; flex-direction: column; padding: 0; overflow: hidden; animation: mc-chat-in .18s ease-out; }
[dir="rtl"] .mc-chatbot-panel { right: auto; left: 0; }
@keyframes mc-chat-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.mc-chatbot-header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .85rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.mc-chatbot-header strong { display: block; }
.mc-chatbot-status { display: block; font-size: .75rem; }
.mc-chatbot-close { background: transparent; border: 0; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--text); padding: .25rem .5rem; border-radius: 8px; }
.mc-chatbot-close:hover { background: var(--surface); }
.mc-chatbot-panel .ai-messages { flex: 1; padding: 1rem; overflow-y: auto; display: flex; flex-direction: column; gap: .5rem; min-height: 260px; }
.mc-chatbot-panel .ai-msg { max-width: 85%; padding: .6rem .85rem; border-radius: 14px; line-height: 1.45; font-size: .9rem; }
.mc-chatbot-panel .ai-msg-user { align-self: flex-end; background: var(--primary); color: var(--primary-contrast); border-bottom-right-radius: 4px; }
.mc-chatbot-panel .ai-msg-bot  { align-self: flex-start; background: var(--surface-2); color: var(--text); border-bottom-left-radius: 4px; }
.mc-chatbot-suggestions { display: flex; gap: .4rem; padding: 0 .75rem .5rem; flex-wrap: wrap; }
.ai-chip { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: .35rem .7rem; font-size: .78rem; cursor: pointer; }
.ai-chip:hover { background: var(--surface-2); }
.mc-chatbot-panel .ai-input { display: flex; gap: .5rem; padding: .65rem .75rem; border-top: 1px solid var(--border); background: var(--surface); }
.mc-chatbot-panel .ai-input input { flex: 1; height: 40px; padding: 0 .75rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.mc-chatbot-panel .ai-input .btn { padding: 0 .9rem; height: 40px; }
@media (max-width: 480px) {
  .mc-chatbot-panel { position: fixed; right: 12px; left: 12px; bottom: 88px; width: auto; max-height: 75vh; }
  [dir="rtl"] .mc-chatbot-panel { right: 12px; left: 12px; }
}

/* Hidden attribute must win over display:flex on chatbot panel & user dropdown */
.mc-chatbot-panel[hidden],
.user-dropdown[hidden],
.mobile-drawer[hidden] { display: none !important; }

/* --- MediCare auth page (login / register) --- */
.mc-auth { min-height: 70vh; display: grid; place-items: center; padding: 3rem 1rem; background: var(--surface-2); }
.mc-auth-card { width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 2rem; }
.mc-auth-tabs { display: flex; gap: .25rem; padding: .25rem; background: var(--surface-2); border-radius: 999px; margin-bottom: 1.5rem; }
.mc-auth-tab { flex: 1; text-align: center; padding: .55rem .9rem; border-radius: 999px; text-decoration: none; color: var(--text); font-weight: 600; font-size: .9rem; }
.mc-auth-tab.is-active { background: var(--primary); color: var(--primary-contrast); box-shadow: var(--shadow); }
.mc-auth-card h1 { margin: 0 0 .35rem; font-size: 1.5rem; }
.mc-auth-card .muted { margin-bottom: 1.25rem; }
.mc-auth-field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .9rem; }
.mc-auth-field label { font-size: .85rem; font-weight: 600; }
.mc-auth-field input { height: 44px; padding: 0 .85rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: .95rem; }
.mc-auth-field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary) 20%, transparent); }
.mc-auth-row { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; margin: .25rem 0 1rem; }
.mc-auth-row a { color: var(--primary); text-decoration: none; }
.mc-auth .btn { width: 100%; justify-content: center; }
.mc-auth-alt { text-align: center; margin-top: 1rem; font-size: .9rem; color: var(--muted); }
.mc-auth-alt a { color: var(--primary); text-decoration: none; font-weight: 600; }
.mc-auth-notice { padding: .7rem .85rem; border-radius: 10px; background: color-mix(in oklab, var(--primary) 12%, transparent); color: var(--text); font-size: .88rem; margin-bottom: 1rem; }
.mc-auth-error { background: color-mix(in oklab, #dc2626 15%, transparent); color: #dc2626; }
