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

:root {
  --bg:         #080d16;
  --bg2:        #0f1623;
  --bg3:        #161e2e;
  --bg4:        #1c2538;
  --border:     #1f2d45;
  --border2:    #2a3a55;
  --text:       #d0daf0;
  --text-dim:   #6e88aa;
  --text-muted: #3d5270;

  --red:        #e5293b;
  --red-dim:    #7a1020;
  --green:      #22c55e;
  --green-dim:  #145c31;
  --gold:       #f5c518;
  --gold-dim:   #6b530a;
  --blue:       #3b82f6;
  --purple:     #8b5cf6;
  --teal:       #14b8a6;
  --orange:     #f97316;
  --pink:       #ec4899;

  --radius:     8px;
  --radius-lg:  12px;
  --shadow:     0 4px 24px rgba(0,0,0,.5);
  --transition: .15s ease;

  --cat-fb:         #1877f2;
  --cat-ig:         #c13584;
  --cat-daily-form: #14b8a6;
  --cat-daily-q:    #8b5cf6;
  --cat-weekly:     #f97316;
  --cat-app:        #06b6d4;
  --cat-discount:   #64748b;
  --cat-other:      #475569;
}

html { height: 100%; zoom: 1.25; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  font-size: 14px;
  line-height: 1.5;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== HEADER ===== */
.header {
  background: linear-gradient(135deg, #0a1628 0%, #111d35 100%);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
}

.header-logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--gold);
  white-space: nowrap;
}
.header-logo span { color: var(--red); }
.header-spacer { flex: 1; }
.header-controls { display: flex; align-items: center; gap: 10px; }

/* ===== INPUTS & SELECTS ===== */
select, input[type=text], input[type=url], input[type=date], input[type=time], textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}
select:focus, input:focus, textarea:focus { border-color: var(--blue); }
select { cursor: pointer; }
textarea { resize: vertical; min-height: 70px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover:not(:disabled) { background: #2563eb; }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}
.btn-ghost:hover:not(:disabled) {
  border-color: var(--border2);
  color: var(--text);
  background: var(--bg3);
}

.btn-sm { padding: 4px 9px; font-size: 12px; }

.btn-icon {
  padding: 4px 6px;
  font-size: 14px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 6px;
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--bg4); color: var(--text); }

/* ===== MAIN ===== */
.main { padding: 16px 24px; max-width: 100%; }

/* ===== STATS BAR ===== */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  margin-bottom: 14px;
  overflow: hidden;
}

