/* ============================================================
   components.css — buttons, tabs, forms, panels, AI widgets
   ============================================================ */

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 700;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: var(--steel-700);
  color: #fff;
}

.btn--primary:hover {
  filter: brightness(1.08);
}

.btn--gradient {
  background: linear-gradient(100deg, var(--steel-600), var(--navy-900));
  color: #fff;
  justify-content: center;
  width: 100%;
  padding: 13px 20px;
  border-radius: var(--radius-md);
}

.btn--gradient:hover {
  filter: brightness(1.1);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--text-2);
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--navy-900);
}

.icon-btn--circle {
  border-radius: 50%;
  border: 1px solid var(--border);
}

/* ---------- Patient history button ---------- */

.history-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 8px;
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--navy-900);
  box-shadow: var(--shadow-card);
  transition: filter 0.15s ease;
}

.history-btn:hover {
  filter: brightness(0.97);
}

.history-btn__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--navy-900);
  color: #fff;
}

.history-btn__icon .icon {
  width: 17px;
  height: 17px;
}

.history-btn__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
}

.history-btn__text strong {
  font-size: 13px;
  font-weight: 700;
}

.history-btn__text small {
  font-size: 10.5px;
  color: var(--text-3);
}

.history-btn__chevron {
  width: 15px;
  height: 15px;
  color: var(--text-3);
}

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab:hover {
  background: var(--surface-2);
  color: var(--navy-900);
}

.tab.is-active {
  background: var(--primary-soft);
  color: var(--navy-800);
  font-weight: 700;
}

.tab .icon {
  width: 16px;
  height: 16px;
}

.tab__badge {
  display: grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 50%;
  font-size: 10.5px;
  font-weight: 700;
  background: var(--primary-softer);
  color: var(--primary);
}

.tab.is-active .tab__badge {
  background: #fff;
}

/* ---------- Panel ---------- */

.panel {
  padding: 22px 24px 26px;
}

.panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.panel__heading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.panel__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--navy-800);
}

.panel__title {
  font-size: 17px;
  font-weight: 800;
  color: var(--navy-900);
}

.panel__subtitle {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 12px;
  background: var(--primary-softer);
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 700;
  transition: filter 0.15s ease;
}

.ai-chip:hover {
  filter: brightness(0.96);
}

.ai-chip .icon {
  width: 15px;
  height: 15px;
}

.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-3);
}

.empty-state h3 {
  color: var(--text-2);
  margin-bottom: 6px;
}

/* ---------- Form ---------- */

.form__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px 20px;
}

.form__grid--allergy {
  margin-top: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.field--span2 {
  grid-column: span 2;
}

.field__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.field__input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-1);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
}

.field__input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-softer);
}

.field__input:read-only {
  background: #fff;
}

.field__input--danger {
  border-color: var(--red);
  color: var(--red);
}

.field__input--danger:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}

/* number input spinners off */
.field__input[type="number"]::-webkit-outer-spin-button,
.field__input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.field__input[type="number"] {
  -moz-appearance: textfield;
}

/* Select with custom chevron */
.select-wrap {
  position: relative;
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 1.8px solid var(--text-3);
  border-bottom: 1.8px solid var(--text-3);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.select-wrap .field__input {
  padding-right: 36px;
  cursor: pointer;
}

/* Input with suffix (kg / cm / badge) */
.input-affix {
  position: relative;
  display: flex;
  align-items: center;
}

.input-affix .field__input {
  padding-right: 64px;
}

.input-affix__suffix {
  position: absolute;
  right: 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-3);
  pointer-events: none;
}

/* ---------- Badges ---------- */

.badge {
  position: absolute;
  right: 10px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
}

.badge--green {
  background: var(--green-soft);
  color: var(--green);
}

.badge--amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge--red {
  background: var(--red-soft);
  color: var(--red);
}

.badge--blue {
  background: var(--primary-softer);
  color: var(--primary);
}

