/* css/main.css — Globální styly systému */

:root {
  --brand:      #022135;
  --accent:     #0097B2;
  --success:    #7BD759;
  --warning:    #FDC156;
  --danger:     #e74c3c;
  --paper:      #f9fafb;
  --surface:    #ffffff;
  --border:     #d1d5db;
  --muted:      #6b7280;
  --text:       #111827;
  --radius:     4px;
  --shadow:     0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg:  0 4px 16px rgba(0,0,0,0.12);
  --font-ui:    'Inter', system-ui, sans-serif;
  --font-brand: 'Anton', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  /* Zabraň horizontálnímu posunu na všech zařízeních */
  overflow-x: hidden;
  max-width: 100%;
}

body {
  font-family: var(--font-ui);
  background: var(--paper);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  max-width: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── TOP NAV ─────────────────────────────────────────────── */
.topnav {
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
  gap: 8px;
  width: 100%;
  /* Zabraň přetékání nav prvků za viewport */
  overflow: hidden;
}

.nav-brand {
  font-family: var(--font-brand);
  font-size: 1.2rem;
  color: #fff;
  letter-spacing: 0.04em;
  margin-right: 24px;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  gap: 4px;
  align-items: center;
}

.nav-links a {
  color: rgba(255,255,255,0.8);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.nav-links a:hover,
.nav-links a.active { background: rgba(255,255,255,0.12); color: #fff; }
.nav-links a.nav-admin { color: var(--warning); }

.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  flex-shrink: 0;
  margin-left: auto;
}

.nav-role {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.nav-role.admin    { background: var(--warning); color: var(--brand); }
.nav-role.provozni { background: #fecaca; color: #991b1b; }
.nav-role.brigadnik { background: #bfdbfe; color: #1e40af; }
.nav-role.user     { background: rgba(255,255,255,0.15); color: #fff; }

.nav-name {
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.nav-logout, .nav-login {
  color: rgba(255,255,255,0.7);
  font-size: 0.8rem;
  border: 1px solid rgba(255,255,255,0.25);
  padding: 4px 10px;
  border-radius: var(--radius);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s;
}
.nav-logout:hover, .nav-login:hover {
  background: rgba(255,255,255,0.1);
  text-decoration: none;
  color: #fff;
}

/* ── MAIN CONTENT ────────────────────────────────────────── */
main {
  flex: 1;
  padding: 32px 24px 48px;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  overflow-x: hidden;
}

/* ── PAGE HEADER ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--brand);
}

.page-header h1 {
  font-family: var(--font-brand);
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  color: var(--brand);
  letter-spacing: -0.02em;
}

/* ── CARDS ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.app-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--accent);
  text-decoration: none;
}
.app-card-icon  { font-size: 2rem; }
.app-card-title { font-family: var(--font-brand); font-size: 1.1rem; color: var(--brand); }
.app-card-desc  { font-size: 0.8rem; color: var(--muted); }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: filter 0.15s;
  text-decoration: none;
  white-space: nowrap;
  touch-action: manipulation; /* rychlejší tap na mobilu */
}
.btn:hover { filter: brightness(0.9); text-decoration: none; }

.btn-primary  { background: var(--brand);   color: #fff; }
.btn-accent   { background: var(--accent);  color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm       { font-size: 0.75rem; padding: 6px 10px; }

/* ── FORMS ───────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.form-input, .form-select {
  font-family: var(--font-ui);
  font-size: 16px; /* min. 16px = žádný zoom na iOS */
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.form-input:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,151,178,0.15);
}

/* ── ALERTS ──────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 16px;
  border-left: 4px solid transparent;
  word-break: break-word;
}
.alert-error   { background: #fef2f2; border-color: var(--danger);  color: #991b1b; }
.alert-success { background: #f0fdf4; border-color: var(--success); color: #166534; }
.alert-info    { background: #eff6ff; border-color: var(--accent);  color: #1e40af; }

/* ── TABLE ───────────────────────────────────────────────── */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  min-width: 580px; /* zabrání sploštění na velmi malých displejích */
}

.data-table th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  background: var(--paper);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:hover td { background: #f8fafc; }

/* Akční tlačítka v tabulce */
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* ── BADGES ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-admin     { background: #fef3c7; color: #92400e; }
.badge-provozni  { background: #fee2e2; color: #991b1b; }
.badge-user,
.badge-brigadnik { background: #dbeafe; color: #1e40af; }
.badge-active    { background: #d1fae5; color: #065f46; }
.badge-inactive { background: #f3f4f6; color: var(--muted); }

/* ── FOOTER ──────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 16px;
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* ── MODÁLY ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(2,33,53,0.55);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--surface);
  border-radius: 6px;
  padding: 28px 24px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
  max-height: 90vh;
  overflow-y: auto;
}

/* ── RESPONSIVE — MOBIL (max 640px) ─────────────────────── */
@media (max-width: 640px) {

  /* Nav: dva řádky
     1. řádek: logo | jméno + role + Odhlásit
     2. řádek: Kalendář | Rezervace | (Uživatelé)            */
  .topnav {
    padding: 0 12px;
    height: auto;
    flex-wrap: wrap;
    gap: 0;
    overflow: visible;
  }

  .nav-brand {
    font-size: 0.9rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 10px 0;
    margin-right: 8px;
  }

  /* Uživatel + Odhlásit — první řádek vpravo */
  .nav-user {
    gap: 5px;
    flex-shrink: 0;
    padding: 8px 0;
  }

  .nav-role {
    font-size: 0.62rem;
    padding: 2px 6px;
    letter-spacing: 0;
    white-space: nowrap;
  }

  .nav-name {
    max-width: 75px;
    font-size: 0.75rem;
  }

  .nav-logout, .nav-login {
    font-size: 0.72rem;
    padding: 3px 8px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Nav-links — na mobilu schované, jen dlaždice v dashboardu */
  .nav-links {
    display: none;
  }

  /* Obsah */
  main {
    padding: 16px 12px 32px;
    overflow-x: hidden;
    max-width: 100%;
  }

  /* Page header */
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-header .btn { width: 100%; }

  /* Karty */
  .card { padding: 16px 14px; }
  .card-grid { grid-template-columns: 1fr; }

  /* Dashboard */
  .dash-layout { flex-direction: column !important; }
  .dash-aside  { width: 100% !important; }
  .dash-aside .app-card { flex-direction: row; align-items: center; gap: 14px; }
  .dash-aside .app-card-icon { font-size: 1.5rem; }

  /* Tabulka */
  .table-responsive::before {
    content: '← Posuňte pro více →';
    display: block;
    text-align: center;
    font-size: 0.72rem;
    color: var(--muted);
    padding: 4px 0 8px;
  }

  /* Modál */
  .modal-box {
    padding: 20px 16px;
    max-height: 88vh;
    overflow-y: auto;
  }
  .modal-wide { max-width: 100% !important; margin: 8px; }

  /* Tlačítka — min. dotyková plocha */
  .btn     { min-height: 44px; }
  .btn-sm  { min-height: 36px; }
}

/* ── RESPONSIVE — TABLET (641–900px) ────────────────────── */
@media (min-width: 641px) and (max-width: 900px) {
  main { padding: 24px 16px 40px; }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .table-responsive { overflow-x: auto; }
}
