/* SOUBOR: css/layout-blocks.css (v3.3 – 2026-02-17) */
/* POPIS: Rozložení bloků: Header, KPI, Tabulky, Modály, Login, Profil modal. */

/* --- 0. DESKTOP LAYOUT --- */
/* Mobil: stacked (flex column) - kalendář nahoře, admin statistiky dole */
/* Desktop (1024px+): grid 2 sloupce - kalendář vlevo, admin statistiky vpravo */
/* Brigadník: admin-dashboard má class "hidden" → grid se chová jako single column */
.desktop-layout {
  display: flex;
  flex-direction: column;
}

/* Desktop breakpoint - grid 2 sloupce (aktivní pouze když admin-dashboard je viditelný) */
@media (min-width: 1024px) {
  body.is-admin .desktop-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    align-items: stretch;
  }

  .desktop-layout > .calendar-wrapper {
    display: flex;
    flex-direction: column;
  }

  .desktop-layout > .calendar-wrapper .calendar-grid {
    flex: 1;
  }

  /* Odstranit margin-bottom u všech .card v desktop layoutu */
  body.is-admin .desktop-layout .card {
    margin-bottom: 0;
  }

  /* Skrýt toggle "Neaktivní" na desktopu - rovnou zobrazit všechny */
  body.is-admin .desktop-layout .inactive-toggle {
    display: none !important;
  }

  body.is-admin .desktop-layout .inactive-section {
    display: block !important;
  }

  /* Desktop - větší písma v tabulce */
  body.is-admin .desktop-layout .card-label {
    font-size: 1.1rem;
  }

  body.is-admin .desktop-layout .stats-table th {
    font-size: 0.8rem;
    padding: 14px 8px;
  }

  body.is-admin .desktop-layout .stats-table td {
    font-size: 0.95rem;
    padding: 14px 8px;
  }

  body.is-admin .desktop-layout .name-pill {
    font-size: 0.9rem;
    padding: 6px 14px;
  }

  /* Rovná výška panelů: admin-dashboard + card musí vyplnit celou výšku gridu */
  body.is-admin .desktop-layout > #admin-dashboard {
    height: 100%;
  }

  body.is-admin .desktop-layout > #admin-dashboard > .card {
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  body.is-admin .desktop-layout > #admin-dashboard .table-wrapper {
    flex: 1;
  }
}


/* --- 1. HEADER & BRAND --- */
.header-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 0 30px 0;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-text {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--c-text-main);
  text-transform: uppercase;
  letter-spacing: -0.5px;
}

.brand-logo img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  box-shadow: var(--shadow);
  object-fit: cover;
}

/* APP HEADER (User info) */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-top: 10px;
}

.user-text-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
}

.user-info h2 {
  font-size: 1.6rem;
  line-height: 1.1;
  margin: 0;
  color: var(--c-text-main);
}

/* --- 2. CARDS & KPI DASHBOARD --- */
.card {
  background: var(--c-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--c-border);
}

.card-header-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-label-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-label {
  text-transform: capitalize;
  font-size: 1rem;
  font-weight: 700;
  color: var(--c-text-main);
  letter-spacing: 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.kpi-card {
  background: var(--c-card);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
  border: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.kpi-card.full-width-col {
  grid-column: span 2;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  text-align: left;
}

.pay-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.pay-stats-grid .kpi-card {
  padding: 16px 12px;
}

.kpi-label {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--c-text-main); /* Změněno z --c-text-muted na černou */
  margin-bottom: 6px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  width: 100%;
}

.kpi-val {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--c-text-main);
}

.kpi-val.green,
.kpi-val.text-green {
  color: var(--c-green);
}

.kpi-explain {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--c-text-muted);
  margin-top: 4px;
}

/* --- 3. TABLES (Admin View) --- */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -24px;
  padding: 0 24px;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 300px;
}

.stats-table th {
  text-align: center;
  font-size: 0.7rem;
  color: var(--c-text-muted);
  border-bottom: 1px solid var(--c-border);
  user-select: none;
  padding: 12px 6px;
  letter-spacing: 0.5px;
}

.stats-table th.sortable {
  cursor: pointer;
  transition: color 0.15s ease;
}

.stats-table th.sortable:hover {
  color: var(--c-text-main);
}

