/* ── Variables (Žacláněno dle yamahamusicschool.cz) ──────── */
:root {
  --purple:      #622c93;   /* brand primary  */
  --purple-dark: #311b92;   /* brand dark / topbar */
  --purple-light:#9575cd;
  --purple-faint:#ede7f6;
  --accent:      #ffd740;   /* gold accent */
  --text:        #212121;
  --muted:       #757575;
  --border:      #e0e0e0;
  --radius:      8px;
  --shadow:      0 2px 8px rgba(98,44,147,.12);
}

/* ── Reset / Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Nunito Sans', 'Inter', 'Segoe UI', system-ui, sans-serif; background: #fafafa; color: var(--text); }
h1, h2, h3 { font-family: 'Nunito Sans', 'Inter', 'Segoe UI', system-ui, sans-serif; font-weight: 700; }
a { color: var(--purple); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ──────────────────────────────────────────────────── */
.layout { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  background: var(--purple);
  color: #fff;
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
  letter-spacing: .01em;
}
.topbar .brand { font-size: 1.2rem; font-weight: 700; letter-spacing: .03em; margin-right: auto; }
.topbar .user-badge { font-size: .85rem; opacity: .85; }

.main-content { padding: 1.5rem 2rem; max-width: min(96vw, 1800px); margin: 0 auto; width: 100%; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 1rem; font-weight: 600; color: var(--purple); margin-bottom: 1rem; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary {
  background: var(--purple);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: .55rem 1.4rem;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover:not(:disabled) { background: var(--purple-dark); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }

.btn-outline {
  background: transparent;
  color: var(--purple);
  border: 2px solid var(--purple);
  border-radius: var(--radius);
  padding: .45rem 1.2rem;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-outline:hover { background: var(--purple); color: #fff; }

.btn-logout {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,.5);
  border-radius: var(--radius);
  padding: .4rem 1rem;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.3); text-decoration: none; }

/* ── Forms ───────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.field label { font-size: .85rem; font-weight: 600; color: var(--muted); }
.field input[type=text], .field input[type=password] {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .75rem;
  font-size: .95rem;
  outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--purple); box-shadow: 0 0 0 2px rgba(106,13,173,.15); }
.field-checkbox { flex-direction: row; align-items: center; }
.field-checkbox label { display: flex; align-items: center; gap: .4rem; font-weight: 400; color: var(--text); cursor: pointer; }
.field-checkbox input[type=checkbox] { width: auto; margin: 0; }

fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
legend { padding: 0 .5rem; font-size: .85rem; font-weight: 700; color: var(--purple); }

/* ── Login page ──────────────────────────────────────────────── */
.login-card {
  max-width: 440px;
  margin: 4rem auto;
  background: #fff;
  border-radius: var(--radius);
  padding: 2.5rem;
  box-shadow: var(--shadow);
}
.login-card h1 { color: var(--purple); font-size: 1.8rem; margin-bottom: .3rem; }
.login-card .subtitle { color: var(--muted); font-size: .9rem; margin-bottom: 1.5rem; }
.login-card .btn-primary { width: 100%; padding: .7rem; font-size: 1rem; margin-top: .5rem; }
.login-card .btn-outline { padding: .7rem 1.2rem; font-size: 1rem; margin-top: .5rem; }
.login-step button + button { margin-left: .5rem; }
.login-step fieldset { margin-bottom: 1rem; }

/* ── Dashboard ───────────────────────────────────────────────── */
.dashboard h1 { font-size: 1.5rem; font-weight: 700; color: var(--purple); margin-bottom: 1.5rem; }

.action-row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.toggle-label { font-size: .9rem; display: flex; align-items: center; gap: .4rem; cursor: pointer; }
.progress-indicator { margin-top: .4rem; color: var(--purple-light); font-size: .85rem; }

/* Animated indeterminate progress bar */
.job-progress {
  margin-top: .75rem;
  height: 4px;
  background: var(--purple-faint);
  border-radius: 2px;
  overflow: hidden;
}
.job-progress-bar {
  height: 100%;
  width: 40%;
  background: var(--purple);
  border-radius: 2px;
  animation: progress-slide 1.4s ease-in-out infinite;
}
@keyframes progress-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* Schedule status badge */
.schedule-header { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.schedule-header h2 { margin-bottom: 0; }
.schedule-status-badge {
  font-size: .78rem;
  font-weight: 700;
  padding: .2rem .6rem;
  border-radius: 999px;
  letter-spacing: .02em;
}
.schedule-status-badge.on  { background: #dcfce7; color: #15803d; }
.schedule-status-badge.off { background: #f1f5f9; color: #94a3b8; }
.card-schedule-on { border-left: 3px solid #22c55e; }
.approval-row { margin-top: 1rem; padding: .75rem 1rem; background: #fff8e1; border: 1px solid #ffe082; border-radius: var(--radius); display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.approval-label { font-size: .9rem; font-weight: 500; }
.conflict-warning { margin-top: .75rem; padding: .6rem 1rem; background: #fff1f2; border: 1px solid #fecaca; border-radius: var(--radius); color: #991b1b; font-size: .88rem; }

.log-panel {
  background: #1a1a2e;
  color: #e0d7ff;
  border-radius: var(--radius);
  padding: 1rem;
  font-size: .82rem;
  line-height: 1.6;
  white-space: pre;
  overflow: auto;
  height: clamp(200px, 50vh, 600px);
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}
.log-header h2 { margin-bottom: 0; }

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .3rem .75rem;
  font-size: .8rem;
  cursor: pointer;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--purple-faint); color: var(--purple); border-color: var(--purple); }

.schedule-row { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; }
.semester-row { display: flex; gap: .75rem; align-items: center; margin-top: .6rem; flex-wrap: wrap; }
.semester-select {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .3rem .6rem;
  font-size: .88rem;
  color: var(--text);
  background: #fff;
  cursor: pointer;
  min-width: 220px;
}
.semester-select:focus { border-color: var(--purple); outline: none; }
.semester-loading { font-size: .85rem; color: var(--muted); font-style: italic; }
/* ── Danger button ───────────────────────────────────────────── */
.btn-danger {
  background: #c0392b;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: .55rem 1.4rem;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-danger:hover:not(:disabled) { background: #96281b; }
.btn-danger:disabled { opacity: .55; cursor: not-allowed; }

/* ── Topbar nav links ────────────────────────────────────────── */
.nav-link {
  color: #fff;
  font-size: .88rem;
  opacity: .85;
  padding: .3rem .7rem;
  border-radius: calc(var(--radius) / 2);
  transition: background .15s, opacity .15s;
}
.nav-link:hover { background: rgba(255,255,255,.18); opacity: 1; text-decoration: none; }.schedule-row label { font-size: .9rem; display: flex; align-items: center; gap: .4rem; }
.schedule-row input[type=number] { border: 1px solid var(--border); border-radius: 4px; padding: .3rem; }

/* ── Badges / alerts ─────────────────────────────────────────── */
.badge-ok { color: #16a34a; font-weight: 600; font-size: .9rem; }
.badge-pending { color: #b45309; font-weight: 600; font-size: .88rem; }
.alert-error {
  background: #fee2e2;
  color: #b91c1c;
  border-radius: var(--radius);
  padding: .6rem .9rem;
  font-size: .9rem;
  margin-bottom: .9rem;
}

/* ── History table ───────────────────────────────────────────── */
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.history-table th {
  text-align: left;
  padding: .45rem .75rem;
  background: var(--purple-faint);
  color: var(--purple-dark);
  font-weight: 600;
  border-bottom: 2px solid var(--purple-light);
}
.history-table td {
  padding: .4rem .75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.history-table tbody tr:hover { background: #faf5ff; }
.history-table .row-changed td { background: #f0fdf4; }
.history-table .row-error   td { background: #fff1f2; }
.history-table .row-clickable { cursor: pointer; }
.history-table .expand-cell { width: 1.5rem; text-align: center; color: var(--muted); }
.history-table .run-log-row td { padding: 0; }
.run-log { max-height: 300px; overflow-y: auto; margin: 0; border-radius: 0; font-size: .8rem; }

.source-badge {
  display: inline-block;
  font-size: .75rem;
  font-weight: 600;
  padding: .1rem .45rem;
  border-radius: 999px;
}
.source-manual { background: var(--purple-faint); color: var(--purple-dark); }
.source-auto   { background: #e0f2fe; color: #0369a1; }

/* ── Reconciliation workbench ───────────────────────────────────────────── */
.reconciliation-workbench { padding-bottom: .5rem; }
.reconciliation-intro { margin-top: .25rem; color: var(--muted); font-size: .86rem; }
.reconciliation-selection-actions { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.reconciliation-table-section { border-top: 1px solid var(--border); padding: 1rem 0; }
.reconciliation-table-section:first-of-type { border-top: 0; padding-top: 0; }
.reconciliation-table-heading { display: flex; align-items: baseline; gap: .65rem; margin-bottom: .55rem; }
.reconciliation-table-heading h3 { color: var(--text); font-size: .94rem; font-weight: 700; }
.reconciliation-table-heading h3 span { color: var(--muted); font-size: .78rem; font-weight: 600; }
.reconciliation-table-heading p { color: var(--muted); font-size: .8rem; }
.reconciliation-table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.reconciliation-table { width: 100%; min-width: 950px; border-collapse: collapse; font-size: .83rem; }
.reconciliation-table th { text-align: left; padding: .45rem .6rem; background: #f8f6fb; color: var(--purple-dark); font-size: .74rem; font-weight: 700; white-space: nowrap; border-bottom: 1px solid var(--border); }
.reconciliation-table td { padding: .5rem .6rem; vertical-align: top; border-bottom: 1px solid var(--border); }
.reconciliation-table tbody tr:last-child td { border-bottom: 0; }
.reconciliation-table tbody tr:hover td { background: #fcfbfd; }
.reconciliation-table .selection-cell { width: 4.5rem; text-align: center; }
.reconciliation-table .details-cell { width: 4rem; text-align: center; }
.reconciliation-table .links-cell { width: 8rem; white-space: nowrap; }
.reconciliation-table .links-cell a { margin-right: .5rem; font-weight: 700; font-size: .78rem; }
.reconciliation-table .links-cell a:last-child { margin-right: 0; }
.table-sort { display: inline-flex; align-items: center; gap: .3rem; border: 0; background: transparent; color: inherit; font: inherit; font-weight: inherit; cursor: pointer; }
.table-sort:hover { color: var(--purple); }
.table-sort:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.detail-toggle { min-width: 2rem; padding: .2rem .4rem; color: var(--purple); font-size: .9rem; }
.reconciliation-table input[type=checkbox] { accent-color: var(--purple); cursor: pointer; }
.program-abbreviation { display: inline-block; margin-left: .35rem; color: var(--muted); font-family: monospace; font-size: .75rem; }
.reconciliation-state { display: inline-block; font-size: .76rem; font-weight: 700; line-height: 1.3; }
.reconciliation-state.state-insync { color: #15803d; }
.reconciliation-state.state-updateavailable { color: #92400e; }
.reconciliation-state.state-createavailable { color: #1d4ed8; }
.reconciliation-state.state-blocked { color: #b91c1c; }
.reconciliation-state.state-deletecandidate { color: #b45309; }
.state-blocked td { background: #fffafa; }
.state-deletecandidate td { background: #fffdf5; }
.mapping-issues { margin: .35rem 0 0; padding-left: 1rem; color: #b91c1c; font-size: .75rem; line-height: 1.4; }
.field-selection { display: flex; align-items: center; gap: .35rem .55rem; flex-wrap: wrap; min-width: 210px; }
.field-selection label { display: inline-flex; align-items: center; gap: .25rem; white-space: nowrap; color: var(--text); font-size: .78rem; }
.reconciliation-detail-row td { background: #fbf9fd; padding: .8rem 1rem; }
.reconciliation-detail-row:hover td { background: #fbf9fd !important; }
.change-details { display: grid; gap: .75rem; }
.change-comparison h4 { margin-bottom: .35rem; color: var(--purple-dark); font-size: .82rem; }
.change-values { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.change-values > div > span { display: block; margin-bottom: .2rem; color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.change-value { max-height: 9rem; overflow: auto; padding: .45rem .55rem; background: #fff; border: 1px solid var(--border); border-radius: 4px; color: var(--text); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .76rem; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ── Status summary ──────────────────────────────────────────── */
.status-summary {
  margin-top: .75rem;
  padding: .5rem .75rem;
  background: var(--purple-faint);
  border-radius: var(--radius);
  font-size: .88rem;
}
.status-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.status-row + .status-row { margin-top: .35rem; }
.status-label { color: var(--muted); font-weight: 500; }
.status-sep   { color: var(--muted); }

.status-chip {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
}
.chip-ok    { background: #dcfce7; color: #166534; }
.chip-sync  { background: #dbeafe; color: #1e40af; }
.chip-warn  { background: #fef3c7; color: #92400e; }
.chip-error { background: #fee2e2; color: #991b1b; }

/* ── Version footer ──────────────────────────────────────────── */
.version-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .5rem 1.5rem;
  background: var(--purple);
  color: rgba(255,255,255,.7);
  font-size: .75rem;
  margin-top: auto;
}
.version-meta {
  display: flex;
  gap: .5rem;
  font-family: monospace;
  font-size: .7rem;
  letter-spacing: .03em;
  opacity: .85;
}

@media (max-width: 720px) {
  .main-content { padding: 1rem; max-width: 100%; }
  .card { padding: 1rem; }
  .reconciliation-table-heading { align-items: flex-start; flex-direction: column; gap: .2rem; }
  .reconciliation-table-heading p { line-height: 1.4; }
  .reconciliation-selection-actions { justify-content: flex-start; }
  .change-values { grid-template-columns: 1fr; }
}
