:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --text-muted: #64748b;
  --brand: #2563eb;
  --brand-light: rgba(37, 99, 235, 0.1);
  --success: #10b981;
  --danger: #ef4444;
  --border: rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-font-smoothing: antialiased; }
html { scrollbar-gutter: stable; }
html, body { height: 100%; margin: 0; }

body {
  font-family: "Manrope", sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Icons */
.icon { 
  width: 1.25em; 
  height: 1.25em; 
  vertical-align: middle;
  display: inline-block;
  flex-shrink: 0;
}

/* Fix pro Lucide ikony před načtením */
i[data-lucide] {
  display: inline-block;
  width: 1.25em;
  height: 1.25em;
}

/* Layout */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 48px;
  text-decoration: none;
  color: var(--text);
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--brand), #60a5fa);
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: white;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
}

.brand-name span {
  color: var(--brand);
}

.brand-slogan {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 4px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 600;
  transition: all 0.2s;
  text-decoration: none;
}

.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link:active { transform: translateX(2px); }
.nav-link.active { color: var(--brand); background: var(--brand-light); }

.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.top-bar {
  height: 72px;
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.content-area { padding: 40px; max-width: 1200px; width: 100%; margin: 0 auto; }

/* Components */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform, box-shadow;
}

.card--hover {
  transform: translateY(0);
}

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

.card--hover:active {
  transform: translateY(0);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  text-decoration: none;
}

.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: #1d4ed8; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2); }

.btn-secondary { background: white; border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); }

.btn-ghost { color: var(--text-muted); padding: 8px; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

/* Badges */
.badge {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-ghost { background: #f1f5f9; color: #64748b; border: 1px solid var(--border); }

.hidden { display: none !important; }

/* Tables */
.table-container { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 16px; color: var(--text-muted); font-size: 0.875rem; border-bottom: 1px solid var(--border); }
td { padding: 16px; border-bottom: 1px solid var(--border); transition: all 0.2s; }
tr:last-child td { border-bottom: none; }

.payment-row { transition: all 0.2s; }
.payment-row:hover td { background: var(--surface-2); }

.row-paid td {
  background: #f8fafc;
  color: var(--text-muted);
}

.row-paid .badge-green {
  opacity: 0.8;
}

/* Inputs */
.form-group { margin-bottom: 24px; }
.form-label { display: block; margin-bottom: 8px; font-weight: 700; font-size: 0.875rem; color: var(--text); }
.form-control {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.2s;
}
.form-control:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-light); }
.form-control[readonly] { background-color: #cbd5e1; cursor: not-allowed; color: #334155; border-color: #94a3b8; }

.nette-form label { display: block; margin-bottom: 8px; font-weight: 700; font-size: 0.875rem; }
.nette-form input[type="text"], 
.nette-form input[type="password"], 
.nette-form input[type="email"], 
.nette-form input[type="number"], 
.nette-form select, 
.nette-form textarea {
  extend: .form-control; /* Note: extend doesn't work in pure CSS, repeating styles below */
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 4px;
}
.nette-form .error { color: var(--danger); font-size: 0.8rem; font-weight: 700; margin-bottom: 12px; display: block; }

/* Grid helpers */
.grid { display: grid; gap: 24px; }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }

    /* Toggle Switch */
    .toggle-switch {
      display: flex;
      align-items: center;
      gap: 12px;
      cursor: pointer;
      padding: 14px 20px;
      background: var(--surface-2);
      border-radius: 14px;
      margin: 8px 0 24px 0;
      transition: all 0.2s;
      border: 1px solid transparent;
      user-select: none;
      width: 100%;
    }

    .toggle-switch:hover {
      background: #e2e8f0;
      border-color: var(--border);
    }

    .toggle-control {
      position: relative;
      width: 44px;
      height: 22px;
      flex-shrink: 0;
    }

    .toggle-control input {
      position: absolute;
      opacity: 0;
      width: 100%;
      height: 100%;
      cursor: pointer;
      z-index: 2;
      margin: 0;
    }

    .toggle-slider {
      position: absolute;
      inset: 0;
      background-color: #e2e8f0;
      border-radius: 22px;
      transition: .3s;
      z-index: 1;
      border: 1px solid var(--border);
    }

    .toggle-slider:before {
      position: absolute;
      content: "";
      height: 16px;
      width: 16px;
      left: 2px;
      bottom: 2px;
      background-color: white;
      border-radius: 50%;
      transition: .3s;
      box-shadow: var(--shadow-sm);
    }

    .toggle-switch input:checked ~ .toggle-slider {
      background-color: #22c55e !important;
      border-color: #16a34a;
    }

    .toggle-switch input:checked ~ .toggle-slider:before {
      transform: translateX(22px);
    }

    .toggle-label {
      font-weight: 700;
      font-size: 0.95rem;
      color: var(--text);
    }
.progress-bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--brand); transition: width 0.3s; }