/* Skrýt sort ikony */
.stats-table th.sortable .sort-icon {
  display: none;
}

/* Force center first column header */
.stats-table th:first-child {
  text-align: center !important;
}

.stats-table td {
  padding: 12px 6px;
  text-align: center;
  border-bottom: 1px solid var(--c-border);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--c-text-main);
  vertical-align: middle;
  white-space: nowrap;
}

/* Force center first column cells & bold */
.stats-table td:first-child {
  text-align: center !important;
  font-weight: 700;
}

.row-active td {
  font-weight: 800 !important;
  color: #000000 !important;
}

/* ✅ Vyplacené měsíce – hodiny a částka šedivě */
.row-active.row-paid td:not(:first-child) {
  font-weight: 500 !important;
  color: var(--c-text-muted) !important;
}

/* ✅ HOVER EFEKT NA ŘÁDCÍCH (desktop) */
@media (min-width: 1024px) {
  .stats-table tbody tr:not(.toggle-inactive-row) {
    transition: background-color 0.15s ease;
  }

  .stats-table tbody tr:not(.toggle-inactive-row):hover {
    background-color: var(--c-input-bg);
  }
}

/* ✅ NEAKTIVNÍ ŘÁDKY (nižší opacity) */
.row-inactive {
  opacity: 0.5;
}

/* Poslední řádek v tabulce nemá mít border */
.stats-table tbody tr:last-child td {
  border-bottom: none;
}

/* ✅ ROZBALOVACÍ TLAČÍTKO PRO NEAKTIVNÍ */
.toggle-inactive-row {
  cursor: pointer;
  transition: var(--trans-fast);
}

.toggle-inactive-row:hover {
  background: var(--c-input-bg);
}

.toggle-inactive-row:active {
  transform: scale(0.98);
}

.toggle-inactive-cell {
  text-align: center !important;
  padding: 12px !important;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--c-text-muted);
  user-select: none;
}

/* --- 4. HISTORY LIST --- */
.history-list-wrapper {
  max-height: 300px;
  overflow-y: auto;
  margin: 0 -10px;
  padding: 0 10px;
}

.history-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--c-border);
}

.history-item:last-child {
  border-bottom: none;
}

.h-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.h-date {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--c-text-main);
}

.h-amount {
  font-weight: 700;
  font-size: 0.95rem;
}

.h-note {
  font-size: 0.75rem;
  color: var(--c-text-muted);
}

/* --- 4b. DETAIL TABLE (User Detail Modal) --- */
#userDetailBody,
#yearDetailBody {
  width: 85%;
  margin: 0 auto;
  max-height: 60vh;
  overflow-y: auto;
}

.detail-table-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  padding: 12px 8px;
  border-bottom: 1px solid var(--c-border);
}

.detail-table-header span {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-accent);
}

.detail-table-header svg {
  stroke-width: 2.5;
}

.detail-table-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  padding: 8px 8px;
  border-bottom: 1px dashed var(--c-border);
  align-items: center;
}

.detail-table-row span {
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--c-text-main);
  text-align: center;
  white-space: nowrap;
}

.detail-table-row.last {
  border-bottom: none;
}

/* Budoucí směny (neopdracované) - šedivý font */
.detail-table-row.future span {
  color: var(--c-text-muted);
  font-weight: 400;
}

/* Vyplacené měsíce v tabulce - světle šedá barva jako "Vyplaceno" */
.detail-table-row span.paid-complete {
  color: var(--c-text-muted);
  font-weight: 400;
}

.detail-table-footer {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  padding: 8px 8px;
  margin-top: 6px;
  background: var(--c-input-bg);
  border-radius: var(--radius);
  align-items: center;
}

.detail-table-footer span {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--c-text-main);
  text-align: center;
}

/* Vyplaceno / Zbývá – pod CELKEM, na bílém pozadí */
.detail-pay-block {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0;
  padding: 0 8px;
  margin-top: 4px;
  align-items: center;
}

.detail-pay-line-sep {
  grid-column: 1 / -1;
  height: 1px;
  border-bottom: 1px dashed var(--c-border);
  margin: 0;
}

.detail-pay-line-label {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 8px 2px;
}

.detail-pay-line-val {
  font-weight: 700;
  font-size: 0.85rem;
  text-align: right;
  padding: 8px 2px;
}