/* ---------- AI processing overlay ----------
   Shown from the moment the transcript is closed until OMNIA's suggestions
   land (or fail). The motion logo plays muted so browsers allow autoplay. */

.ai-processing {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 30, 45, 0.55);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.ai-processing.is-open {
  opacity: 1;
  visibility: visible;
}

.ai-processing__dialog {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: min(420px, 100%);
  padding: 30px 32px 34px;
  text-align: center;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(15, 30, 45, 0.28);
}

.ai-processing__video {
  width: min(260px, 74%);
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: var(--radius-lg);
  background: #fff;
}

.ai-processing__title {
  font-size: 17px;
  font-weight: 800;
  color: var(--navy-900);
}

.ai-processing__desc {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-2);
  max-width: 300px;
}

.ai-processing__dots {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}

.ai-processing__dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  animation: aiProcessingDot 1.1s ease-in-out infinite;
}

.ai-processing__dots span:nth-child(2) { animation-delay: 0.15s; }
.ai-processing__dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes aiProcessingDot {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-4px); }
}

/* ---------- Toggle cards ---------- */

.form__toggles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 20px;
}

.toggle-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  cursor: pointer;
  transition: background 0.15s ease;
}

.toggle-card:hover {
  background: #eaf2f8;
}

.toggle-card__icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff;
  color: var(--navy-800);
  flex-shrink: 0;
}

.toggle-card__icon--danger {
  color: var(--red);
}

.toggle-card__text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
}

.toggle-card__text strong {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-1);
}

.toggle-card__text small {
  font-size: 11px;
  color: var(--text-3);
}

/* Custom checkbox */
.checkbox {
  appearance: none;
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--border-strong);
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}

/* rtl:begin:ignore — a check mark reads the same in every language */
.checkbox::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2.2px solid #fff;
  border-bottom: 2.2px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
  opacity: 0;
  transition: opacity 0.1s ease;
}
/* rtl:end:ignore */

.checkbox:checked {
  background: var(--primary);
  border-color: var(--primary);
}

.checkbox:checked::after {
  opacity: 1;
}

.checkbox--danger:checked {
  background: var(--red);
  border-color: var(--red);
}

/* ---------- AI assistant panel ---------- */

.ai-panel__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
}

.ai-panel__logo {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: var(--navy-900);
  color: #fff;
  flex-shrink: 0;
}

.ai-panel__logo .icon {
  width: 26px;
  height: 26px;
}

.ai-panel__titles h2 {
  font-size: 16px;
  font-weight: 800;
  color: var(--navy-900);
}

.ai-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 3px;
}

.ai-status__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  transition: background 0.2s ease;
}

.ai-panel.is-listening .ai-status__dot {
  background: var(--green);
  animation: blink 1.2s ease-in-out infinite;
}

@keyframes blink {
  50% { opacity: 0.35; }
}

.ai-panel__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 24px 20px;
}

.ai-orb {
  width: min(260px, 82%);
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  margin-bottom: 10px;
}

.ai-panel.is-listening .ai-orb {
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.ai-panel__welcome {
  font-size: 16.5px;
  font-weight: 800;
  color: var(--navy-900);
}

.ai-panel__desc {
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-2);
  max-width: 280px;
}

.ai-panel__start {
  margin-top: 10px;
  max-width: 300px;
}

