/* ===== RESET & VARIABLES ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #dbeafe;
  --danger:        #dc2626;
  --success:       #16a34a;
  --warning:       #d97706;

  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;

  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow:    0 1px 3px rgba(0,0,0,0.10), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.10), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.10), 0 10px 10px -5px rgba(0,0,0,0.04);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== HEADER — mobile first ===== */
.app-header {
  background: var(--primary);
  color: #fff;
  height: 56px;                  /* menší na mobilu */
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-icon { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; display: block; flex-shrink: 0; }

/* Název skrytý na mobilu, ukáže se na tabletu */
.brand-name {
  display: none;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.season-select {
  padding: 0.375rem 0.5rem;
  border: 1.5px solid rgba(255,255,255,0.4);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 0.8125rem;
  cursor: pointer;
  max-width: 130px;              /* omezeno na mobilu */
}
.season-select option { background: var(--primary-dark); color: #fff; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  min-height: 44px;              /* touch target */
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  font-family: inherit;
}

.btn-primary-plain { background: var(--primary); color: #fff; }
.btn-primary-plain:hover { background: var(--primary-dark); }

.btn-outline {
  background: transparent;
  color: #fff;
  border: 1.5px solid rgba(255,255,255,0.5);
}
.btn-outline:hover { background: rgba(255,255,255,0.12); border-color: #fff; }

.btn-secondary {
  background: #fff;
  color: var(--gray-700);
  border: 1.5px solid var(--gray-200);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-300); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* ===== APP BODY ===== */
.app-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem;
  width: 100%;
  margin: 0 auto;
}

/* ===== MONTH NAV ===== */
.month-nav-wrapper {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 0.375rem;
  box-shadow: var(--shadow);
}

.month-nav-btn {
  width: 44px;                   /* touch target */
  height: 44px;
  flex-shrink: 0;
  border: none;
  background: var(--gray-100);
  border-radius: var(--radius);
  font-size: 1.375rem;
  line-height: 1;
  color: var(--gray-500);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.month-nav-btn:hover { background: var(--primary-light); color: var(--primary); }

.month-tabs {
  display: flex;
  gap: 0.25rem;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.month-tabs::-webkit-scrollbar { display: none; }

.month-tab {
  padding: 0.375rem 0.625rem;
  border: none;
  background: none;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  color: var(--gray-500);
  white-space: nowrap;
  cursor: pointer;
  min-height: 36px;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}
.month-tab:hover { background: var(--gray-100); color: var(--gray-700); }
.month-tab.active { background: var(--primary); color: #fff; font-weight: 600; }

/* ===== TABLE WRAPPER ===== */
.table-wrapper {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 160px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--gray-400);
}
.empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.empty-state p { margin-bottom: 1.25rem; font-size: 1rem; color: var(--gray-500); }

/* ===== TABLE ===== */
.table-container {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 240px);
  -webkit-overflow-scrolling: touch; /* plynulý scroll na iOS */
}

.attendance-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.attendance-table th,
.attendance-table td {
  border-right: 1px solid var(--gray-100);
  border-bottom: 1px solid var(--gray-100);
  text-align: center;
  padding: 0;
}

.sticky-col {
  position: sticky;
  left: 0;
  z-index: 20;
  background: var(--gray-50);
  text-align: left !important;
}

.sticky-right {
  position: sticky;
  right: 0;
  z-index: 20;
  background: var(--gray-50);
}

.attendance-table thead th {
  background: var(--gray-50);
  position: sticky;
  top: 0;
  z-index: 10;
  font-weight: 600;
  color: var(--gray-600);
}
.attendance-table thead .sticky-col   { z-index: 30; }
.attendance-table thead .sticky-right { z-index: 30; }

.attendance-table tbody tr:nth-child(even) { background: var(--gray-50); }
.attendance-table tbody tr:nth-child(even) .sticky-col   { background: var(--gray-50); }
.attendance-table tbody tr:nth-child(even) .sticky-right { background: var(--gray-50); }

.attendance-table tbody tr:hover { background: var(--primary-light) !important; }
.attendance-table tbody tr:hover .sticky-col   { background: var(--primary-light) !important; }
.attendance-table tbody tr:hover .sticky-right { background: var(--primary-light) !important; }

/* Sloupce */
.col-player  { min-width: 110px; padding: 0.625rem 0.75rem !important; }
.col-percent { min-width: 48px; width: 48px; padding: 0.625rem 0.25rem !important; font-weight: 600; }

.training-header {
  min-width: 60px;
  width: 60px;
  padding: 0.375rem 0.25rem !important;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
  vertical-align: middle;
}
.training-header:hover { background: var(--primary-light); }
.training-header.cancelled { background: var(--gray-50); opacity: 0.55; }

.training-date { display: block; font-weight: 600; font-size: 0.8125rem; color: var(--gray-700); }
.training-day  { display: block; font-size: 0.6875rem; color: var(--gray-400); }

.training-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  margin-top: 3px;
}
.training-header.cancelled .training-dot { background: var(--danger); }

.player-name-cell {
  padding: 0.5rem 0.75rem !important;
  text-align: left !important;
  cursor: pointer;
  font-weight: 500;
  color: var(--gray-800);
}
.player-name-cell:hover { color: var(--primary); text-decoration: underline; }

.attendance-cell {
  width: 60px;
  height: 44px;                  /* touch target */
  cursor: pointer;
}
.attendance-cell.cancelled { background: var(--gray-100) !important; cursor: default; }

.attendance-btn {
  width: 100%;
  height: 100%;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  transition: background 0.1s;
}
.attendance-btn:hover:not(:disabled) { background: rgba(0,0,0,0.04); }
.attendance-btn:disabled { cursor: default; }

.icon-present { color: var(--success); }
.icon-absent  { color: var(--danger); }
.icon-empty   { color: var(--gray-300); font-size: 0.9375rem; }

.percent-cell { font-weight: 700; font-size: 0.875rem; padding: 0 0.25rem !important; }
.percent-high { color: var(--success); }
.percent-mid  { color: var(--warning); }
.percent-low  { color: var(--danger); }

.empty-month-row td {
  padding: 2.5rem 1rem !important;
  color: var(--gray-400);
  font-size: 0.9375rem;
  text-align: center !important;
}

/* ===== ACTIONS BAR — na mobilu pod sebou ===== */
.actions-bar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.actions-bar .btn { width: 100%; }

/* ===== MODALS — na mobilu vyjíždí ze spodu ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: flex-end;         /* zarovnání ke spodku na mobilu */
  justify-content: center;
  z-index: 1000;
  padding: 0;
  backdrop-filter: blur(2px);
}
.modal-overlay.active { display: flex; }

.modal {
  background: #fff;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;  /* zaoblení jen nahoře */
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  animation: modalUp 0.22s ease;
}

@keyframes modalUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.125rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
}

.modal-title { font-size: 1.0625rem; font-weight: 700; color: var(--gray-800); }

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--gray-100);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--gray-200); color: var(--gray-700); }

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-footer-right { display: flex; gap: 0.5rem; }