/* ✅ Vizuální indikace "Vyplaceno" - šedá barva + checkmark */
.detail-pay-line-val.paid-complete {
  color: var(--c-text-muted);
  font-weight: 500;
}


/* Toggle uvnitř detail modálu */
.detail-toggle-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

/* Barva "Zbývá k výplatě" – oranžová */
.detail-pay-debt {
  color: var(--c-accent) !important;
}

/* Tlačítko výplaty v detail modálu */
.detail-pay-action {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

/* Historie výplat v detail modálu */
#detailHistorySection {
  margin-top: 20px;
  border-top: 1px solid var(--c-border);
  padding-top: 16px;
}

.detail-history-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  padding: 8px 0;
  -webkit-tap-highlight-color: transparent;
}

.detail-history-toggle-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-history-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--c-input-bg);
  transition: transform 0.3s ease, background 0.2s ease;
}

.detail-history-toggle-icon svg {
  width: 14px;
  height: 14px;
  stroke: var(--c-text-muted);
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.detail-history-toggle:active .detail-history-toggle-icon {
  background: var(--c-border);
}

.detail-history-toggle-icon.open {
  transform: rotate(180deg);
}

.detail-history-body {
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.25s ease;
  max-height: 500px;
  opacity: 1;
}

.detail-history-body.collapsed {
  max-height: 0;
  opacity: 0;
}

.detail-history-item {
  padding: 10px 0;
  border-bottom: 1px dashed var(--c-border);
}

.detail-history-item:last-child {
  border-bottom: none;
}

.detail-history-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.detail-history-date {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--c-text-main);
}

.detail-history-amount {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--c-green);
}

.detail-history-note {
  font-size: 0.7rem;
  color: var(--c-text-muted);
  margin-top: 2px;
}

/* Titulek modalu s datem vedle jména */
.modal-title-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.modal-title-name {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--c-text-main);
}

.modal-title-date {
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--c-text-muted);
}

/* --- 5. MODALS (Structure) --- */
dialog {
  border: none;
  padding: 0;
  margin: 0;
  background: transparent;
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  position: fixed;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
}

dialog[open] {
  display: flex;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}

@keyframes zoomIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes zoomOut {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0.95); }
}

/* Animace pro vnitřní přechody v modálu (LIST → ADD/EDIT a zpět) */
@keyframes contentZoomIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-content {
  background: var(--c-card);
  width: 90%;
  max-width: 420px;
  border-radius: 24px;
  padding: 32px 24px 40px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: zoomIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  margin: 20px;
}

/* ZoomOut při zavírání modálu */
dialog.closing .modal-content {
  animation: zoomOut 0.2s cubic-bezier(0.4, 0, 1, 1) forwards;
}

dialog.closing::backdrop {
  animation: fadeOutBackdrop 0.2s ease forwards;
}

@keyframes fadeOutBackdrop {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Animace vnitřního obsahu modálu */
.modal-body-animate-in {
  animation: contentZoomIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-body-animate-out {
  animation: contentFadeBack 0.25s ease;
}

@keyframes contentFadeBack {
  from { opacity: 0; transform: scale(1.02); }
  to { opacity: 1; transform: scale(1); }
}

/* 1. VÝCHOZÍ STYL (Pro ShiftDialog - Ikona a datum vedle sebe) */
.modal-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--c-text-main);
  margin-bottom: 12px;
  display: flex;
  flex-direction: row;       /* VEDLE SEBE */
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

/* 2. VÝJIMKA PRO HISTORII (Pro HistoryDialog - Jméno a rok pod sebou) */
#historyDialog .modal-title {
  flex-direction: column;    /* POD SEBE */
  gap: 2px;
  margin-bottom: 10px;
}

.modal-footer {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  justify-content: center;
}

/* --- 6. LOGIN VIEW --- */
.login-tabs-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-bottom: 25px;
  background: var(--c-input-bg);
  padding: 4px;
  border-radius: var(--radius-pill);
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.login-tab {
  background: transparent;
  border: none;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--c-text-muted);
  padding: 10px 24px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--trans-fast);
}

.login-tab:active {
  transform: scale(0.96);
}

.tab-icon {
  width: 18px;
  height: 18px;
  stroke-width: 2.5px;
}