.ai-panel.is-listening .ai-panel__start {
  background: linear-gradient(100deg, #b23b3b, #7d2626);
}

/* ---------- Toast ----------
   The one status line every section page carries (#toast). The showToast
   helpers fill it with a glyph and the message, pick a tone and hold it
   for a few seconds; the clock stops while the pointer rests on it. */

.toast {
  --toast-accent: var(--primary);
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 320px;
  max-width: min(640px, calc(100vw - 32px));
  padding: 16px 22px 16px 18px;
  border-radius: var(--radius-md);
  border-left: 4px solid var(--toast-accent);
  background: var(--navy-900);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 1100;
}

.toast.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.toast__icon {
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  color: var(--toast-accent);
}

.toast__icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.toast__text {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.toast--success {
  --toast-accent: var(--green);
}

.toast--error {
  --toast-accent: var(--red);
}

.toast--warning {
  --toast-accent: var(--amber);
}

.toast--info {
  --toast-accent: var(--primary);
}

@media (prefers-reduced-motion: reduce) {
  .toast,
  .toast.is-visible {
    transform: translate(-50%, 0);
    transition: opacity 0.15s ease;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .form__grid,
  .form__toggles {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .form__grid,
  .form__toggles {
    grid-template-columns: 1fr;
  }

  .field--span2 {
    grid-column: auto;
  }

  .panel {
    padding: 18px 16px 22px;
  }

  /* Header actions become equal-width tap targets */
  .page-header__right .btn {
    flex: 1 1 auto;
    justify-content: center;
    padding: 11px 14px;
  }

  /* 16px inputs prevent iOS auto-zoom on focus */
  .field__input {
    font-size: 16px;
  }

  .toast {
    bottom: 16px;
    min-width: 0;
    width: calc(100vw - 32px);
    max-width: none;
    padding: 14px 16px 14px 14px;
  }
}

/* ============================================================
   Shell navigation drawer (narrow screens)
   The sidebar shells (reception, medical leave, doctor list, admin)
   keep their sidebar on wide screens; below 900px the brand row
   becomes a top bar and the nav slides in from the left behind
   [data-shell-toggle]. The open state is body.shell-nav-open, set
   by assets/js/shell-nav.js. Each shell styles its own drawer
   panel; the button, the veil and the scroll lock are shared here.
   ============================================================ */

.shell-toggle,
.shell-backdrop {
  display: none;
}

@media (max-width: 900px) {
  .shell-toggle {
    display: grid;
    place-items: center;
    flex: none;
    width: 42px;
    height: 42px;
    margin-left: auto;
    border-radius: 12px;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    transition: background 0.15s ease;
  }

  .shell-toggle:hover {
    background: rgba(255, 255, 255, 0.16);
  }

  .shell-toggle .icon {
    width: 22px;
    height: 22px;
  }

  .shell-toggle__close,
  body.shell-nav-open .shell-toggle__open {
    display: none;
  }

  body.shell-nav-open .shell-toggle__close {
    display: block;
  }

  .shell-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(20, 48, 77, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  body.shell-nav-open .shell-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.shell-nav-open {
    overflow: hidden;
  }
}

/* ---------- Shared pieces on phones ---------- */

@media (max-width: 560px) {
  .tabs {
    padding: 6px;
  }

  .tab {
    padding: 9px 12px;
  }

  .panel__header,
  .panel__heading {
    flex-wrap: wrap;
  }

  .empty-state {
    padding: 40px 16px;
  }
}

/* =========================================================
   Language switch (components/locale-switcher.blade.php)
   One button per other language, labelled in that language.
   ========================================================= */
.locale-switch {
  display: flex;
  align-items: center;
  gap: 6px;
}

.locale-switch form {
  margin: 0;
}

.locale-switch__btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--navy-900);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.locale-switch__btn:hover {
  background: var(--primary-softer);
  border-color: var(--primary);
  color: var(--primary);
}

.locale-switch__btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* At the foot of a light sidebar: the full width, pushed to the bottom */
.locale-switch--sidebar {
  margin-top: auto;
}

.locale-switch--sidebar form,
.locale-switch--sidebar .locale-switch__btn {
  width: 100%;
}

.locale-switch--sidebar .locale-switch__btn {
  justify-content: center;
  border-radius: var(--radius-sm);
}

/* The dark admin sidebar */
.locale-switch--dark {
  margin-bottom: 6px;
}

.locale-switch--dark form,
.locale-switch--dark .locale-switch__btn {
  width: 100%;
}

.locale-switch--dark .locale-switch__btn {
  height: 36px;
  border-color: rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.85);
}

.locale-switch--dark .locale-switch__btn:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