/* Alerts */
.alert { padding: 16px; border-radius: var(--radius); margin-bottom: 24px; display: flex; align-items: center; gap: 12px; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  place-items: start center;
  padding: 24px;
  z-index: 100;
  overflow: auto;
}

.modal-overlay.is-open { display: grid; }

.modal {
  width: min(520px, 100%);
  margin-top: 60px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  padding: 24px;
}

@media (max-width: 768px) {
  .sidebar { 
    display: flex; 
    position: fixed; 
    left: -280px; 
    z-index: 1000; 
    transition: left 0.3s ease;
    box-shadow: 20px 0 50px rgba(0,0,0,0.1);
  }
  
  .sidebar.is-open {
    left: 0;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .sidebar-overlay.is-visible {
    display: block;
    opacity: 1;
  }

  .top-bar { padding: 0 20px; }
  .menu-toggle { display: flex !important; }
  
  .content-area { padding: 20px; }
  .grid-cols-3 { grid-template-columns: 1fr; }

  /* Mobile payment list transformation */
  .table-container table thead { display: none; }
  .table-container table, .table-container tbody, .table-container tr, .table-container td { display: block; width: 100%; }
  
  .payment-row {
    padding: 16px !important;
    border-bottom: 1px solid var(--border);
    display: grid !important;
    grid-template-columns: 48px 1fr auto;
    grid-template-areas: 
      "day desc amount"
      "day tag actions";
    gap: 4px 12px;
    align-items: center;
  }

  .payment-row td {
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
  }

  .payment-row td:nth-child(1) { grid-area: day; align-self: center; }
  .payment-row td:nth-child(2) { grid-area: desc; align-self: end; }
  .payment-row td:nth-child(3) { grid-area: tag; align-self: start; }
  .payment-row td:nth-child(4) { grid-area: amount; text-align: right !important; align-self: end; }
  .payment-row td:nth-child(5) { grid-area: actions; text-align: right !important; align-self: start; }

  /* Monthly overview specific mobile adjustments (6 columns table) */
  .payment-row td.payment-status { 
    grid-area: tag; 
    text-align: left !important; 
    padding-left: 0 !important;
    margin-left: 90px; /* Posunutí za tag */
    display: flex !important;
    align-items: center;
  }
  
  .payment-row td.payment-status div { display: none; } /* Skrytí data zaplacení na mobilu */

  .payment-row td.payment-actions { 
    grid-area: actions; 
    text-align: right !important; 
  }

  /* Stat karty v detailu přehledu na mobilu */
  #monthlyTotals.grid-cols-3 {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Page header adjustments for mobile */
  .page-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start !important;
    gap: 16px;
  }
  .page-header > div:last-child {
    width: 100%;
    display: flex;
    gap: 8px;
  }
  .page-header > div:last-child .btn {
    flex: 1;
    justify-content: center;
  }

  /* Vypnutí hover efektu na buňkách v mobilním zobrazení, protože řádek je teď grid */
  .payment-row:hover td { background: transparent !important; }

  /* Mobile summary bar adjustment */
  .card > div[style*="background: var(--surface-2)"] {
    padding: 20px !important;
    flex-direction: column;
    gap: 16px;
    align-items: flex-start !important;
  }
  
  .card > div[style*="background: var(--surface-2)"] > div:last-child {
    width: 100%;
    text-align: left !important;
    padding-top: 16px;
    border-top: 1px solid rgba(15, 23, 42, 0.05);
  }
}
