/* style.css — все стили вынесены в CSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

body {
    display: flex;
    justify-content: center;
    padding: 0;
    background: #f8fafc;
}

.app-wrapper {
    width: 100%;
    background: white;
    margin: 0 auto;
    min-height: 100vh;
}

/* ----- Шапка ----- */
.header {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    background: white;
    border-bottom: 1px solid #e9edf2;
    gap: 0.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.toggle-group {
    display: flex;
    gap: 1.5rem;
    background: #f1f5f9;
    padding: 0.4rem 1rem;
    border-radius: 25px;
    flex-wrap: wrap;
    justify-content: center;
}

.toggle-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    border-radius: 30px;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    background: transparent;
    color: #1e293b;
    border: 2px solid transparent;
    user-select: none;
}

.toggle-option.active {
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border-color: #cbd5e1;
}

.color-dot {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.08);
}

.green-dot { background-color: #22c55e; }
.red-dot { background-color: #ef4444; }

/* ----- Сетка (таблица) ----- */
.schedule-container {
    overflow-x: auto;
    overflow-y: auto;
    margin: 0.5rem 0;
    background: #fafcff;
    position: relative;
    height: calc(100vh - 120px);
}

.schedule-grid {
    display: grid;
    position: relative;
}

/* ----- Десктопная версия (горизонтальная: дни — строки, время — колонки) ----- */
@media (min-width: 1401px) {
    .schedule-grid {
        grid-template-columns: 70px repeat(28, 1fr);
        min-width: 900px;
        width: 100%;
    }
    
    .schedule-container {
        height: auto;
        max-height: calc(100vh - 120px);
        overflow: auto;
    }
    
    .day-header {
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
        font-size: 0.85rem;
        padding: 0.5rem 0.2rem;
        background: #f8fafc;
        border-bottom: 2px solid #dce2ea;
        border-right: 2px solid #dce2ea;
        color: #0f172a;
        letter-spacing: 0.3px;
        min-height: 44px;
        position: sticky;
        left: 0;
        z-index: 10;
        background: #f8fafc;
        box-shadow: 2px 0 8px rgba(0,0,0,0.04);
    }
    
    .day-header.weekend {
        background: #c7f3fea0 !important;
        color: #0e4092;
    }
    
    .time-header {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        font-size: 0.875rem;
        font-weight: 600;
        color: #0f172a;
        background: #f8fafc;
        border-bottom: 2px solid #dce2ea;
        border-right: 1px solid #e2e8f0;
        padding: 0.2rem 0;
        min-height: 44px;
        line-height: 1.2;
        position: sticky;
        top: 0;
        z-index: 5;
        width: 100%;
    }
    
    .time-header.even-col {
        background-color: #f1f5f9;
    }
    
    .time-cell {
        height: 44px;
        border-bottom: 1px solid #edf2f7;
        border-right: 1px solid #edf2f7;
        background: white;
        cursor: pointer;
        transition: background 0.08s;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        font-size: 0.6rem;
        color: #94a3b8;
        user-select: none;
        position: relative;
        gap: 0;
        width: 100%;
    }
    
    .time-cell .start-label {
        font-weight: 500;
        font-size: 0.875rem;
        color: #64748b;
    }
    
    .time-cell.even-col {
        background-color: #f8fafc;
    }
    
    .time-cell.weekend {
        background-color: #ebfbff;
    }
    
    .time-cell.weekend.even-col {
        background-color: #c7f3fea0;
    }
}

/* ----- Мобильная версия (вертикальная: дни — колонки, время — строки) ----- */
@media (max-width: 1400px) {
    .schedule-grid {
        grid-template-columns: 70px repeat(7, 1fr);
        min-width: 500px;
        width: 100%;
    }
    
    .schedule-container {
        height: calc(100vh - 120px);
        overflow: auto;
    }
    
    /* Заголовок строки (время) */
    .time-header {
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
        font-size: 0.8rem;
        color: #0f172a;
        background: #f8fafc;
        border-bottom: 1px solid #dce2ea;
        border-right: 2px solid #dce2ea;
        padding: 0.2rem 0.5rem;
        min-height: 44px;
        position: sticky;
        left: 0;
        z-index: 10;
        background: #f8fafc;
        box-shadow: 2px 0 8px rgba(0,0,0,0.04);
        width: 70px;
    }
    
    .time-header.even-col {
        background-color: #f1f5f9;
    }
    
    /* Заголовок колонки (день) */
    .day-header {
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
        font-size: 0.8rem;
        padding: 0.5rem 0.2rem;
        background: #f8fafc;
        border-bottom: 2px solid #dce2ea;
        border-right: 1px solid #e2e8f0;
        color: #0f172a;
        letter-spacing: 0.3px;
        min-height: 44px;
        position: sticky;
        top: 0;
        z-index: 5;
        background: #f8fafc;
    }
    
    .day-header.weekend {
        background: #c7f3fea0 !important;
        color: #0e4092;
    }
    
    /* Ячейка времени */
    .time-cell {
        height: 44px;
        border-bottom: 1px solid #edf2f7;
        border-right: 1px solid #edf2f7;
        background: white;
        cursor: pointer;
        transition: background 0.08s;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        font-size: 0.6rem;
        color: #94a3b8;
        user-select: none;
        position: relative;
        gap: 0;
        width: 100%;
    }
    
    .time-cell .start-label {
        font-weight: 500;
        font-size: 0.7rem;
        color: #64748b;
    }
    
    .time-cell.even-col {
        background-color: #f8fafc;
    }
    
    .time-cell.weekend {
        background-color: #ebfbff;
    }
    
    .time-cell.weekend.even-col {
        background-color: #c7f3fea0;
    }
}

/* Цветовые состояния – только через классы */
.time-cell.green {
    background-color: #bbf7d0 !important;
}
.time-cell.red {
    background-color: #fecaca !important;
}

.time-cell.green .start-label,
.time-cell.red .start-label {
    color: #1e293b;
    opacity: 1;
}

/* Информационная панель */
.info-panel {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    background: white;
    border-top: 1px solid #e9edf2;
}

.btn-info {
    background: white;
    border: 1px solid #cbd5e1;
    padding: 0.5rem 1.2rem;
    border-radius: 30px;
    font-size: 0.9rem;
    color: #1e293b;
    cursor: pointer;
    transition: 0.1s;
    font-weight: 500;
}
.btn-info:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}
.btn-info:active {
    background: #e2e8f0;
}

/* Адаптивность для очень маленьких экранов */
@media (max-width: 600px) {
    .toggle-group {
        gap: 0.5rem;
        padding: 0.3rem 0.5rem;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }
    
    .toggle-option {
        justify-content: center;
        font-size: 0.85rem;
        padding: 0.3rem 0.5rem;
    }
    
    .header {
        padding: 0.5rem;
    }
    
    .schedule-grid {
        grid-template-columns: 60px repeat(7, 1fr);
        min-width: 360px;
    }
    
    .time-header {
        font-size: 0.7rem;
        min-height: 36px;
        width: 60px;
        padding: 0.2rem 0.3rem;
    }
    
    .day-header {
        font-size: 0.7rem;
        min-height: 36px;
        padding: 0.3rem 0.1rem;
    }
    
    .time-cell {
        height: 36px;
    }
    
    .time-cell .start-label {
        font-size: 0.6rem;
    }
}

/* Дополнительные стили для админской версии */

/* Стили для ячеек админа */
.admin-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 44px;
    font-size: 0.75rem;
    padding: 2px;
}