/* ===== FORM ===== */
.field-group { display: flex; flex-direction: column; gap: 0.375rem; }

.field-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input {
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 1rem;               /* 16px — zabraňuje zoom na iOS */
  font-family: inherit;
  color: var(--gray-800);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  resize: vertical;
  width: 100%;
}
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.toggle-group {
  display: flex;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
}
.toggle-btn {
  flex: 1;
  padding: 0.625rem 1rem;
  min-height: 44px;              /* touch target */
  border: none;
  background: #fff;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-500);
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}
.toggle-btn + .toggle-btn { border-left: 1.5px solid var(--gray-200); }
.toggle-btn.active[data-status="active"]    { background: var(--success); color: #fff; }
.toggle-btn.active[data-status="cancelled"] { background: var(--danger);  color: #fff; }

/* ===== PLAYER STATS ===== */
.player-stats {
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 1rem;
}
.player-stats-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.625rem;
}
.player-stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9375rem;
  padding: 0.2rem 0;
  color: var(--gray-600);
}
.player-stat-row .value { font-weight: 700; color: var(--gray-800); }

/* ===================================================
   TABLET  (600px+)
   =================================================== */
@media (min-width: 600px) {
  .app-header { height: 60px; padding: 0 1.25rem; }
  .brand-name { display: block; }
  .season-select { max-width: none; min-width: 160px; font-size: 0.875rem; }

  .app-body { padding: 1.25rem; gap: 1rem; }

  .month-tab { padding: 0.375rem 0.875rem; font-size: 0.875rem; }

  .col-player  { min-width: 140px; padding: 0.625rem 0.875rem !important; }
  .col-percent { min-width: 54px; width: 54px; }
  .training-header { min-width: 66px; width: 66px; }
  .attendance-cell { height: 46px; width: 66px; }

  /* Akce vedle sebe */
  .actions-bar { flex-direction: row; justify-content: space-between; }
  .actions-bar .btn { width: auto; }

  /* Modal — vycentrovaný, ne bottom sheet */
  .modal-overlay { align-items: center; padding: 1rem; }
  .modal {
    border-radius: var(--radius-xl);
    max-width: 480px;
    animation: modalIn 0.18s ease;
  }
  .modal-sm { max-width: 380px; }

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

/* ===== OFFLINE BANNER ===== */
body.has-offline-banner { padding-bottom: 38px; }

.offline-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  padding: 10px 16px;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  pointer-events: none;
}
.offline-banner.is-offline {
  background: #f59e0b;
  color: #1c1917;
}
.offline-banner.is-syncing {
  background: var(--primary);
  color: #fff;
}

/* ===================================================
   DESKTOP  (1024px+)
   =================================================== */
@media (min-width: 1024px) {
  .app-header { height: 64px; padding: 0 1.5rem; }
  .brand-name { font-size: 1.25rem; }
  .season-select { min-width: 200px; }

  .app-body { padding: 1.5rem; gap: 1.25rem; max-width: 1400px; }

  .table-container { max-height: calc(100vh - 270px); }
  .attendance-table { font-size: 0.875rem; }

  .col-player  { min-width: 160px; padding: 0.75rem 1rem !important; }
  .col-percent { min-width: 58px; width: 58px; padding: 0.75rem 0.5rem !important; }
  .training-header { min-width: 70px; width: 70px; padding: 0.5rem 0.25rem !important; }
  .training-date { font-size: 0.875rem; }
  .attendance-cell { height: 48px; width: 70px; }
  .attendance-btn { font-size: 1.25rem; }

  .modal { max-width: 520px; }
  .modal-sm { max-width: 400px; }
}
