/* === iiko-style Light Theme === */
:root {
  --iiko-blue: #0d47a1;
  --iiko-blue-light: #1565c0;
  --iiko-orange: #ff6f00;
  --bg-main: #f0f4f8;
  --bg-card: #ffffff;
  --text-primary: #1a2332;
  --text-secondary: #5a6a7a;
  --border-light: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --radius: 14px;
  --radius-sm: 10px;
}

body {
  background-color: var(--bg-main) !important;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* === Logo === */
.logo-box {
  background: var(--iiko-orange);
  color: white;
  padding: 3px 10px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.5px;
}

/* === Navbar === */
.navbar { background-color: var(--iiko-blue) !important; box-shadow: 0 2px 8px rgba(13,71,161,0.15); }
.navbar-brand { font-weight: 600; }
.navbar .nav-link { font-size: 0.95rem; padding: 0.5rem 1rem; }
.navbar-toggler { border: none; padding: 4px 8px; }
.navbar-toggler:focus { box-shadow: none; }

/* === Плитки сценариев === */
.card-action {
  border: none !important;
  border-radius: var(--radius);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  position: relative;
}
.card-action:hover { transform: translateY(-3px); box-shadow: var(--shadow-md) !important; }
.card-action .card-body { padding: 1.25rem; }
.card-action .card-title { font-weight: 600; font-size: 1.05rem; }
.card-action .badge { font-size: 0.75rem; padding: 0.4em 0.75em; border-radius: 6px; font-weight: 600; }
.card-action .arrow-icon { color: var(--text-secondary); opacity: 0.5; font-size: 1.1rem; }
.card-action:hover .arrow-icon { opacity: 1; color: var(--iiko-blue); }

/* === Кнопки — крупные для тача === */
.btn { border-radius: var(--radius-sm); font-weight: 500; }
.btn-primary { background-color: var(--iiko-blue); border-color: var(--iiko-blue); }
.btn-primary:hover { background-color: var(--iiko-blue-light); border-color: var(--iiko-blue-light); }
.btn-lg { font-size: 1.05rem; padding: 0.75rem 1.5rem; border-radius: var(--radius-sm); }

/* === Формы — крупные поля === */
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-light);
  padding: 0.65rem 0.9rem;
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-control:focus, .form-select:focus {
  border-color: var(--iiko-blue);
  box-shadow: 0 0 0 3px rgba(13,71,161,0.12);
}
.form-label { font-weight: 500; color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 0.35rem; }
.form-check-input { width: 1.3em; height: 1.3em; margin-top: 0.15em; }

/* Переключатели не должны быть квадратными — возвращаем форму бегунка */
.form-switch .form-check-input {
  width: 2.5em;
  height: 1.3em;
  margin-top: 0.15em;
  background-position: left center;
  transition: background-position .15s ease-in-out;
}
.form-switch .form-check-input:checked {
  background-position: right center;
}

.form-check-label { padding-left: 0.3em; }