.stat-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-dim);
  border-right: 1px solid var(--border);
}
.stat-item:last-child { border-right: none; }
.stat-item span { font-size: 20px; font-weight: 700; color: #fff; line-height: 1; }
.stat-item small { font-size: 11px; color: var(--text-muted); }

.stat-item.si-done span { color: var(--green); }
.stat-item.si-wins span { color: var(--gold); }
.stat-item.si-urgent span { color: var(--red); }

/* ===== ENDING SOON ===== */
.ending-section { margin-bottom: 14px; }

.ending-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ending-chip {
  background: linear-gradient(135deg, #1a0a0d, #2a1015);
  border: 1px solid var(--red-dim);
  border-radius: var(--radius);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: pulse-border 2s ease-in-out infinite;
  cursor: pointer;
  transition: background var(--transition);
}
.ending-chip:hover { background: linear-gradient(135deg, #2a1015, #3a1520); }

.ending-chip .chip-name {
  font-size: 12px;
  font-weight: 500;
  color: #ffa0a0;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ending-chip .chip-countdown {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--red);
  min-width: 65px;
  text-align: right;
}

@keyframes pulse-border {
  0%, 100% { border-color: var(--red-dim); }
  50% { border-color: var(--red); box-shadow: 0 0 8px rgba(229,41,59,.3); }
}

/* ===== TOOLBAR ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.toolbar-left { display: flex; align-items: center; gap: 8px; flex: 1; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }

.search-box { position: relative; }
.search-box input { padding-left: 30px; width: 200px; }
.search-box .search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 12px;
  pointer-events: none;
}

.filter-btn {
  padding: 5px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.filter-btn:hover { background: var(--bg4); color: var(--text); border-color: var(--border2); }
.filter-btn.active { color: var(--blue); border-color: var(--blue); background: var(--bg4); }

/* ===== CATEGORY CHIPS ===== */
.cat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.cat-chip {
  padding: 4px 11px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.cat-chip:hover { border-color: var(--border2); color: var(--text); background: var(--bg4); }
.cat-chip.active { font-weight: 600; }

.chip-count {
  background: rgba(255,255,255,.08);
  border-radius: 10px;
  padding: 0 6px;
  font-size: 11px;
  min-width: 18px;
  text-align: center;
}

/* ===== LIST CONTAINER ===== */
.list-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ===== ACCORDION SECTION ===== */
.list-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.section-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
  border-left: 4px solid transparent;
}
.section-hdr:hover { background: var(--bg3); }

/* Category accent colors on section header */
.list-section[data-cat="Denní CZ - Vyplnění formuláře"] .section-hdr { border-left-color: var(--cat-daily-form); }
.list-section[data-cat="Denní CZ - úkoly a otázky"]     .section-hdr { border-left-color: var(--cat-daily-q); }
.list-section[data-cat="FB - adventní kalendář"]          .section-hdr { border-left-color: var(--cat-fb); }
.list-section[data-cat="Instagram"]                        .section-hdr { border-left-color: var(--cat-ig); }
.list-section[data-cat="Týdenní"]                          .section-hdr { border-left-color: var(--cat-weekly); }
.list-section[data-cat="Aplikace"]                         .section-hdr { border-left-color: var(--cat-app); }
.list-section[data-cat="Pouze Slevy / S nákupem"]         .section-hdr { border-left-color: var(--cat-discount); }
.list-section[data-cat="Ostatní"]                          .section-hdr { border-left-color: var(--cat-other); }

.section-icon { font-size: 15px; flex-shrink: 0; }

.section-title {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.section-count {
  font-size: 11px;
  background: var(--bg4);
  color: var(--text-muted);
  border-radius: 10px;
  padding: 1px 8px;
  min-width: 24px;
  text-align: center;
}

.section-caret {
  font-size: 12px;
  color: var(--text-muted);
  transition: transform .2s ease;
  flex-shrink: 0;
}
.section-hdr.collapsed .section-caret { transform: rotate(-90deg); }

.section-rows { border-top: 1px solid var(--border); }
.section-rows.collapsed { display: none; }

/* ===== CONTEST ROW ===== */
.contest-row {
  display: grid;
  grid-template-columns: 44px 1fr 1fr 110px 88px;
  align-items: stretch;
  gap: 0;
  min-height: 52px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  border-left: 3px solid transparent;
  cursor: pointer;
}
.contest-row:last-of-type { border-bottom: none; }
.contest-row:hover { background: rgba(255,255,255,.025); }

.contest-row.is-done { opacity: .55; }
.contest-row.is-done .row-title a { text-decoration: line-through; color: var(--text-muted); }
.contest-row.ends-today { border-left-color: var(--red); }

/* Row cells */
.row-check {
  width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
  border: none;
  flex-shrink: 0;
}
.check-box {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border2);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: transparent;
  background: transparent;
  transition: all var(--transition);
  user-select: none;
}
.row-check:hover .check-box {
  border-color: var(--green);
  color: var(--green);
}
.row-check.checked .check-box {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}
.row-check.checked:hover .check-box {
  background: var(--red-dim);
  border-color: var(--red-dim);
  color: var(--red);
}

.row-title {
  padding: 0 8px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  overflow: hidden;
}
.row-title-top {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.row-title a {
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--transition);
}
.row-title a:hover { color: var(--blue); }
.row-domain {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-note-badge {
  font-size: 11px;
  flex-shrink: 0;
  opacity: .6;
  cursor: default;
}

.row-prize {
  padding: 4px 8px;
  font-size: 11px;
  word-break: break-word;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}
.prize-desc { color: var(--green); }
.prize-note { color: var(--text-muted); font-size: 10px; }

.row-dates {
  padding: 0 8px;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
}
.row-dates-time {
  font-size: 11px;
  color: var(--orange);
  display: flex;
  align-items: center;
  gap: 4px;
}

.row-countdown {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--red);
}


.row-actions {
  padding: 0 6px;
  display: flex;
  align-items: center;
  gap: 1px;
}

.row-action-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 5px;
  transition: all var(--transition);
  opacity: 0;
}
.contest-row:hover .row-action-btn { opacity: 1; }
.row-action-btn:hover { background: var(--bg4); color: var(--text); }
.row-action-btn.has-notes { opacity: 1; color: var(--gold); }

.row-star {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: transparent;
  border: none;
  color: var(--border2);
  cursor: pointer;
  border-radius: 5px;
  transition: all var(--transition);
  opacity: 0;
  line-height: 1;
  flex-shrink: 0;
}
.contest-row:hover .row-star { opacity: 1; }
.row-star:hover { color: #f59e0b; }
.row-star.active { opacity: 1; color: #f59e0b; }
.contest-row.is-fav { border-left: 2px solid #f59e0b; }

/* ===== NOTES ROW ===== */
.notes-row {
  display: none;
  padding: 4px 16px 8px 60px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.notes-row.open { display: block; }
.notes-row::before {
  content: '';
  position: absolute;
  left: 36px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border2);
  opacity: .5;
}

.notes-list { margin-bottom: 6px; }

.note-item {
  font-size: 12px;
  color: var(--text-dim);
  padding: 3px 0 3px 10px;
  position: relative;
}
.note-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 8px;
  height: 1px;
  background: var(--border2);
  opacity: .5;
}
.note-meta { color: var(--text-muted); font-size: 10px; margin-right: 5px; }
.note-url-link { color: var(--blue); text-decoration: none; word-break: break-all; }
.note-url-link:hover { text-decoration: underline; }
.override-badge { cursor: help; }

.notes-add {
  display: flex;
  gap: 6px;
  padding-left: 10px;
}
.notes-add input { flex: 1; font-size: 12px; padding: 5px 9px; }

/* ===== EMPTY STATE ===== */
.empty-section {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ===== LOADING ===== */
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-muted);
  font-size: 13px;
  gap: 10px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border2);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* ===== WALK MODE + UNDO TOAST ===== */
.toast-action {
  margin-left: 10px;
  padding: 2px 10px;
  border-radius: var(--radius);
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
}
.toast-action:hover { background: rgba(255,255,255,.08); }

.walk-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg3);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 24px rgba(0,0,0,.5);
}
.walk-info {
  flex: 1;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.walk-time { color: var(--text-dim); }

@keyframes row-blink {
  0%,100% { background: transparent; }
  15%,45% { background: rgba(251,191,36,.13); box-shadow: inset 0 0 0 1px rgba(251,191,36,.35); }
  30%,60% { background: transparent; box-shadow: none; }
}
.row-flash { animation: row-blink .9s ease; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(16px);
  transition: transform var(--transition);
  box-shadow: var(--shadow);
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 16px; font-weight: 700; color: #fff; }

.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 5px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; }

.ai-row { display: flex; gap: 8px; margin-bottom: 14px; }
.ai-row input { flex: 1; }

.ai-status { font-size: 12px; color: var(--text-dim); margin-top: 4px; min-height: 18px; }
.ai-status.ok { color: var(--green); }
.ai-status.error { color: var(--red); }

.dup-warning {
  font-size: 12px;
  color: var(--orange);
  background: rgba(251,146,60,.08);
  border: 1px solid rgba(251,146,60,.3);
  border-radius: 6px;
  padding: 6px 10px;
  margin-top: 6px;
}

.fb-paste-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--bg3);
  border-radius: 6px;
  border-left: 2px solid var(--blue);
}

.form-label-hint { font-size: 11px; color: var(--text-muted); font-weight: 400; margin-left: 4px; }

.fb-instructions {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  padding: 6px 10px;
  background: var(--bg3);
  border-radius: 6px;
  border-left: 2px solid var(--blue);
  line-height: 1.5;
}
.fb-instructions kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 10px;
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: 3px;
  font-family: monospace;
}

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  pointer-events: all;
  animation: slide-in .2s ease;
  max-width: 300px;
  box-shadow: var(--shadow);
}
.toast.success { border-color: var(--green-dim); color: var(--green); }
.toast.error { border-color: var(--red-dim); color: #ffa0a0; }

@keyframes slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .contest-row {
    grid-template-columns: 44px 1fr 100px 0 80px;
  }
  .row-dates { display: none; }
}

@media (max-width: 640px) {
  .main { padding: 10px 12px; }
  .header { padding: 0 12px; }
  .header-logo { font-size: 15px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-bar { flex-wrap: wrap; }
  .stat-item { flex: none; width: 50%; border-right: none; border-bottom: 1px solid var(--border); }
}
