/* manager.css (only manager-page layout + manager-specific UI)
   ВАЖНО: никаких глобальных переопределений body/.btn/.container — это уже есть в app.css + black.css/white.css.
*/

/* ========== Helpers ========== */
.visually-hidden{
  position:absolute;
  width:1px;height:1px;
  padding:0;margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}
/* скрытое поле для мини‑календаря */
.visually-hidden#mgr-date{
  position:absolute;
  width:1px;height:1px;
  padding:0;margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}

/* ========== Top admin panel (2 rows) ========== */
.mgr-adminpanel{
  display:flex;
  flex-direction:column;
  gap:8px;
  align-items:stretch;
  margin-top:8px;
}

.mgr-adminpanel-main{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
}

.mgr-adminpanel-left{
  flex:1 1 auto;
  min-width:0;
}

.mgr-adminpanel-logo{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  justify-content:flex-end;
}

.mgr-inner-logo{
  display:block;
  height:34px;
  width:auto;
}

.mgr-adminpanel-row{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  justify-content:flex-start;
  align-items:center;
}

.mgr-toolbar{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
  justify-content:flex-start;
}

.mgr-parent-btn{
  padding:10px 12px;
  font-weight:700;
}

/* current parent page: subtle emphasis */
.mgr-parent-btn[aria-current="page"]{
  box-shadow: inset 0 -2px 0 currentColor;
  opacity:.92;
}


.mgr-child-btn{
  padding:8px 10px;
}

/* inline hint after child buttons */
.mgr-actions-hint-inline{
  margin-left:10px;
  opacity:.65;
  white-space:nowrap;
}
.mgr-nav-btn2{
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  gap:8px;
  min-height:38px;
  line-height:1;
  padding-left:12px;
  padding-right:12px;
}

/* иконки‑кнопки действий */
.mgr-action-btn{
  padding:4px 6px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:4px;
}
.mgr-action-icon{
  width:18px;
  height:18px;
  display:block;
}

/* disabled — должны быть видимыми в обеих темах */
.mgr-action-btn[disabled]{
  cursor:default;
}
html[data-theme="white"] .mgr-action-btn[disabled] .mgr-action-icon{
  filter: grayscale(1) brightness(0.75);
}
html[data-theme="black"] .mgr-action-btn[disabled] .mgr-action-icon{
  filter: invert(1) grayscale(1) brightness(0.75);
}

/* ========== Hint (inline, after action buttons) ========== */
.mgr-actions-hint{
  font-size:12px;
  line-height:1;
  user-select:none;
}
/* ========== Role toggles (manager/admin) — визуально как “Актуальные/Архив” ========== */
.mgr-role-group{
  display:grid;
  grid-template-columns:max-content max-content;
  gap:12px;
  align-items:stretch;
  justify-content:flex-start;
}
.mgr-role-option{
  display:flex;
  align-items:center;
  min-height:38px;
  gap:8px;
  cursor:pointer;
  user-select:none;
  color: var(--ink);
}
.mgr-role-option input{
  position:absolute;
  opacity:0;
  pointer-events:none;
}
.mgr-role-box{
  width:14px;
  height:14px;
  border-radius:3px;
  border:1px solid currentColor;
  flex-shrink:0;
  display:inline-block;
  background: transparent;
}
.mgr-role-text{
  opacity:.8;
}
.mgr-role-option input:checked + .mgr-role-box{
  background: currentColor;
}
.mgr-role-option input:checked ~ .mgr-role-text{
  opacity:1;
  font-weight:600;
}

@media (max-width:720px){
  .mgr-role-group{ grid-template-columns:1fr; }
  .mgr-actions-hint-inline{ white-space:normal; margin-left:0; flex-basis:100%; }
}

/* ========== Bottom mode toggles (active/archive) — только “в ряд и ровно” ========== */
.mgr-mode-group{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  align-items:stretch;
}
.mgr-mode-option{
  display:flex;
  align-items:center;
  min-height:38px;
  gap:8px;
  cursor:pointer;
  user-select:none;
  color: var(--ink);
}
@media (max-width:720px){
  .mgr-mode-group{ grid-template-columns:1fr; }
}

/* ========== Date label + date navigation row (центр) ========== */
.mgr-date-label{
  width:100%;
  text-align:center;
  font-weight:800;
  line-height:1.15;
  margin:10px 0 10px;
  font-size: clamp(20px, 3.2vw, 56px);
}