/* === Карточки === */
.card {
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

/* === Таблицы === */
.table { font-size: 0.95rem; }
.table thead th {
  font-weight: 600; color: var(--text-secondary);
  font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.3px;
  border-bottom: 2px solid var(--border-light); padding: 0.75rem 0.5rem;
}
.table tbody td { padding: 0.65rem 0.5rem; vertical-align: middle; }
.table tbody tr:hover { background-color: rgba(13,71,161,0.03); }

/* === Alert === */
.alert { border-radius: var(--radius-sm); font-size: 0.95rem; }

/* === Строки товаров === */
.product-row { transition: background-color 0.1s ease; border-radius: 6px; }
.product-row:hover { background-color: rgba(13,71,161,0.04); }

/* === Папки категорий === */
.category-folder summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  padding: 6px 8px;
  border-radius: 6px;
  background: #f8f9fb;
  font-size: 0.9rem;
}
.category-folder summary::-webkit-details-marker { display: none; }
.category-folder summary:hover { background: #eef2f7; }
.category-folder[open] > summary { background: #e8eef5; margin-bottom: 4px; }

/* === Global Loader === */
.global-loader {
  position: fixed; inset: 0; background: rgba(255,255,255,0.85); z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.toast-container { z-index: 10000; }

/* === Login / Register === */
.login-wrap { display: flex; justify-content: center; align-items: center; min-height: 60vh; }
.login-card { width: 100%; max-width: 400px; border-radius: var(--radius); box-shadow: var(--shadow-md); overflow: hidden; }
.login-card .card-header {
  background: var(--iiko-blue); color: white; text-align: center;
  padding: 1.5rem; font-size: 1.2rem; font-weight: 600;
}
.login-card .logo-box { font-size: 1.5rem; padding: 5px 14px; }

/* === Mobile-first адаптация (телефоны) === */
@media (max-width: 768px) {
  body { font-size: 16px; }  /* iOS не зумит при 16px */
  .container { padding-left: 10px; padding-right: 10px; }
  h3 { font-size: 1.25rem; }
  h6 { font-size: 1rem; }

  .navbar-brand { font-size: 1rem; }
  .navbar .nav-link { padding: 0.6rem 1rem; font-size: 1rem; }
  .navbar-collapse { background: rgba(0,0,0,0.15); border-radius: 8px; margin-top: 8px; padding: 4px; }

  .card-action .card-body { padding: 1rem; }
  .card-action .card-title { font-size: 1rem; }

  /* Таблица товаров → карточки */
  .table-cards {
    display: block;
  }
  .table-cards thead { display: none; }
  .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr {
    border: 1px solid var(--border-light);
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 10px 12px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  }
  .table-cards tr:hover { background: #fff; }
  .table-cards td {
    border: none !important;
    padding: 3px 0 !important;
  }
  .table-cards td[data-label]:before {
    content: attr(data-label) ': ';
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
    min-width: 80px;
  }
  .table-cards td.cell-input { margin-top: 6px; }
  .table-cards td.cell-input input {
    max-width: 100% !important;
    height: 42px;
    font-size: 1.05rem;
    text-align: center;
  }

  /* Крупные кнопки на мобильном */
  .btn-lg { font-size: 1rem; padding: 0.75rem 1rem; }
  .d-grid { width: 100%; }
  .d-grid .btn { width: 100%; }
}

/* Very small phones */
@media (max-width: 400px) {
  .logo-box { font-size: 0.9rem; padding: 2px 7px; }
  .card-action .card-title { font-size: 0.95rem; }
}

/* Плавные переходы */
a { transition: color 0.15s ease; }

/* Убираем outline при тапе на телефон */
button, a, input, select { -webkit-tap-highlight-color: transparent; }

/* === Календарь смен === */
.attendance-calendar {
  border: 1px solid var(--border-light);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.cal-head {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: #f0f4f8;
}
.cal-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-top: 1px solid var(--border-light);
}
.cal-cell {
  padding: 8px 6px;
  min-height: 70px;
  border-right: 1px solid var(--border-light);
  font-size: 0.85rem;
}
.cal-cell:last-child { border-right: none; }
.cal-head-cell {
  text-align: center;
  font-weight: 600;
  color: var(--text-secondary);
  min-height: auto;
  padding: 8px 4px;
  font-size: 0.8rem;
  text-transform: uppercase;
}
.cal-empty { background: #fafbfc; }
.cal-day {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 3px;
}
.cal-has-shift {
  background: #e8f5e9;
}
.cal-has-shift .cal-day {
  color: #2e7d32;
}
.cal-shift {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 0.75rem;
  line-height: 1.2;
}
.cal-time {
  color: #2e7d32;
  font-weight: 600;
}
.cal-hours {
  color: #558b2f;
}

@media (max-width: 480px) {
  .cal-cell { min-height: 55px; padding: 5px 3px; font-size: 0.75rem; }
  .cal-day { font-size: 0.8rem; }
  .cal-shift { font-size: 0.65rem; }
}


/* ============================================================
   Этап 1 — дополнения к дизайн-системе
   ============================================================ */

/* Навбар */
.app-navbar {
  background-color: var(--iiko-blue) !important;
  box-shadow: 0 2px 8px rgba(13,71,161,0.15);
  padding-top: 6px;
  padding-bottom: 6px;
}
.app-navbar .navbar-brand {
  font-weight: 700;
  letter-spacing: 0.2px;
}
.app-navbar .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.92rem;
  padding: 8px 12px !important;
  border-radius: 8px;
  transition: background .15s;
}
.app-navbar .nav-link:hover {
  background: rgba(255,255,255,0.08);
}
.app-navbar .nav-link.active {
  background: rgba(255,255,255,0.15);
  font-weight: 600;
}
.app-navbar .nav-profile-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 992px) {
  .app-navbar .nav-link {
    padding: 10px 14px !important;
    justify-content: flex-start;
  }
  .app-navbar .nav-profile-name {
    max-width: none;
  }
  .app-navbar .navbar-collapse {
    background: rgba(0,0,0,0.15);
    border-radius: 10px;
    margin-top: 8px;
    padding: 6px;
  }
}

/* Бейдж-счётчик */
.badge-counter {
  position: absolute;
  top: 2px;
  right: -2px;
  background: #dc2626;
  color: #fff;
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  text-align: center;
  line-height: 1.2;
  border: 2px solid var(--iiko-blue);
}

/* Flash-сообщения в основной части */
.alert-dismissible .btn-close {
  padding: 0.5rem;
  background-size: 0.7em;
}

/* Skeleton — плейсхолдеры загрузки */
.skeleton {
  display: block;
  background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.2s ease-in-out infinite;
  border-radius: 6px;
  height: 1em;
  width: 100%;
}
.skeleton-sm { height: 0.7em; width: 60%; }
.skeleton-lg { height: 1.8em; }
@keyframes skeleton-loading {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Страницы 404 / 500 */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: 40px 20px;
}
.error-page .err-code {
  font-size: 6rem;
  font-weight: 800;
  line-height: 1;
  color: var(--iiko-blue);
  opacity: 0.15;
}
.error-page .err-icon {
  font-size: 3.5rem;
  color: var(--iiko-blue);
  margin-top: -20px;
}
.error-page h1 {
  font-size: 1.5rem;
  margin-top: 16px;
  color: var(--text-primary);
}
.error-page p {
  color: var(--text-secondary);
  max-width: 480px;
  margin-top: 8px;
}
.error-page .btn {
  margin-top: 24px;
  min-width: 180px;
}

/* Улучшенные кнопки */
.btn {
  font-weight: 500;
  transition: all 0.12s ease;
}
.btn:active {
  transform: scale(0.98);
}

/* Улучшенные заголовки страниц */
h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 600;
}
h3 { font-size: 1.4rem; }
@media (max-width: 768px) {
  h3 { font-size: 1.2rem; }
}

/* Убираем дефолтный серый от Bootstrap bg-light в пользу нашего */
body.bg-light { background-color: var(--bg-main) !important; }

/* Компактные бейджи-статусы */
.badge {
  font-weight: 600;
  letter-spacing: 0.2px;
  padding: 0.35em 0.65em;
  border-radius: 6px;
}
