/* DrDrive theme UI + dark/light surface fixes */

.ud-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0 0.65rem;
  border-radius: 0.65rem;
  border: 1px solid color-mix(in srgb, var(--ud-brand) 28%, var(--ud-border));
  background: color-mix(in srgb, var(--ud-brand) 8%, var(--ud-canvas));
  color: var(--ud-text);
  cursor: pointer;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
  flex-shrink: 0;
  transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.ud-theme-toggle:hover {
  background: color-mix(in srgb, var(--ud-brand) 16%, var(--ud-canvas));
  border-color: color-mix(in srgb, var(--ud-brand) 40%, var(--ud-border));
}

.ud-theme-toggle:focus-visible {
  outline: 2px solid var(--ud-brand);
  outline-offset: 2px;
}

.ud-theme-toggle__icon {
  font-size: 1.05rem;
  line-height: 1;
}

.ud-theme-toggle__label {
  display: none;
}

@media (min-width: 480px) {
  .ud-theme-toggle__label {
    display: inline;
  }
}

.ud-theme-toggle--drawer {
  width: 100%;
  margin: 0.35rem 0 0.75rem;
  justify-content: center;
}

.ud-theme-toggle--admin {
  margin-inline-end: 0.35rem;
}

/* Floating toggle for App PWA auth/shell pages without site header */
.ud-theme-toggle--float {
  position: fixed;
  z-index: 80;
  top: max(0.75rem, env(safe-area-inset-top));
  inset-inline-end: max(0.75rem, env(safe-area-inset-right));
  min-width: 2.75rem;
  min-height: 2.75rem;
  box-shadow: 0 8px 24px var(--ud-shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.ud-theme-toggle--float .ud-theme-toggle__label {
  display: none;
}

/* Forms: avoid UA color-scheme making text unreadable on themed backgrounds */
html[data-theme="light"],
html[data-theme="dark"] {
  color-scheme: inherit;
}

html[data-theme="light"] {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

html[data-theme="light"] body,
html[data-theme="dark"] body,
html[data-theme="light"] #root,
html[data-theme="dark"] #root {
  background-color: var(--ud-canvas);
  color: var(--ud-text);
}

html[data-theme="light"] input,
html[data-theme="light"] textarea,
html[data-theme="light"] select,
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
  color: var(--ud-text);
  background-color: var(--ud-input-bg);
  border-color: var(--ud-border);
  caret-color: var(--ud-brand);
}

html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder,
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: var(--ud-text-muted);
  opacity: 0.85;
}

html[data-theme="light"] input:-webkit-autofill,
html[data-theme="light"] textarea:-webkit-autofill,
html[data-theme="light"] select:-webkit-autofill,
html[data-theme="dark"] input:-webkit-autofill,
html[data-theme="dark"] textarea:-webkit-autofill,
html[data-theme="dark"] select:-webkit-autofill {
  -webkit-text-fill-color: var(--ud-text);
  caret-color: var(--ud-brand);
  box-shadow: 0 0 0 1000px var(--ud-input-bg) inset;
  transition: background-color 99999s ease-out;
}

