/* Дополнительные кастомные стили для мини-CRM бассейна H2O */

/* Навигационные табы */
.tab-btn {
  color: #64748b;
}
.tab-btn:hover {
  color: #0f172a;
  background-color: #f1f5f9;
}
.tab-btn.active {
  color: #0284c7;
  background-color: #e0f2fe;
  font-weight: 600;
}

.tab-btn-m {
  color: #64748b;
  background-color: #ffffff;
}
.tab-btn-m.active {
  color: #0284c7;
  background-color: #e0f2fe;
  font-weight: 600;
}

/* Дни недели в шаблоне */
.dow-btn {
  color: #64748b;
}
.dow-btn.active {
  background-color: #ffffff;
  color: #0284c7;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Календарь */
.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.cal-day:hover:not(.empty) {
  background-color: #f1f5f9;
}
.cal-day.selected {
  background-color: #0284c7 !important;
  color: #ffffff !important;
  font-weight: 700;
  box-shadow: 0 2px 4px rgba(2, 132, 199, 0.3);
}
.cal-day.today {
  border: 2px solid #0284c7;
  color: #0284c7;
}
.cal-day.empty {
  cursor: default;
}

/* Слоты расписания */
.slot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-radius: 0.75rem;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  transition: all 0.15s ease;
}
.slot-row:hover {
  border-color: #cbd5e1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.slot-row.slot-attended {
  background-color: #f0fdf4;
  border-color: #86efac;
}
.slot-row.slot-empty {
  background-color: rgba(255, 255, 255, 0.6);
  border-style: dashed;
}

/* Скроллбары */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ==================== YCLIENTS СТИЛИ ДЛЯ ЖУРНАЛА ==================== */

/* Карточка записи в стиле YCLIENTS */
.yc-card {
  position: relative;
  border-radius: 0.625rem;
  border: 1px solid #e2e8f0;
  background-color: #ffffff;
  padding: 0.5rem 0.75rem;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  border-left-width: 4px;
}
.yc-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
  border-color: #cbd5e1;
}

/* Цветовая кодировка статусов визита */
.yc-status-planned {
  border-left-color: #f59e0b; /* Янтарный: Ожидание / Запланировано */
  background: linear-gradient(90deg, rgba(254, 243, 199, 0.25) 0%, #ffffff 25%);
}
.yc-status-attended {
  border-left-color: #10b981; /* Зеленый: Ребенок пришел / Занятие списано */
  background: linear-gradient(90deg, rgba(209, 250, 229, 0.3) 0%, #ffffff 25%);
}
.yc-status-confirmed {
  border-left-color: #0284c7; /* Синий: Подтверждено родителем */
  background: linear-gradient(90deg, rgba(224, 242, 254, 0.3) 0%, #ffffff 25%);
}
.yc-status-empty {
  border-left-color: #cbd5e1;
  border-style: dashed;
  background-color: rgba(248, 250, 252, 0.65);
}
.yc-status-empty:hover {
  border-left-color: #0284c7;
  border-style: solid;
  background-color: #ffffff;
  box-shadow: 0 2px 8px -1px rgba(2, 132, 199, 0.12);
}

/* Красная линия текущего времени (YCLIENTS Timeline Now) */
.timeline-now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background-color: #ef4444;
  z-index: 20;
  pointer-events: none;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}
.timeline-now-dot {
  position: absolute;
  left: -4px;
  top: -4px;
  width: 10px;
  height: 10px;
  background-color: #ef4444;
  border-radius: 9999px;
  box-shadow: 0 0 0 2px #ffffff, 0 0 8px rgba(239, 68, 68, 0.6);
  animation: pulse-dot 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.2); }
}

/* Боковая выезжающая шторка (Quick Drawer) */
#drawer-backdrop {
  transition: opacity 0.25s ease;
}
#drawer-backdrop.drawer-open {
  display: block !important;
  opacity: 1;
}
#drawer-backdrop.drawer-closed {
  opacity: 0;
  pointer-events: none;
}

#quick-drawer {
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}
#quick-drawer.drawer-open {
  transform: translateX(0) !important;
}
#quick-drawer.drawer-closed {
  transform: translateX(100%) !important;
}

/* Бейджи и микроэлементы */
.yc-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1rem;
}

/* Мобильный переключатель чаш */
.pool-toggle-btn {
  color: #64748b;
  background-color: transparent;
  transition: all 0.2s ease;
}
.pool-toggle-btn.active {
  background-color: #ffffff;
  color: #0284c7;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  font-weight: 700;
}

