@import url("https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700;800&display=swap");

:root,
:root[data-theme="dark"] {
  --nv-white: #ffffff;
  --nv-black: #000000;
  --nv-neutral-50: #fafafa;
  --nv-neutral-200: #e5e5e5;
  --nv-neutral-400: #a3a3a3;
  --nv-neutral-600: #525252;
  --nv-neutral-700: #404040;
  --nv-neutral-800: #262626;
  --nv-neutral-950: #0a0a0a;
  --nv-bg: #121212;
  --nv-bg-card: #191919;
  --nv-bg-sidebar: #0d0d0d;
  --nv-bg-panel: #0d0d0d;
  --nv-border: #262626;
  --nv-border-strong: #404040;
  --nv-text-soft: #a3a3a3;
  --nv-text-muted: #737373;
  --nv-accent: #38b98d;
  --nv-accent-bright: #00d092;
  --nv-error: #ef4444;
  --nv-success: #22c55e;
  --nv-radius-sm: 6px;
  --nv-radius-md: 8px;
  --nv-radius-lg: 10px;
  --nv-radius-xl: 16px;
  --nv-radius-full: 9999px;
  --nv-shadow-soft: 0 12px 24px rgba(0, 0, 0, 0.22);
  --nv-font-sans: "Cairo", "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--nv-bg);
  color: var(--nv-white);
  font-family: var(--nv-font-sans);
  scroll-behavior: smooth;
}

body { min-height: 100vh; margin: 0; background: var(--nv-bg); }
button, input, textarea { font: inherit; }
button:not(:disabled), a[href] { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }

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

.nv-webchat-app {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 16%, rgba(56, 185, 141, .12), transparent 28%),
    radial-gradient(circle at 80% 66%, rgba(110, 41, 150, .24), transparent 34%),
    linear-gradient(180deg, var(--nv-black) 0%, var(--nv-bg-sidebar) 58%, var(--nv-black) 100%);
}

.nv-webchat-app::before {
  position: absolute; inset: 0; content: ""; pointer-events: none;
  background: linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(0deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 96px 96px;
  -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,.78), transparent 70%);
  mask-image: linear-gradient(180deg, rgba(0,0,0,.78), transparent 70%);
}

.nv-webchat-shell {
  position: relative; z-index: 1; display: grid; grid-template-rows: auto 1fr;
  width: min(1180px, calc(100% - 40px)); min-height: 100vh; margin: 0 auto; padding: 28px 0;
}

.nv-webchat-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 42px; }
.nv-webchat-logo-link { display: inline-flex; }
.nv-webchat-logo { width: 178px; height: auto; }
.nv-webchat-nav { display: flex; align-items: center; gap: 24px; color: var(--nv-text-soft); font-family: "Inter", var(--nv-font-sans); font-size: 14px; font-weight: 500; }
.nv-webchat-nav a { transition: color 150ms ease; }
.nv-webchat-nav a:hover, .nv-webchat-nav a:focus-visible { color: var(--nv-white); }