.login-tab.active {
  background-color: var(--c-green);
  color: #000000;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.login-form-narrow {
  width: fit-content;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* --- 7. RESPONSIVE --- */
@media (min-width: 768px) {
  .modal-content {
    padding: 40px;
    max-width: 460px;
  }
}

/* --- 8. PROFIL MODAL --- */

/* Řádek s ikonou, hodnotou a zámkem */
.profile-field-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0;
}

.profile-field-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-input-bg);
  border-radius: 10px;
  flex-shrink: 0;
  color: var(--c-text-muted);
  margin-top: 2px;
}

.profile-field-value {
  flex: 1;
  min-width: 0;
}

.profile-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}

.profile-field-text {
  font-size: 17px;
  font-weight: 500;
  color: var(--c-text-main);
  letter-spacing: 0.08em;
}

/* Email - menší font aby nezasahoval do zámku */
.profile-field-text--small {
  font-size: 14px;
  letter-spacing: 0;
  word-break: break-all;
  padding-right: 4px;
}

/* Editor který se rozbalí po odemknutí */
.profile-field-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  animation: contentZoomIn 0.18s ease;
}

.profile-field-editor .styled-input {
  margin: 0;
}

/* Levá ikona – oranžová varianta */
.profile-field-icon--accent {
  color: var(--c-accent);
  background: rgba(230, 74, 25, 0.08);
}

/* Pravá ikona (tužka) - zarovnání */
.profile-edit-btn {
  flex-shrink: 0;
  margin-top: 2px;
}

/* Input + save fajfka vedle sebe */
.profile-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-input-row .styled-input {
  margin: 0;
  flex: 1;
}

/* Save tlačítko (fajfka) vedle inputu - zelená */
.profile-save-btn {
  flex-shrink: 0;
  background: var(--c-green) !important;
  color: #fff !important;
}

/* Oddělovač mezi sekcemi */
.profile-separator {
  height: 1px;
  background: var(--c-border);
  margin: 0 0 0 50px;
}

/* Admin sekce – flex column s mezerou */
.profile-admin-select {
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.profile-admin-select .btn {
  margin: 0;
}

.profile-admin-select .styled-input {
  margin: 0;
  width: 100%;
}

/* --- 9. BULK PLÁNOVÁNÍ --- */

/* Tlačítko bulk mode - aktivní stav (oranžové pozadí) */
#bulkModeBtn.bulk-active {
  background: var(--c-accent) !important;
  color: #fff !important;
}

/* Floating bar pod kalendářem */
.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--c-accent);
  color: #fff;
  border-radius: 14px;
  padding: 10px 14px;
  margin-top: 12px;
  animation: contentZoomIn 0.2s ease;
}

.bulk-bar-count {
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.bulk-bar-btns {
  display: flex;
  gap: 6px;
}

.bulk-bar .btn {
  font-size: 13px;
  padding: 7px 14px;
  min-height: 34px;
  height: 34px;
  line-height: 1;
}

.bulk-bar .btn-ghost {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: none;
}

.bulk-bar .btn-success {
  background: #fff;
  color: var(--c-accent);
}

.bulk-bar .btn-success:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Označený den v bulk módu */
.cal-day.bulk-selected {
  outline: 3px solid var(--c-accent);
  outline-offset: -3px;
  background: rgba(230, 74, 25, 0.08);
  border-radius: 10px;
}

/* Nedostupný den v bulk módu (není bílý) */
.cal-day.bulk-disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Minulý den v bulk módu – zešedivělý + křížek */
.cal-day.bulk-past {
  opacity: 0.35;
  cursor: not-allowed;
  position: relative;
}

.cal-day.bulk-past::after {
  content: '✕';
  position: absolute;
  bottom: 4px;
  right: 5px;
  font-size: 10px;
  color: #aaa;
  line-height: 1;
  font-weight: 600;
}

/* Souhrn vybraných dnů v bulk modalu */
.bulk-days-summary {
  font-size: 13px;
  color: var(--c-text-main);
  background: transparent;
  padding: 0 0 12px 0;
  margin-bottom: 0;
  line-height: 1.6;
}

.bulk-days-summary strong {
  color: var(--c-text-main);
  font-weight: 700;
}

/* Bulk modal řádky – ikona vycentrovaná na střed inputu */
.bulk-modal-row {
  align-items: center;
  padding: 10px 0;
}

.bulk-modal-icon {
  align-self: center;
}