/**
 * Tmavý režim — přepínač: html[data-theme="dark"]
 * Doplňuje tokeny v blooms.css; kontrast textu dle ui-ux (min. ~4.5:1 na body).
 */

html[data-theme="light"] {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --brand-sage-soft: rgba(172, 207, 180, 0.14);
  --brand-charcoal: #e8ecea;
  --brand-charcoal-mid: #c5d0cc;
  --brand-off-white: #0a0e0c;

  --bg-page: #0e1311;
  --bg-subtle: #161d1a;
  --bg-elevated: #1b2421;

  --text: #e8edea;
  --text-muted: #9caaa3;
  --text-soft: #7d8c84;

  --border-hairline: #2a3430;
  --border-subtle: #37423d;
  --border: #45524c;

  --primary: #e8edea;
  --primary-hover: #b8e6c8;

  --accent-sage-text: #a3d4b2;
  --accent-sage-strong: #7cb89a;
  --accent-gold: #e4c04a;
  --accent-gold-bg: rgba(212, 175, 55, 0.15);

  --danger: #f87171;
  --danger-bg: rgba(63, 32, 32, 0.85);

  --shadow-soft:
    0 2px 8px -2px rgba(0, 0, 0, 0.5),
    0 12px 28px -10px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.06);
  --shadow-lift:
    0 14px 44px -12px rgba(0, 0, 0, 0.55),
    0 20px 40px -18px rgba(172, 207, 180, 0.08);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.05);

  /* Sekundární tlačítka — výraznější sage než neutrální --border */
  --btn-outline: rgba(127, 179, 138, 0.45);
  --btn-outline-hover: rgba(163, 212, 178, 0.68);
  --btn-secondary-hover-bg: rgba(172, 207, 180, 0.16);
  --btn-secondary-shadow: 0 2px 14px rgba(172, 207, 180, 0.14);
}