.mgr-caption-nav{
  width:100%;
  display:flex;
  justify-content:center;
}

.mgr-date-nav{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px;
  flex-wrap:wrap;
}

/* Кнопка‑иконка календаря: одинаковая высота с кнопками */
.manager-date-box{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:44px;
  height:44px;
  padding:0;
  margin:0;
  border-radius:12px;
  cursor:pointer;
  user-select:none;
  border:1px solid var(--line);
  background: color-mix(in srgb, var(--ink) 6%, transparent);
}
.manager-date-icon{
  width:22px;
  height:22px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

/* ========== Manager table: zebra/hover/selected (theme tokens) ========== */
.grid tbody tr:nth-child(odd){ background: var(--tile); }
.grid tbody tr:nth-child(even){ background: var(--tile2); }

.grid tbody tr:hover{
  background: color-mix(in srgb, var(--accent) 6%, var(--tile2));
  cursor:pointer;
}

.grid tbody tr.selected{
  background: color-mix(in srgb, var(--accent) 18%, var(--tile));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 50%, transparent);
}

/* footer count: читаемо в тёмной теме */
html[data-theme="black"] .table-footer .muted{ color: color-mix(in srgb, var(--ink) 80%, transparent); }
html[data-theme="black"] .table-footer .muted b{ color: var(--ink); }

/* ========== Responsive: table -> cards ========== */
@media (max-width:900px){
  /* fix adaptive: ensure grid wrapper stretches full width (cards were shrinking to max-content) */
  .manager-page .wrap{ grid-template-columns:minmax(0,1fr); justify-items:stretch; }
  .manager-page .wrap > *{ width:100%; }

  .grid thead{ display:none; }

  .manager-table .table-wrap{
    width:100%;
    margin:0;
    padding:0;
    border:none;
    background:none;
  }

  .grid tbody tr{
    display:block;
    width:100%;
    margin-bottom:12px;
    border-radius:12px;
    overflow:hidden;
    border:1px solid var(--line);
    background: var(--tile);
  }

  .grid tbody tr:nth-child(odd),
  .grid tbody tr:nth-child(even){
    background: var(--tile);
  }

  .grid tbody td{
    display:block;
    width:100%;
    padding:6px 10px;
    box-sizing:border-box;
    border-bottom:1px solid var(--line);
    font-size:14px;
    text-align:left;
  }

  .grid tbody td:last-child{ border-bottom:none; }

  /* “Телефон: +7...” */
  .grid tbody td{
    overflow-wrap:anywhere;
    word-break:break-word;
  }

  .grid tbody td::before{
    content: attr(data-col);
    font-weight:600;
    opacity:0.85;
    display:block;
    margin:0 0 2px 0;
  }

  .cell-time{ font-size:15px; font-weight:700; }
}

/* ========== Edit modal ========== */
.mgr-modal-backdrop[hidden]{ display:none; }
.mgr-modal-backdrop{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,.5);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:5000;
}
.mgr-modal{
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 18px 20px 16px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 18px 45px rgba(0,0,0,0.35);
  color: var(--ink);
}
.mgr-modal__header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:12px;
}
.mgr-modal__header h2{ margin:0; font-size:18px; }
.mgr-modal__close{
  border:none;
  background:transparent;
  color: var(--muted);
  font-size:20px;
  cursor:pointer;
}
.mgr-modal__body{
  display:flex;
  flex-direction:column;
  gap:10px;
}
.mgr-field{
  display:flex;
  flex-direction:column;
  gap:4px;
}
.mgr-field label{ font-size:13px; color: var(--muted); }
.mgr-field input,
.mgr-field textarea{
  background: var(--tile);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--ink);
  font: inherit;
}
.mgr-modal__footer{
  margin-top:12px;
  display:flex;
  justify-content:flex-end;
  gap:10px;
}

/* ========== Print ========== */
.mgr-print{ display:none; font-size:15px; }
.mgr-print__header,
.mgr-print__body,
.mgr-print__footer{ page-break-inside:avoid; }

.mgr-print__header{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  margin-bottom:10mm;
  border-bottom:1px solid #000;
  padding-bottom:4mm;
}
.mgr-print__logo-wrap{ max-width:120px; }
.mgr-print__logo{ max-width:100%; height:auto; }
.mgr-print__head-text{ text-align:right; }
.mgr-print__label{
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.05em;
  margin-bottom:2mm;
}
.mgr-print__date{ font-size:20px; font-weight:700; }