/* Soft tint banners used on auth/coaches — keep readable in both themes */
html[data-theme="dark"] .bg-red-50,
html[data-theme="dark"] .bg-red-50\/80 {
  background-color: color-mix(in srgb, var(--ud-danger) 16%, var(--ud-surface)) !important;
  color: color-mix(in srgb, var(--ud-danger) 85%, #fff) !important;
}

html[data-theme="dark"] .bg-emerald-50,
html[data-theme="dark"] .bg-emerald-100 {
  background-color: color-mix(in srgb, var(--color-success) 16%, var(--ud-surface)) !important;
  color: color-mix(in srgb, var(--color-success) 75%, #fff) !important;
}

html[data-theme="dark"] .bg-violet-50,
html[data-theme="dark"] .bg-violet-100 {
  background-color: color-mix(in srgb, var(--ud-brand) 16%, var(--ud-surface)) !important;
  color: var(--ud-brand) !important;
}

html[data-theme="dark"] .bg-amber-50,
html[data-theme="dark"] .bg-amber-100 {
  background-color: color-mix(in srgb, var(--ud-warning) 16%, var(--ud-surface)) !important;
  color: var(--ud-warning) !important;
}

html[data-theme="dark"] .from-violet-50 {
  --tw-gradient-from: color-mix(in srgb, var(--ud-brand) 12%, var(--ud-surface)) !important;
}

html[data-theme="dark"] .to-violet-200 {
  --tw-gradient-to: color-mix(in srgb, var(--ud-brand) 22%, var(--ud-surface)) !important;
}

html[data-theme="dark"] .bg-neutral-950,
html[data-theme="dark"] .from-neutral-950 {
  background-color: var(--ud-canvas) !important;
}

html[data-theme="light"] .bg-neutral-950,
html[data-theme="light"] .from-neutral-950 {
  background-color: var(--ud-canvas) !important;
  color: var(--ud-text);
}

/* Hardcoded palette / opacity text that stays unreadable on dark canvas */
html[data-theme="dark"] .text-amber-400,
html[data-theme="dark"] .text-amber-500,
html[data-theme="dark"] .text-amber-600,
html[data-theme="dark"] .text-amber-700,
html[data-theme="dark"] .text-amber-800,
html[data-theme="dark"] .text-amber-900,
html[data-theme="dark"] .text-amber-950 {
  color: var(--ud-warning) !important;
}

html[data-theme="dark"] .text-emerald-600,
html[data-theme="dark"] .text-emerald-800,
html[data-theme="dark"] .text-emerald-900 {
  color: var(--color-success) !important;
}

html[data-theme="dark"] .text-red-900,
html[data-theme="dark"] .text-red-300 {
  color: var(--ud-danger) !important;
}

html[data-theme="dark"] .text-brand,
html[data-theme="dark"] .text-brand\/70,
html[data-theme="dark"] .text-brand\/80,
html[data-theme="dark"] .text-brand\/90 {
  color: var(--ud-brand) !important;
}

html[data-theme="dark"] .text-border {
  color: var(--ud-text-muted) !important;
}

html[data-theme="dark"] .text-text-muted,
html[data-theme="dark"] .text-text-muted\/40,
html[data-theme="dark"] .text-text-muted\/50,
html[data-theme="dark"] .text-text-muted\/80,
html[data-theme="dark"] .text-text-muted\/90,
html[data-theme="dark"] .disabled\:text-text-muted:disabled {
  color: var(--ud-text-muted) !important;
}

html[data-theme="dark"] .text-text {
  color: var(--ud-text) !important;
}

html[data-theme="dark"] .text-warning {
  color: var(--ud-warning) !important;
}

html[data-theme="dark"] .text-danger {
  color: var(--ud-danger) !important;
}

html[data-theme="dark"] .text-success {
  color: var(--color-success) !important;
}

/* SVG icons inheriting too-dark strokes */
html[data-theme="dark"] svg:not([fill="none"]) {
  color: inherit;
}

html[data-theme="dark"] .text-text-muted svg,
html[data-theme="dark"] button svg,
html[data-theme="dark"] a svg {
  stroke: currentColor;
}

html[data-theme="dark"] .border-amber-200,
html[data-theme="dark"] .border-emerald-200,
html[data-theme="dark"] .border-red-300 {
  border-color: var(--ud-border) !important;
}

html[data-theme="dark"] .site-header,
html[data-theme="dark"] header.sticky {
  background: color-mix(in srgb, var(--ud-canvas) 92%, transparent);
}

html[data-theme="dark"] .sh-nav-drawer__panel {
  background: var(--ud-canvas);
  color: var(--ud-text);
  border-inline-start: 1px solid var(--ud-border);
}

html[data-theme="dark"] .sh-nav-drawer__panel a {
  color: var(--ud-text-muted);
}

html[data-theme="dark"] .sh-nav-drawer__panel a.is-active,
html[data-theme="dark"] .sh-nav-drawer__panel a:hover {
  color: var(--ud-brand);
}

html[data-theme="dark"] .home-footer,
html[data-theme="dark"] footer.home-footer {
  background: var(--ud-surface);
  border-top-color: var(--ud-border);
}

html[data-theme="dark"] .home-coach-skeleton__media,
html[data-theme="dark"] .home-coach-skeleton__line {
  background: color-mix(in srgb, var(--ud-text-muted) 14%, var(--ud-surface));
}

html[data-theme="dark"] .home-mockup {
  background: var(--ud-surface);
  border-color: var(--ud-border);
}

html[data-theme="dark"] .blog-prose pre {
  background: var(--ud-code-bg);
  color: var(--ud-code-text);
}

html[data-theme="dark"] .blog-prose :not(pre) > code {
  background: color-mix(in srgb, var(--ud-text) 8%, var(--ud-surface));
}

html[data-theme="dark"] .blog-crumb__sep {
  color: var(--ud-text-muted);
}

html[data-theme="dark"] .tox-tinymce,
html[data-theme="dark"] .tox .tox-edit-area__iframe {
  border-color: var(--ud-border) !important;
}

html[data-theme="dark"] .ud-studio__panel {
  background: var(--ud-canvas);
  border-color: var(--ud-border);
  color: var(--ud-text);
}

html[data-theme="dark"] .ud-studio__panel-head {
  background: var(--ud-surface);
  border-bottom-color: var(--ud-border);
}

html[data-theme="dark"] .ud-studio__section button,
html[data-theme="dark"] .ud-studio__field input,
html[data-theme="dark"] .ud-studio__field select,
html[data-theme="dark"] .ud-studio__field textarea {
  background: var(--ud-input-bg);
  border-color: var(--ud-border);
  color: var(--ud-text);
}

html[data-theme="dark"] #ud-brand-loader {
  background: #ffffff;
}

html[data-theme="dark"] .bg-canvas,
html[data-theme="dark"] .bg-canvas\/80,
html[data-theme="dark"] .bg-canvas\/95 {
  background-color: var(--color-canvas) !important;
}

html[data-theme="dark"] .bg-surface {
  background-color: var(--color-surface) !important;
}

html[data-theme="dark"] .text-text {
  color: var(--color-text) !important;
}

html[data-theme="dark"] .text-text-muted,
html[data-theme="dark"] .text-text-muted\/40,
html[data-theme="dark"] .text-text-muted\/90 {
  color: var(--color-text-muted) !important;
}

html[data-theme="dark"] .border-border,
html[data-theme="dark"] .border-border\/70,
html[data-theme="dark"] .border-border\/80 {
  border-color: var(--color-border) !important;
}

html[data-theme="dark"] .bg-white {
  background-color: var(--color-canvas) !important;
}

html[data-theme="dark"] .bg-slate-50,
html[data-theme="dark"] .bg-gray-50 {
  background-color: var(--color-surface) !important;
}

html[data-theme="dark"] .shadow,
html[data-theme="dark"] .shadow-sm,
html[data-theme="dark"] .shadow-md {
  box-shadow: 0 1px 3px var(--ud-shadow) !important;
}

html[data-theme="dark"] .ring-border,
html[data-theme="dark"] .ring-border\/60 {
  --tw-ring-color: var(--color-border) !important;
}

html[data-theme="dark"] .tox .tox-toolbar,
html[data-theme="dark"] .tox .tox-toolbar__primary,
html[data-theme="dark"] .tox .tox-statusbar {
  background-color: var(--ud-surface) !important;
  border-color: var(--ud-border) !important;
}

html[data-theme="dark"] .tox .tox-tbtn,
html[data-theme="dark"] .tox .tox-tbtn svg {
  color: var(--ud-text) !important;
  fill: var(--ud-text) !important;
}

/* App companion / frosted panels — readable in dark */
html[data-theme="dark"] .ai-companion-panel {
  background: color-mix(in srgb, var(--ud-surface) 88%, transparent) !important;
  border-color: var(--ud-border) !important;
  color: var(--ud-text) !important;
}

html[data-theme="dark"] .ai-companion-mascot__bubble {
  background: var(--ud-surface) !important;
  border-color: var(--ud-border) !important;
  color: var(--ud-text) !important;
}

html[data-theme="dark"] .ai-companion-panel__subtitle,
html[data-theme="dark"] .ai-companion-panel__preview,
html[data-theme="dark"] .ai-companion-panel__footer {
  color: var(--ud-text-muted) !important;
}

/* Coach / instructor review lists — mobile RTL + touch scroll */
.coach-review-panel,
.coach-review-list,
.coach-review-item,
.instructor-review-list,
.instructor-review-item,
.review-modal-scroll,
.review-modal-scroll .rounded-panel,
.coach-review-panel .rounded-panel,
.instructor-review-item.rounded-panel {
  direction: rtl;
  writing-mode: horizontal-tb;
  text-orientation: mixed;
  transform: none;
  filter: none;
  unicode-bidi: isolate;
}

.coach-review-panel .review-text-wrapper,
.coach-review-panel .review-text-content,
.instructor-review-list .review-text-wrapper,
.instructor-review-list .review-text-content {
  transform: none;
  filter: none;
}

.coach-review-panel {
  overflow: visible;
}

.coach-review-list,
.instructor-review-list {
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

.coach-review-item,
.instructor-review-item {
  min-width: 0;
  overflow: visible;
}

.coach-review-name,
.instructor-review-name,
input.coach-review-name,
input.review-alias {
  direction: rtl;
  unicode-bidi: isolate;
  text-align: right;
  letter-spacing: 0 !important;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
  writing-mode: horizontal-tb;
  transform: none;
}

.coach-review-meta,
.instructor-review-meta {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: left;
  flex-shrink: 0;
  letter-spacing: 0;
}

.coach-review-text,
.instructor-review-text,
.review-text-wrapper {
  direction: rtl;
  unicode-bidi: isolate;
  text-align: right;
  writing-mode: horizontal-tb;
  transform: none;
  filter: none;
  overflow: visible;
  max-height: none;
  display: block;
  -webkit-line-clamp: unset;
  line-clamp: unset;
}

.review-text-content {
  direction: rtl;
  unicode-bidi: isolate;
  text-align: right;
  writing-mode: horizontal-tb;
  transform: none;
  filter: none;
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: anywhere;
  letter-spacing: 0;
}

.review-rtl-probe-outside {
  direction: rtl;
  unicode-bidi: isolate;
  text-align: right;
}

textarea.coach-review-text,
textarea.instructor-review-text {
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: anywhere;
}

.review-phone,
.coach-review-phone,
.instructor-review-phone,
input.coach-review-phone,
input.review-phone {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: left;
  letter-spacing: 0 !important;
  writing-mode: horizontal-tb;
  transform: none;
}

.review-rtl-probe {
  direction: rtl;
}

.review-modal-scroll {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  min-height: 0;
  flex: 1 1 auto;
  scrollbar-width: thin;
}

.review-modal-footer {
  flex-shrink: 0;
}