.nv-webchat-workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 430px); align-items: center; gap: clamp(28px, 5vw, 72px); padding: 52px 0 64px; }
.nv-webchat-hero { display: grid; gap: 24px; max-width: 700px; }
.nv-webchat-eyebrow { margin: 0; color: var(--nv-accent); direction: ltr; font-family: "Inter", sans-serif; font-size: 11px; font-weight: 800; letter-spacing: .14em; text-align: right; }
.nv-webchat-hero h1 { margin: 0; color: var(--nv-white); font-size: clamp(43px, 6vw, 76px); font-weight: 800; line-height: 1.13; letter-spacing: -.04em; }
.nv-webchat-hero > p:not(.nv-webchat-eyebrow) { max-width: 620px; margin: 0; color: var(--nv-text-soft); font-size: 18px; line-height: 1.85; }
.nv-webchat-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.nv-webchat-button { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; border: 1px solid rgba(255,255,255,.85); border-radius: var(--nv-radius-md); padding: 0 22px; background: var(--nv-white); color: var(--nv-neutral-950); font-size: 15px; font-weight: 800; transition: transform 150ms ease, background 150ms ease; }
.nv-webchat-button:hover { transform: translateY(-1px); background: var(--nv-neutral-200); }
.nv-webchat-status { display: inline-flex; align-items: center; gap: 8px; width: max-content; border: 1px solid rgba(56,185,141,.2); border-radius: var(--nv-radius-full); padding: 8px 12px; background: rgba(56,185,141,.1); color: var(--nv-accent); font-size: 12px; font-weight: 800; }
.nv-webchat-status::before { width: 7px; height: 7px; border-radius: 999px; content: ""; background: currentColor; box-shadow: 0 0 0 5px rgba(56,185,141,.12); }
.nv-webchat-status[data-state="busy"] { color: #f8cf61; border-color: rgba(248,207,97,.24); background: rgba(248,207,97,.09); }
.nv-webchat-status[data-state="error"] { color: #fca5a5; border-color: rgba(239,68,68,.32); background: rgba(239,68,68,.09); }

.nv-niva-panel { display: flex; width: 100%; height: min(680px, calc(100vh - 148px)); min-height: 520px; flex-direction: column; overflow: hidden; border: 1px solid rgba(255,255,255,.1); border-radius: var(--nv-radius-xl); background: linear-gradient(180deg, rgba(25,25,25,.96), rgba(13,13,13,.98)), var(--nv-bg-panel); box-shadow: 0 32px 96px rgba(0,0,0,.56); }
.nv-niva-panel__header { display: flex; align-items: center; justify-content: space-between; flex: 0 0 auto; border-bottom: 1px solid #272727; padding: 21px 24px; }
.nv-webchat-brand { display: flex; align-items: center; min-width: 0; gap: 12px; }
.nv-webchat-brand p { margin: 0; color: var(--nv-accent); direction: ltr; font-family: "Inter", sans-serif; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-align: right; text-transform: uppercase; }
.nv-webchat-brand h2 { margin: 2px 0 0; overflow: hidden; color: var(--nv-white); font-size: 16px; font-weight: 700; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.nv-webchat-mark { display: grid; place-items: center; width: 31px; flex: 0 0 auto; color: var(--nv-accent); }
.nv-webchat-mark svg { width: 31px; height: auto; fill: currentColor; }
.nv-online-indicator { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--nv-success); box-shadow: 0 0 0 4px rgba(34,197,94,.12); }

.nv-niva-panel__messages { display: flex; flex: 1; flex-direction: column; gap: 18px; overflow-y: auto; padding: 18px 16px; scroll-behavior: smooth; scrollbar-color: var(--nv-border-strong) transparent; scrollbar-width: thin; }
.nv-niva-message-item { display: flex; align-items: flex-start; gap: 12px; width: 100%; padding-right: 8px; animation: nv-webchat-rise-in 220ms ease; }
.nv-niva-message-item--user { justify-content: flex-end; gap: 16px; padding-right: 0; padding-left: 8px; }
.nv-niva-message-item__avatar { display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 auto; overflow: hidden; border-radius: 50%; background: #0b040f; }
.nv-niva-message-item__avatar img { width: 100%; height: 100%; object-fit: cover; }
.nv-niva-message-item--user .nv-niva-message-item__avatar { border-radius: var(--nv-radius-lg); background: #2a2828; color: #d0d0d0; }
.nv-niva-message-item__content { display: flex; min-width: 0; flex: 1; flex-direction: column; align-items: flex-start; gap: 8px; }
.nv-niva-message-item--user .nv-niva-message-item__content { align-items: flex-end; }
.nv-niva-message-item__meta { display: flex; align-items: center; gap: 8px; min-height: 20px; color: var(--nv-text-soft); }
.nv-niva-message-item__name { color: var(--nv-white); font-size: 13px; font-weight: 700; }
.nv-niva-message-item__time { direction: ltr; color: #a1a1a1; font-family: "Inter", var(--nv-font-sans); font-size: 11px; }
.nv-niva-message-item__bubble { width: 100%; border: 1px solid #353535; border-radius: 16px 6px 16px 16px; padding: 15px 16px; background: #191919; color: var(--nv-white); font-size: 13px; line-height: 1.9; overflow-wrap: anywhere; text-align: right; unicode-bidi: plaintext; white-space: pre-wrap; }
.nv-niva-message-item--user .nv-niva-message-item__bubble { border: 0; border-radius: 6px 16px 16px; padding: 15px 20px; background: linear-gradient(135deg, #157a5a, #1a946e); color: var(--nv-white); }
.nv-niva-message-item--error .nv-niva-message-item__bubble { border-color: rgba(239,68,68,.42); color: #fecaca; }

.nv-appointment-actions { display: grid; width: 100%; gap: 10px; margin-top: 2px; border: 1px solid rgba(56,185,141,.28); border-radius: var(--nv-radius-md); padding: 12px; background: rgba(56,185,141,.07); }
.nv-appointment-actions__title { margin: 0; color: #d7fff0; font-size: 12px; font-weight: 800; }
.nv-appointment-actions__buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.nv-appointment-actions button { min-height: 34px; border: 1px solid var(--nv-border-strong); border-radius: var(--nv-radius-sm); padding: 6px 10px; background: #202020; color: var(--nv-white); font-size: 12px; font-weight: 700; transition: border-color 150ms ease, background 150ms ease; }
.nv-appointment-actions button:hover:not(:disabled) { border-color: var(--nv-accent); background: #252525; }
.nv-appointment-actions button[data-action="confirm"] { border-color: rgba(56,185,141,.55); background: rgba(56,185,141,.14); color: #c8ffeb; }
.nv-appointment-actions button[data-action="cancel"] { border-color: rgba(239,68,68,.35); color: #fecaca; }
.nv-appointment-actions button:disabled { cursor: wait; opacity: .6; }
.nv-reschedule-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.nv-reschedule-form[hidden] { display: none; }
.nv-reschedule-form input { min-width: 0; border: 1px solid var(--nv-border-strong); border-radius: var(--nv-radius-sm); padding: 8px; background: #111; color: var(--nv-white); color-scheme: dark; font-size: 12px; }
.nv-reschedule-form button { background: var(--nv-accent); color: #061b14; }
.nv-appointment-actions__result { margin: 0; color: #b8f4da; font-size: 12px; line-height: 1.7; }

.nv-niva-typing { display: flex; align-items: center; gap: 5px; padding-right: 44px; }
.nv-niva-typing span { width: 6px; height: 6px; border-radius: 50%; background: #a1a1a1; animation: nv-niva-bounce 1s infinite; }
.nv-niva-typing span:nth-child(2) { animation-delay: 150ms; }
.nv-niva-typing span:nth-child(3) { animation-delay: 300ms; }
.nv-niva-panel__composer { flex: 0 0 auto; border-top: 1px solid #2e2e2e; padding: 14px 16px 11px; background: var(--nv-bg-sidebar); }
.nv-niva-composer { display: flex; align-items: center; gap: 8px; border: 1px solid #303030; border-radius: var(--nv-radius-lg); padding: 8px; background: var(--nv-bg-card); }
.nv-niva-composer:focus-within { border-color: rgba(56,185,141,.72); box-shadow: 0 0 0 3px rgba(56,185,141,.10); }
.nv-niva-composer textarea { min-width: 0; max-height: 110px; flex: 1; border: 0; outline: 0; resize: none; background: transparent; color: var(--nv-white); font-size: 14px; line-height: 1.6; }
.nv-niva-composer textarea::placeholder { color: #7e7e7e; }
.nv-niva-composer button { display: grid; place-items: center; width: 37px; height: 37px; flex: 0 0 auto; border: 0; border-radius: var(--nv-radius-sm); background: var(--nv-accent); color: #0b040f; transition: transform 150ms ease, opacity 150ms ease; }
.nv-niva-composer button:hover:not(:disabled) { transform: translateX(-1px); }
.nv-niva-composer button:disabled { cursor: wait; opacity: .65; }
.nv-niva-composer button svg { width: 19px; height: 19px; transform: rotate(180deg); }
.nv-composer-hint { margin: 7px 2px 0; color: var(--nv-text-muted); font-size: 10px; text-align: right; }

@keyframes nv-webchat-rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes nv-niva-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }

@media (max-width: 900px) {
  .nv-webchat-shell { width: min(100% - 32px, 720px); }
  .nv-webchat-workspace { grid-template-columns: 1fr; align-items: start; padding-top: 44px; }
  .nv-webchat-hero { justify-items: center; text-align: center; }
  .nv-webchat-eyebrow { text-align: center; }
  .nv-webchat-hero > p:not(.nv-webchat-eyebrow) { text-align: center; }
  .nv-webchat-nav { display: none; }
  .nv-niva-panel { height: min(660px, calc(100vh - 410px)); }
}

@media (max-width: 640px) {
  .nv-webchat-shell { width: 100%; padding: 18px 12px 12px; }
  .nv-webchat-workspace { padding: 28px 0 0; }
  .nv-webchat-hero { display: none; }
  .nv-niva-panel { height: calc(100vh - 82px); min-height: 0; border-radius: var(--nv-radius-xl); }
  .nv-niva-panel__header { padding: 14px; }
  .nv-niva-panel__messages { padding: 14px 12px; }
  .nv-niva-panel__composer { padding: 12px; }
  .nv-webchat-logo { width: 145px; }
}