/* Spotlight Ctrl+K */
.spotlight-item {
  transition: all 0.15s ease;
}
.spotlight-item:hover, .spotlight-item.active {
  background-color: #f0f9ff;
  border-color: #bae6fd;
}

/* KPI карточки дашборда */
.stat-kpi-card {
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
}
.stat-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px -4px rgba(15, 23, 42, 0.06);
}

/* Хронология визитов ребенка */
.history-item {
  position: relative;
  padding-left: 1.25rem;
  border-left: 2px solid #e2e8f0;
}
.history-item::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #0284c7;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px #0284c7;
}

:root { --crm-ink: #12394a; --crm-accent: #087f8c; }
main, .tab-content, .day-journal { min-width: 0; }
button, summary, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 3px solid #0891b2;
  outline-offset: 3px;
}
.day-settings-summary { display: none; }
.modal-backdrop { z-index: 60; }
.modal-backdrop > div {
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}
body.overlay-open { overflow: hidden; }

/* Шапка помещается и на планшетах с семью разделами. */
@media (min-width: 768px) and (max-width: 1535px) {
  .crm-header .header-inner { height: auto; min-height: 64px; flex-wrap: wrap; gap: 12px; padding-block: 12px; }
  #nav-tabs { order: 3; width: 100%; overflow-x: auto; }
  #nav-tabs button { white-space: nowrap; flex-shrink: 0; }
}

@media (min-width: 768px) {
  /* Обе чаши видны после перехода с мобильного на широкий экран. */
  #big-pool-column, #small-pool-column { display: flex; }
}