html[data-theme="dark"] body::before {
  background:
    radial-gradient(ellipse 100% 80% at 50% -25%, rgba(172, 207, 180, 0.12), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 0%, rgba(212, 175, 55, 0.08), transparent 50%),
    radial-gradient(ellipse 50% 40% at 0% 100%, rgba(0, 0, 0, 0.35), transparent 45%),
    linear-gradient(180deg, #0e1311 0%, #121a17 100%);
}

html[data-theme="dark"] ::selection {
  background: rgba(172, 207, 180, 0.35);
  color: #f8fafc;
}

html[data-theme="dark"] .site-header {
  background: rgba(22, 30, 27, 0.88);
  border-bottom-color: rgba(55, 66, 61, 0.85);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 4px 24px -12px rgba(0, 0, 0, 0.4);
}

html[data-theme="dark"] .site-nav__cluster > a.site-nav__link--active,
html[data-theme="dark"] .site-nav__cluster > a[aria-current="page"] {
  color: #ecfdf5;
  background: rgba(52, 120, 85, 0.48);
  border-color: rgba(134, 239, 172, 0.48);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 1px 3px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .site-nav__cluster > a.site-nav__link--active:hover,
html[data-theme="dark"] .site-nav__cluster > a[aria-current="page"]:hover {
  color: #fff;
  background: rgba(52, 120, 85, 0.6);
  border-color: rgba(167, 243, 208, 0.55);
}

html[data-theme="dark"] .surface-card {
  background: linear-gradient(165deg, #1c2623 0%, #151d1b 100%);
  border-color: rgba(55, 66, 61, 0.9);
}

html[data-theme="dark"] .surface-card::before {
  background: linear-gradient(
    90deg,
    transparent,
    rgba(157, 201, 168, 0.2) 30%,
    rgba(201, 162, 39, 0.15) 70%,
    transparent
  );
}

html[data-theme="dark"] .hero {
  background:
    radial-gradient(ellipse 90% 70% at 50% 0%, rgba(157, 201, 168, 0.14), transparent 62%),
    linear-gradient(175deg, #1a2220 0%, #141c1a 38%, #121917 100%);
  border-color: rgba(55, 66, 61, 0.85);
}

html[data-theme="dark"] .flash {
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
}

html[data-theme="dark"] .filter-bar {
  background: rgba(22, 30, 27, 0.72);
  border-color: rgba(55, 66, 61, 0.9);
}

html[data-theme="dark"] .stacked-row {
  background: linear-gradient(180deg, #1a2220 0%, #161d1b 100%);
  border-color: var(--border-hairline);
}

html[data-theme="dark"] .stat-card {
  background: linear-gradient(145deg, #1c2623 0%, #171f1d 100%);
  border-color: rgba(55, 66, 61, 0.95);
}

html[data-theme="dark"] .card.product-card {
  background: linear-gradient(180deg, #1c2623 0%, #181f1d 100%);
  border-color: rgba(55, 66, 61, 0.9);
}

html[data-theme="dark"] .product-thumb {
  background: linear-gradient(145deg, #1f2a26 0%, #161d1b 100%);
}

html[data-theme="dark"] .product-logistics {
  background: var(--bg-subtle);
  border-color: var(--border-hairline);
}

html[data-theme="dark"] .order-kind__text {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text);
}

html[data-theme="dark"] .order-kind__btn:hover .order-kind__text {
  background: rgba(172, 207, 180, 0.12);
}

html[data-theme="dark"] .order-kind__btn input:checked + .order-kind__text {
  background: rgba(172, 207, 180, 0.18);
  color: var(--accent-sage-text);
}

html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #9fb0a8;
  opacity: 1;
}

html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
  box-shadow: 0 0 0 3px rgba(172, 207, 180, 0.22);
}

html[data-theme="dark"] .order-form__control--qty {
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.38),
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

html[data-theme="dark"] .order-form__control--qty:focus-within {
  box-shadow:
    0 3px 12px rgba(0, 0, 0, 0.45),
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 0 3px rgba(172, 207, 180, 0.22);
}

html[data-theme="dark"] .order-form__control--qty .order-form__qty-input {
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .order-form__control--qty .order-form__qty-input:focus {
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.38) !important;
}

html[data-theme="dark"] .order-form__step {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.04) 100%);
  color: #e8f0ec;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -1px 0 rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .order-form__step:hover {
  background: linear-gradient(
    180deg,
    rgba(172, 207, 180, 0.18) 0%,
    rgba(172, 207, 180, 0.08) 100%
  );
  color: var(--accent-sage-text);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .order-form__step:active {
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.55);
}

html[data-theme="dark"] .auth-card .auth-form,
html[data-theme="dark"] .auth-panel > form {
  background: linear-gradient(180deg, #1c2623 0%, #151d1b 100%);
  border-color: rgba(55, 66, 61, 0.9);
}

html[data-theme="dark"] .btn.primary {
  background: linear-gradient(180deg, #3d4844 0%, #2a3330 100%);
  color: #f0f4f2;
  border-color: #3d4844;
  box-shadow:
    0 1px 0 rgba(212, 175, 55, 0.18) inset,
    0 4px 16px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .btn.primary:hover {
  background: linear-gradient(180deg, #4d5854 0%, #3a4541 100%);
  border-color: var(--brand-gold);
  color: #fff;
  box-shadow:
    0 0 0 1px rgba(212, 175, 55, 0.35),
    0 8px 28px rgba(212, 175, 55, 0.1);
}

html[data-theme="dark"] .btn.danger {
  background: rgba(127, 29, 29, 0.45);
  border-color: #b91c1c;
  color: #fecaca;
}

html[data-theme="dark"] .btn.danger:hover {
  background: rgba(153, 27, 27, 0.55);
  color: #fff;
}

html[data-theme="dark"] .btn--sage {
  background: rgba(172, 207, 180, 0.16);
  border-color: rgba(127, 179, 138, 0.55);
  color: #d4f0e0;
}

html[data-theme="dark"] .btn--sage:hover {
  background: rgba(172, 207, 180, 0.26);
  border-color: rgba(163, 212, 178, 0.72);
  color: #ecf8f1;
  box-shadow: 0 2px 14px rgba(172, 207, 180, 0.18);
}

html[data-theme="dark"] .btn--ghost {
  background: transparent !important;
  border-color: var(--btn-outline) !important;
  color: var(--accent-sage-text) !important;
}

html[data-theme="dark"] .btn--ghost:hover {
  background: var(--btn-secondary-hover-bg) !important;
  border-color: var(--btn-outline-hover) !important;
  color: #d8f0e4 !important;
}

html[data-theme="dark"] .photo-lightbox__panel {
  background: #1a2220;
  border-color: var(--border-hairline);
}

html[data-theme="dark"] .photo-lightbox__img {
  background: #0e1311;
}

html[data-theme="dark"] .data-table thead th {
  background: var(--bg-subtle);
  color: var(--text-soft);
  border-bottom-color: var(--border-hairline);
}

html[data-theme="dark"] .data-table tbody td,
html[data-theme="dark"] .data-table tbody th {
  border-bottom-color: var(--border-hairline);
}

html[data-theme="dark"] .data-table--stripe tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

html[data-theme="dark"] .data-table--brand thead th {
  background: linear-gradient(180deg, rgba(47, 74, 56, 0.65) 0%, rgba(30, 42, 36, 0.95) 100%);
  color: var(--accent-sage-text);
  border-bottom-color: rgba(127, 179, 138, 0.35);
}

html[data-theme="dark"] .data-table--brand.data-table--stripe tbody tr:nth-child(even) td {
  background: rgba(172, 207, 180, 0.04);
}

html[data-theme="dark"] .data-table tfoot th,
html[data-theme="dark"] .data-table--brand tfoot th {
  background: linear-gradient(180deg, #1a2220 0%, rgba(47, 74, 56, 0.35) 100%);
  color: var(--text);
  border-top-color: rgba(212, 175, 55, 0.35);
}

html[data-theme="dark"] .admin-product-card {
  background: linear-gradient(165deg, #1c2623 0%, #171f1d 100%);
  border-color: rgba(55, 66, 61, 0.9);
}

html[data-theme="dark"] .admin-catalog-count {
  background: rgba(52, 120, 85, 0.35);
  border-color: rgba(134, 239, 172, 0.42);
  color: #ecfdf5;
}

html[data-theme="dark"] .order-filter-bar a {
  background: linear-gradient(180deg, #1c2623 0%, #181f1d 100%);
  border-color: rgba(55, 66, 61, 0.9);
  color: var(--text-muted);
}

html[data-theme="dark"] .accordion-hint details {
  background: linear-gradient(180deg, #1c2623 0%, #181f1d 100%);
  border-color: rgba(55, 66, 61, 0.9);
}

/* Import — výraznější sage rámeček na tmavém podkladu (bg už z tokenů v blooms.css) */
html[data-theme="dark"] .file-input-wrapper {
  border-color: rgba(127, 179, 138, 0.38);
}

html[data-theme="dark"] .file-input-wrapper.is-drag {
  border-color: var(--accent-sage-strong);
  box-shadow: 0 0 0 3px rgba(172, 207, 180, 0.2);
}

/* Banner detailu objednávky — v tmavém režimu tmavé pozadí + světlý text (ne světlý gradient + --brand-charcoal) */
html[data-theme="dark"] .admin-order-banner--submitted {
  background: linear-gradient(135deg, rgba(69, 26, 8, 0.92) 0%, rgba(40, 18, 6, 0.96) 100%);
  border-color: rgba(251, 191, 36, 0.38);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .admin-order-banner--sent {
  background: linear-gradient(135deg, rgba(20, 55, 38, 0.88) 0%, rgba(14, 40, 28, 0.94) 100%);
  border-color: rgba(127, 179, 138, 0.42);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

html[data-theme="dark"] .admin-order-banner--submitted .admin-order-banner__icon {
  background: rgba(154, 52, 18, 0.55);
  color: #fff7c2;
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.42);
}

html[data-theme="dark"] .admin-order-banner--sent .admin-order-banner__icon {
  background: rgba(22, 101, 52, 0.55);
  color: #d1fae5;
  box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.4);
}

html[data-theme="dark"] .admin-order-banner__icon {
  background: rgba(52, 120, 85, 0.45);
  color: #ecfdf5;
  box-shadow: inset 0 0 0 1px rgba(134, 239, 172, 0.38);
}

html[data-theme="dark"] .admin-order-banner__text {
  color: #c5d0cc;
}

html[data-theme="dark"] .admin-order-banner__text strong {
  color: #f8fafc;
}

html[data-theme="dark"] .buyer-order-line__note {
  background: rgba(0, 0, 0, 0.25);
  border-color: var(--border-hairline);
}

html[data-theme="dark"] input[type="file"]::file-selector-button,
html[data-theme="dark"] input[type="file"]::-webkit-file-upload-button {
  background: rgba(172, 207, 180, 0.14);
  color: var(--accent-sage-text);
  border-color: rgba(142, 184, 154, 0.4);
}

html[data-theme="dark"] .auth-field__static {
  background: var(--bg-subtle);
  border-color: var(--border-hairline);
  color: var(--text);
}

html[data-theme="dark"] .cart-badge {
  background: #4f7a5e;
  color: #f0fdf4;
  border-color: rgba(187, 247, 208, 0.4);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* Status / štítky — vyšší kontrast na tmavém pozadí */
html[data-theme="dark"] .badge--success {
  background: rgba(20, 83, 45, 0.72);
  color: #ecfdf5;
  border: 1px solid rgba(52, 211, 153, 0.55);
}

html[data-theme="dark"] .badge--warn {
  background: rgba(120, 53, 15, 0.72);
  color: #fffbeb;
  border: 1px solid rgba(251, 191, 36, 0.58);
}

html[data-theme="dark"] .badge--neutral {
  background: rgba(51, 65, 85, 0.85);
  color: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.55);
}

html[data-theme="dark"] .badge--brand-sent {
  background: rgba(113, 63, 18, 0.72);
  color: #fff7c2;
  border: 1px solid rgba(251, 191, 36, 0.58);
}

/* Ikony v řádcích objednávek — čitelnější výplň + ikona */
html[data-theme="dark"] .stacked-row__icon {
  background: rgba(52, 120, 85, 0.45);
  color: #ecfdf5;
  box-shadow: inset 0 0 0 1px rgba(134, 239, 172, 0.42);
}

html[data-theme="dark"] .stacked-row__icon--submitted {
  background: rgba(154, 52, 18, 0.55);
  color: #fff7c2;
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.45);
}

html[data-theme="dark"] .stacked-row__icon--sent {
  background: rgba(22, 101, 52, 0.58);
  color: #d1fae5;
  box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.42);
}

html[data-theme="dark"] .stacked-row__icon--other {
  background: rgba(71, 85, 105, 0.62);
  color: #f8fafc;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.42);
}

html[data-theme="dark"] .in-cart-badge {
  background: rgba(52, 120, 85, 0.5);
  color: #ecfdf5;
  border-color: rgba(134, 239, 172, 0.48);
  font-weight: 600;
}

/* Přehled (dashboard) — ikony ve stat kartách na tmavém podkladu */
html[data-theme="dark"] .stat-card--orders-queue .stat-card__icon {
  background: rgba(154, 52, 18, 0.5);
  color: #fff7c2;
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.42);
}

html[data-theme="dark"] .stat-card--orders-sent .stat-card__icon {
  background: rgba(22, 101, 52, 0.55);
  color: #d1fae5;
  box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.4);
}

html[data-theme="dark"] .stat-card--registrations .stat-card__icon {
  background: rgba(146, 64, 14, 0.52);
  color: #fff7c2;
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.4);
}

html[data-theme="dark"] .stat-card--buyers .stat-card__icon {
  background: rgba(67, 56, 202, 0.42);
  color: #e0e7ff;
  box-shadow: inset 0 0 0 1px rgba(165, 180, 252, 0.45);
}

html[data-theme="dark"] .stat-card--imports .stat-card__icon {
  background: rgba(7, 89, 133, 0.48);
  color: #e0f2fe;
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.45);
}

@media (max-width: 720px) {
  html[data-theme="dark"] .data-table--responsive tbody tr {
    background: var(--bg-elevated);
    border-color: var(--border-hairline);
  }

  html[data-theme="dark"] .data-table--responsive tfoot tr {
    background: linear-gradient(180deg, #1a2220 0%, rgba(47, 74, 56, 0.4) 100%);
    border-color: rgba(127, 179, 138, 0.35);
  }
}

html[data-theme="dark"] .flash__dismiss:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .empty-state__icon {
  color: #b8e6c8;
}

html[data-theme="dark"] .empty-state__icon svg {
  opacity: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}

html[data-theme="dark"] .admin-metric__label {
  color: #b8c4bf;
}

html[data-theme="dark"] .admin-metric__value {
  color: #f0f4f2;
}

html[data-theme="dark"] .surface-card--accent::before {
  background: linear-gradient(
    90deg,
    rgba(157, 201, 168, 0.5) 0%,
    rgba(201, 162, 39, 0.45) 48%,
    rgba(157, 201, 168, 0.42) 100%
  );
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  margin: 0;
  border-radius: var(--radius-pill);
  border: 1px solid var(--btn-outline);
  background: transparent;
  color: var(--accent-sage-text);
  cursor: pointer;
  transition: var(--transition);
}

html[data-theme="dark"] .theme-toggle:hover {
  color: #e8f5ee;
  border-color: var(--btn-outline-hover);
  background: var(--btn-secondary-hover-bg);
  box-shadow: var(--btn-secondary-shadow);
}

html[data-theme="light"] .theme-toggle:hover {
  color: var(--brand-sage-deep);
  border-color: var(--btn-outline-hover);
  background: var(--btn-secondary-hover-bg);
  box-shadow: var(--btn-secondary-shadow);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent-sage-strong);
  outline-offset: 2px;
}

.theme-toggle svg {
  width: 1.25rem;
  height: 1.25rem;
}

html[data-theme="dark"] .theme-toggle .theme-toggle__icon--sun {
  display: block;
}

html[data-theme="dark"] .theme-toggle .theme-toggle__icon--moon {
  display: none;
}

html[data-theme="light"] .theme-toggle .theme-toggle__icon--sun {
  display: none;
}

html[data-theme="light"] .theme-toggle .theme-toggle__icon--moon {
  display: block;
}

/* Hamburger (vedle theme toggle) — výchozí stav musí být čitelný i bez hoveru */
html[data-theme="dark"] .nav-burger {
  color: #e8f5ee;
  border-color: var(--btn-outline);
}

html[data-theme="dark"] .nav-burger__bar {
  height: 2.5px;
  border-radius: 2px;
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .nav-burger:hover {
  color: #f8fafc;
  border-color: var(--btn-outline-hover);
  background: var(--btn-secondary-hover-bg);
  box-shadow: var(--btn-secondary-shadow);
}

html[data-theme="light"] .nav-burger:hover {
  color: var(--brand-sage-deep);
  border-color: var(--btn-outline-hover);
  background: var(--btn-secondary-hover-bg);
  box-shadow: var(--btn-secondary-shadow);
}