.mgr-print__title{
  text-align:center;
  font-size:18px;
  font-weight:700;
  margin:0 0 12px;
  text-transform:uppercase;
  letter-spacing:.4px;
}

.mgr-print__table{
  width:100%;
  border-collapse:collapse;
  margin-bottom:8mm;
}
.mgr-print__table th{
  border:1px solid #000;
  padding:3mm 2mm;
  text-align:center;
  background:#f2f2f2;
  font-weight:600;
}
.mgr-print__table td{
  border:1px solid #000;
  padding:2mm 2mm;
  text-align:left;
}
.mgr-print__footer{
  margin-top:8mm;
  border-top:1px solid #000;
  padding-top:4mm;
  font-size:12px;
}
.mgr-print__promo{ font-style:italic; opacity:.85; }


@media (max-width:720px){
  .mgr-adminpanel-main{
    flex-direction:column;
    align-items:stretch;
  }
  .mgr-adminpanel-logo{
    justify-content:flex-start;
    order:-1;
  }
  .mgr-inner-logo{
    height:30px;
  }
}

@media print{
  body *{ visibility:hidden !important; }
  #mgr-print, #mgr-print *{ visibility:visible !important; }
  #mgr-print{
    display:block !important;
    position:absolute;
    inset:0;
    padding:15mm 12mm;
    background:#fff;
    color:#000;
  }
}
@media print{
  /* Логотип: принудительно печатаем и не даём схлопнуться */
  #mgr-print .mgr-print__logo-wrap{
    display:block !important;
    visibility:visible !important;
    min-height: 1px !important;
    margin-bottom: 6mm !important;
  }
  #mgr-print .mgr-print__logo-wrap img{
    display:block !important;        /* ключевой момент */
    visibility:visible !important;
    opacity:1 !important;
    max-height: 90px !important;
    max-width: 240px !important;
    width:auto !important;
    height:auto !important;
    object-fit:contain !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

@media print {
  .mgr-print__table th,
  .mgr-print__table td{
    text-align:center;
    font-size:14px;
  }
}
.mgr-print__table th,
.mgr-print__table td{
  text-align: center;
  vertical-align: middle;
  font-size: 14px;
}

.mgr-print__table th{
  font-weight: 600;
}

/* Логотип всегда слева + автонормализация размеров */
.mgr-print__logo-wrap{
  text-align: left !important;
}

.mgr-print__logo-wrap img{
  display: inline-block;
  max-height: 90px;     /* можно 70–110 по вкусу */
  max-width: 240px;     /* ограничение по ширине */
  width: auto;
  height: auto;
  object-fit: contain;
}

/* На экране печатный блок всегда скрыт */
/* На экране печатный шаблон скрыт всегда */
#mgr-print {
  display: none !important;
}

/* Только при печати */
@media print {
  #mgr-print {
    display: block !important;
  }
}




/* Print layout: keep footer at bottom of page */
@media print{
  #mgr-print{
    display:flex !important;
    flex-direction:column !important;
    min-height:100vh !important;
  }
  #mgr-print .mgr-print__body{
    flex:1 1 auto !important;
  }
  #mgr-print .mgr-print__footer{
    margin-top:auto !important;
    padding-top:6mm;
    border-top:1px solid #ddd;
  }
}


/* ========== Cosmetic marathon: unify toggle controls + tame big date title ========== */

/* Make bottom mode toggles (active/archive) look exactly like top role toggles */
.mgr-mode-option{
  position: relative;
  display:flex;
  align-items:center;
  min-height:38px;
  gap:8px;
  cursor:pointer;
  user-select:none;
  color: var(--ink);
}

/* hide native radio */
.mgr-mode-option input{
  position:absolute;
  opacity:0;
  pointer-events:none;
}

/* box identical to mgr-role-box */
.mgr-mode-box{
  width:14px;
  height:14px;
  border-radius:4px;
  border:1px solid color-mix(in srgb, var(--ink) 22%, transparent);
  background: transparent;
  display:inline-block;
  flex:0 0 auto;
}

.mgr-mode-text{
  opacity:.8;
}

.mgr-mode-option input:checked + .mgr-mode-box{
  background: currentColor;
}

.mgr-mode-option input:checked ~ .mgr-mode-text{
  opacity:1;
  font-weight:600;
}

/* Place the active/archive options on the left, closer to each other */
.mgr-mode-group{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:18px;
  width:100%;
}