.admin-cell .stat-green {
    color: #16a34a;
    font-weight: 800;
    font-size: 0.8rem;
}

.admin-cell .stat-red {
    color: #dc2626;
    font-weight: 800;
    font-size: 0.8rem;
}

.admin-cell .stat-empty {
    color: #94a3b8;
    font-size: 0.7rem;
}

/* Адаптивность для админских ячеек */
@media (max-width: 768px) {
    .admin-cell {
        min-height: 36px;
        font-size: 0.65rem;
        gap: 1px;
    }
    
    .admin-cell .stat-green,
    .admin-cell .stat-red {
        font-size: 0.65rem;
    }
}

@media (max-width: 600px) {
    .admin-cell {
        min-height: 32px;
        font-size: 0.55rem;
        gap: 0px;
    }
    
    .admin-cell .stat-green,
    .admin-cell .stat-red {
        font-size: 0.55rem;
    }
}

/* Стили для всплывающих подсказок админа */
.admin-tooltip {
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  padding: 16px 20px;
  max-width: 300px;
  min-width: 200px;
  z-index: 1000;
  border: 1px solid #e2e8f0;
  pointer-events: auto;
    will-change: transform, opacity;
    backface-visibility: hidden;
}

/* Для десктопа - убираем задержку при наведении */
@media (hover: hover) {
    .admin-tooltip {
        transition: opacity 0.12s ease;
  }
}

.tooltip-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tooltip-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tooltip-label {
  font-weight: 600;
  font-size: 0.8rem;
  color: #475569;
  padding-bottom: 2px;
  border-bottom: 2px solid #e2e8f0;
}

.tooltip-green .tooltip-label {
  color: #16a34a;
  border-bottom-color: #86efac;
}

.tooltip-red .tooltip-label {
  color: #dc2626;
  border-bottom-color: #fca5a5;
}

.tooltip-names {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  padding-top: 4px;
}

.tooltip-name {
  font-size: 0.85rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f8fafc;
  white-space: nowrap;
}

.green-name {
  color: #16a34a;
  background: #dcfce7;
}

.red-name {
  color: #dc2626;
  background: #fee2e2;
}

/* Для мобилок - увеличиваем отступы */
@media (max-width: 768px) {
  .admin-tooltip {
    max-width: 250px;
    min-width: 160px;
    padding: 12px 16px;
  }
  
  .tooltip-name {
    font-size: 0.75rem;
    padding: 2px 4px;
  }
}

.clients-list-container {
    margin: 20px 0;
    padding: 16px;
    background: white;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.clients-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
}

.clients-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 300px;
    overflow-y: auto;
}

.clients-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 10px;
    border-radius: 6px;
    background: #f8fafc;
    transition: background 0.15s;
    flex-wrap: wrap;
}

.clients-item:hover {
    background: #f1f5f9;
}

.clients-name {
    font-weight: 500;
    color: #0f172a;
    min-width: 130px;
    font-size: 0.9rem;
}

.clients-stats {
    display: flex;
    gap: 8px;
    min-width: 70px;
}

.clients-stats .stat-green {
    color: #16a34a;
    font-weight: 600;
}

.clients-stats .stat-red {
    color: #dc2626;
    font-weight: 600;
}

.clients-times {
    flex: 1;
    min-width: 150px;
    font-size: 0.8rem;
}

.clients-times .times-green {
    color: #16a34a;
}

.clients-times .times-red {
    color: #dc2626;
}

.clients-total {
    color: #64748b;
    font-size: 0.8rem;
    white-space: nowrap;
}

.clients-empty {
    text-align: center;
    color: #94a3b8;
    padding: 20px 0;
}

/* Адаптивность для мобилок */
@media (max-width: 768px) {
    .clients-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .clients-name {
        min-width: auto;
        font-size: 0.85rem;
    }

    .clients-times {
        font-size: 0.7rem;
        min-width: auto;
        width: 100%;
    }

    .clients-total {
        font-size: 0.75rem;
    }
}