@media (max-width: 767px) {
  body { background: #edf5f6; }
  .crm-header { padding-top: env(safe-area-inset-top); box-shadow: 0 4px 18px #12394a0a; }
  .crm-header .header-inner { height: auto; padding: 12px 14px; flex-wrap: wrap; gap: 12px; }
  .header-brand { width: 100%; min-width: 0; }
  .header-brand > div:last-child { min-width: 0; }
  .header-brand p { font-size: 10px; margin-top: 5px; }
  .header-brand > div:first-child { background: var(--crm-accent); box-shadow: none; flex-shrink: 0; }
  .header-brand .text-lg { color: var(--crm-ink); }
  .crm-header .header-actions { width: 100%; display: grid; grid-template-columns: 44px 1fr 1fr; gap: 8px; }
  .header-actions > button { margin: 0 !important; min-height: 44px; justify-content: center; padding-inline: 8px; border-radius: 12px; }
  .header-search > span, .header-search > kbd { display: none; }
  .header-search svg { width: 18px; height: 18px; margin: 0; }
  .mobile-nav { padding: 7px 12px; gap: 6px; background: #f5fafb; scrollbar-width: none; }
  .mobile-nav::-webkit-scrollbar { display: none; }
  .mobile-nav button { margin: 0 !important; min-height: 44px; padding: 10px 14px; border-radius: 12px; flex-shrink: 0; border: 1px solid #e2ecef; }
  .tab-btn-m.active { color: #fff; background: var(--crm-ink); border-color: var(--crm-ink); }
  main { padding: 12px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  #tab-daily { gap: 12px; }
  .day-settings { border: 1px solid #d7e6e9; border-radius: 16px; background: #fff; }
  .day-settings-summary { display: flex; justify-content: space-between; align-items: center; min-height: 48px; padding: 12px 16px; color: var(--crm-ink); font-size: 13px; font-weight: 600; cursor: pointer; list-style: none; }
  .day-settings-summary::-webkit-details-marker { display: none; }
  .day-settings[open] .day-settings-summary span { transform: rotate(180deg); }
  .day-settings-content { padding: 0 10px 10px; }
  .day-settings-content > div { box-shadow: none; }
  .cal-day { min-height: 38px; aspect-ratio: auto; }
  .day-settings-content button { min-height: 36px; }
  #tab-daily .day-toolbar { padding: 16px 12px; background: #fff; }
  #tab-daily .day-date-navigation { width: 100%; flex-direction: column; align-items: stretch; gap: 12px; }
  .day-date-navigation > div { margin: 0 !important; }
  .day-date-navigation > div:first-child { order: 2; justify-content: space-between; }
  .day-date-navigation button { min-height: 40px; }
  #selected-date-title { font-size: 19px; color: var(--crm-ink); }
  .day-date-navigation p { font-size: 11px; margin-top: 5px; line-height: 1.5; }
  #tab-daily .day-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .day-actions button { min-height: 44px; justify-content: center; padding: 8px; font-size: 11px; }
  #tab-daily .day-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
  .day-metrics > span:first-child { grid-column: 1 / -1; }
  .day-metrics > span:not(:first-child) { padding: 8px; border-radius: 10px; font-size: 11px; flex-wrap: wrap; }
  #mobile-pool-selector button { min-height: 44px; font-size: 13px; }
  #big-pool-column, #small-pool-column { padding: 10px; }
  #big-pool-column > div:first-child, #small-pool-column > div:first-child { gap: 8px; }
  #big-pool-column h3, #small-pool-column h3 { font-size: 13px; }
  #big-pool-column p, #small-pool-column p { font-size: 10px; }
  #big-pool-occupancy, #small-pool-occupancy { flex-shrink: 0; }
  .yc-card { padding: 10px; min-height: 64px; }
  .yc-card > .slot-content { flex-wrap: wrap; gap: 10px; }
  .slot-details { flex: 1 1 100%; min-width: 0; }
  .slot-person { min-width: 0; flex: 1; }
  .slot-badges { flex-wrap: wrap; gap: 4px; }
  .slot-badges > * { margin: 0 !important; }
  .slot-actions { margin-left: auto; }
  .yc-card button { min-height: 40px; }
  .yc-status-empty > div { min-width: 0; gap: 8px; }
  .yc-status-empty > div > span:last-child { font-size: 10px; }
  .yc-status-empty > button { flex-shrink: 0; padding-inline: 6px; }
  #template-dow-buttons { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); width: 100%; gap: 2px; }
  #template-dow-buttons button { padding-inline: 0; min-height: 44px; margin: 0; }
  .tab-content:not(#tab-daily) { padding: 16px 12px; }
  .tab-content h2 { font-size: 18px; line-height: 1.4; }
  #tab-clients > div:first-child > div:last-child { flex-wrap: wrap; gap: 8px; }
  #tab-clients > div:first-child > div:last-child > * { margin: 0; width: 100%; }
  #clients-list-container > div, #waiting-list-container > div { min-width: 0; overflow-wrap: anywhere; }
  #clients-list-container .client-heading, #clients-list-container .child-summary { flex-wrap: wrap; gap: 8px; }
  #clients-list-container button, #waiting-list-container button, .tab-content > div:first-child button { min-height: 44px; }
  body > .modal-backdrop { padding: 8px; align-items: flex-end; }
  .modal-backdrop > div { max-height: calc(100dvh - env(safe-area-inset-top) - 16px); padding: 18px 16px; border-radius: 22px 22px 14px 14px; }
  .modal-backdrop > div > div:first-child { flex-shrink: 0; gap: 12px; }
  .modal-backdrop > div > div:first-child button { min-width: 44px; min-height: 44px; }
  .modal-backdrop form { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  #modal-client .grid-cols-3 { grid-template-columns: 1fr; }
  #modal-client .grid-cols-2 { grid-template-columns: 1fr; }
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="color"]), select, textarea { font-size: 16px !important; min-height: 44px; max-width: 100%; min-width: 0; }
  .modal-backdrop button { min-height: 44px; }
  #quick-drawer { padding-top: env(safe-area-inset-top); }
  #quick-drawer > div:last-child { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  #quick-drawer button, #drawer-call-btn { min-height: 44px; }
  #toast-container { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  #toast-container > div { max-width: 100%; }
  .spotlight-item { flex-wrap: wrap; gap: 8px; }
  .spotlight-item > div { min-width: 0; }
  .spotlight-item > div:first-child { width: 100%; overflow-wrap: anywhere; }
  .spotlight-item > div:first-child > div:last-child > div { flex-wrap: wrap; gap: 4px; }
}

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

@media print {
  .crm-header, .crm-sidebar, .mobile-nav, #toast-container, #quick-drawer, .modal-backdrop, .day-actions { display: none !important; }
  body, .crm-shell, .crm-workspace, #tab-daily { height: auto !important; overflow: visible !important; background: #fff !important; }
  .pool-columns { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 12px !important; padding: 0 !important; }
  .pool-card { box-shadow: none !important; border: 1px solid #cbd5e1 !important; break-inside: avoid; }
}