/* Date label: reduce ~40% (keeps responsive clamp) */
.mgr-date-label{
  font-size: clamp(16px, 2.0vw, 34px);
  margin: 12px 0 10px;
}

/* =====================================================
   WHITE THEME OVERRIDES (manager page)
   ===================================================== */

/* manager.white-fix.css
   White-theme cosmetics for manager buttons.
   Goal: avoid black "dark-style" buttons on light background.
*/
html[data-theme="white"] .manager-page .btn,
html[data-theme="white"] .manager-page a.btn,
html[data-theme="white"] .manager-page button.btn{
  background: var(--tile);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}

html[data-theme="white"] .manager-page .btn:hover,
html[data-theme="white"] .manager-page a.btn:hover,
html[data-theme="white"] .manager-page button.btn:hover{
  background: color-mix(in srgb, var(--ink) 6%, var(--tile));
}

html[data-theme="white"] .manager-page .btn:active,
html[data-theme="white"] .manager-page a.btn:active,
html[data-theme="white"] .manager-page button.btn:active{
  background: color-mix(in srgb, var(--ink) 10%, var(--tile));
}

html[data-theme="white"] .manager-page .btn[disabled],
html[data-theme="white"] .manager-page button.btn:disabled{
  opacity: .55;
  cursor: default;
}

/* Date picker chip (label that acts like button) */
html[data-theme="white"] .manager-page .manager-date-box{
  background: var(--tile);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}
html[data-theme="white"] .manager-page .manager-date-box:hover{
  background: color-mix(in srgb, var(--ink) 6%, var(--tile));
}

/* Icon buttons group: keep icons readable in light theme */
html[data-theme="white"] .manager-page .mgr-action-btn{
  background: var(--tile);
  border: 1px solid var(--line);
  color: var(--ink);
}

/* ==========================================================
   LOCK: manager-page button colors in WHITE theme
   (manager.css is also used on print-settings.html, so scope strictly!)
   ========================================================== */

html[data-theme="white"] .manager-page .btn,
html[data-theme="white"] .manager-page .mgr-action-btn,
html[data-theme="white"] .manager-page .mgr-nav-btn2,
html[data-theme="white"] .manager-page .mgr-date-nav .btn,
html[data-theme="white"] .manager-page .manager-date-box{
  background: #f3f5f8;
  border: 1px solid #dbe3ee;
  color: #0b1a2a;
}

html[data-theme="white"] .manager-page .btn:hover,
html[data-theme="white"] .manager-page .mgr-action-btn:hover,
html[data-theme="white"] .manager-page .mgr-nav-btn2:hover,
html[data-theme="white"] .manager-page .manager-date-box:hover{
  background: #eef2f7;
}

/* disabled — чтобы не “чернело” и читалось */
html[data-theme="white"] .manager-page .btn:disabled,
html[data-theme="white"] .manager-page .mgr-action-btn[disabled]{
  background: #f3f5f8;
  border-color: #dbe3ee;
  color: #7a8796;
}

/* ========== Cosmetic: рамка для нижней части страницы менеджера (ПК) ========== */
/* По ТЗ: на ПК рамка есть, в адаптиве (текущий брейкпоинт) рамки нет. */
.manager-table .mgr-frame{
  border: 1px solid var(--line, #d9d9d9);
  background: var(--panel, #fff);
  border-radius: 10px;
  padding: 14px;
  margin-top: 14px;
}

@media (max-width:720px){
  .manager-table .mgr-frame{
    border: none;
    background: transparent;
    border-radius: 0;
    padding: 0;
    margin-top: 0;
  }
}


/* === Mobile: keep date controls (prev / today / next / calendar) on one line === */
@media (max-width: 520px){
  .mgr-date-nav{
    flex-wrap:nowrap;
    gap:8px;
  }
  .mgr-date-nav .btn{
    padding-left:10px;
    padding-right:10px;
    height:36px;
    border-radius:10px;
  }
  .mgr-date-nav .manager-date-box{
    width:38px;
    height:36px; /* align with buttons */
    border-radius:10px;
  }
  .mgr-date-nav .manager-date-icon{
    width:20px;
    height:20px;
  }
}
@media (max-width: 380px){
  .mgr-date-nav{ gap:6px; }
  .mgr-date-nav .btn{ padding-left:8px; padding-right:8px; }
  .mgr-date-nav .manager-date-box{ width:36px; }
}
