@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --c-bg: #0A1628;
  --c-panel: #FFFFFF;
  --c-page: #F2F4F7;
  --c-accent: #2E9BF0;
  --c-accent-dark: #1C7DD1;
  --c-steel: #64748B;
  --c-border: #E4E7EC;
  --c-text: #101828;
  --c-danger: #E15353;
  --c-success: #1E8E5A;
  --f-display: 'Space Grotesk', sans-serif;
  --f-body: 'Inter', sans-serif;
  --f-mono: 'JetBrains Mono', monospace;
  --radius: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--f-body); background: var(--c-page); color: var(--c-text); }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; }

/* Atribut [hidden] musí mít vždy přednost před display: flex/grid
   nastaveným v komponentových pravidlech níže — jinak se prvek
   nikdy doopravdy neskryje. */
[hidden] { display: none !important; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-bg);
  background-image: radial-gradient(ellipse 700px 400px at 20% 20%, rgba(242,183,5,0.12), transparent 60%);
}
.login-box {
  width: 380px;
  max-width: calc(100vw - 32px);
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(247,248,250,0.1);
  border-radius: 10px;
  padding: 40px 36px;
  backdrop-filter: blur(8px);
  box-sizing: border-box;
}
.login-logo {
  font-family: var(--f-mono);
  color: #F7F8FA;
  font-size: 15px;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
}
.login-logo .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c-accent); }
.login-logo-sub { color: var(--c-steel); font-weight: 400; }
.login-box h1 {
  font-family: var(--f-display);
  font-size: 20px;
  color: #F7F8FA;
  margin-bottom: 8px;
}
.login-hint { color: var(--c-steel); font-size: 13.5px; margin-bottom: 24px; }
.login-box input {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(247,248,250,0.15);
  background: rgba(247,248,250,0.05);
  color: #F7F8FA;
  margin-bottom: 16px;
}
.login-box input:focus { outline: none; border-color: var(--c-accent); }
.login-error { color: var(--c-danger); font-size: 13.5px; margin-top: 14px; min-height: 18px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 22px; border-radius: var(--radius); border: none;
  font-weight: 600; font-size: 14px; width: 100%; transition: all 0.2s;
}
.btn-primary { background: var(--c-accent); color: #101820; }
.btn-primary:hover { background: var(--c-accent-dark); }
.btn-outline-small {
  border: 1px solid var(--c-border); padding: 9px 14px; border-radius: var(--radius);
  font-size: 13px; color: var(--c-text); width: 100%; text-align: center; display: block;
}
.btn-ghost-small {
  border: none; background: none; color: var(--c-steel); font-size: 13px; padding: 9px 14px; width: 100%;
}
.btn-ghost-small:hover { color: var(--c-danger); }
.btn-small {
  padding: 8px 14px; border-radius: var(--radius); border: 1px solid var(--c-border);
  background: #fff; font-size: 13px; width: auto;
}
.btn-small:hover { border-color: var(--c-accent-dark); }
.btn-small.danger { color: var(--c-danger); border-color: rgba(225,83,83,0.3); }
.btn-small.danger:hover { background: rgba(225,83,83,0.06); }

/* ---------- Admin layout ---------- */
.admin-app { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 240px;
  background: var(--c-bg);
  color: #F7F8FA;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.admin-logo {
  font-family: var(--f-mono);
  font-size: 14px;
  letter-spacing: 0.04em;
  display: flex; align-items: center; gap: 8px;
  padding: 0 8px 24px;
  border-bottom: 1px solid rgba(247,248,250,0.1);
  margin-bottom: 16px;
}
.admin-logo .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c-accent); }
.admin-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.admin-nav button {
  text-align: left; background: none; border: none; color: rgba(247,248,250,0.65);
  padding: 11px 12px; border-radius: var(--radius); font-size: 14px;
}
.admin-nav button:hover { background: rgba(247,248,250,0.06); color: #F7F8FA; }
.admin-nav button.active { background: rgba(242,183,5,0.12); color: var(--c-accent); font-weight: 600; }
.admin-sidebar-footer { display: flex; flex-direction: column; gap: 8px; padding-top: 16px; border-top: 1px solid rgba(247,248,250,0.1); }

.admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.admin-topbar {
  height: 68px; background: var(--c-panel); border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; position: sticky; top: 0; z-index: 10; gap: 16px;
}
#admin-tab-title { font-family: var(--f-display); font-weight: 600; font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-topbar-actions { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.admin-topbar-actions .btn { width: auto; padding: 11px 24px; }
.save-status { font-size: 13px; color: var(--c-steel); }
.save-status.success { color: var(--c-success); }
.save-status.error { color: var(--c-danger); }

.admin-menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: #fff;
  -webkit-tap-highlight-color: transparent;
}
.admin-menu-toggle span { width: 18px; height: 2px; background: var(--c-text); border-radius: 1px; }
.admin-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 40, 0.5);
  z-index: 199;
}
.admin-sidebar-overlay.open { display: block; }

.admin-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.admin-content {
  padding: 32px;
  max-width: 880px;
  flex: 1;
  overflow-y: auto;
  min-width: 0;
}

/* ---------- Živý náhled webu ---------- */
.admin-preview {
  width: 42%;
  min-width: 360px;
  max-width: 640px;
  border-left: 1px solid var(--c-border);
  background: var(--c-page);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.admin-preview.hidden { display: none; }
.admin-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--c-border);
  background: #fff;
  flex-shrink: 0;
}
.admin-preview-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--c-steel);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.admin-preview-size-toggle {
  display: flex;
  gap: 4px;
  background: var(--c-page);
  border-radius: var(--radius);
  padding: 3px;
}
.admin-preview-size-toggle button {
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  background: none;
  font-size: 12px;
  color: var(--c-steel);
}
.admin-preview-size-toggle button.active {
  background: #fff;
  color: var(--c-text);
  box-shadow: 0 1px 2px rgba(16,24,40,0.08);
}
.admin-preview-frame-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 16px;
  background: #d8dde3;
}
.admin-preview-frame-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(16,24,40,0.15);
  transition: width 0.25s ease, max-width 0.25s ease;
}
.admin-preview.size-mobile .admin-preview-frame-wrap iframe {
  max-width: 390px;
  height: 100%;
}

@media (max-width: 1200px) {
  .admin-preview { width: 38%; min-width: 300px; }
}

/* ---------- Form building blocks ---------- */
.field-group { margin-bottom: 22px; }
.field-group label {
  display: block; font-size: 13px; font-weight: 600; color: var(--c-steel);
  margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.03em;
}
.field-group input[type="text"],
.field-group input[type="email"],
.field-group input[type="tel"],
.field-group input[type="url"],
.field-group textarea,
.field-group select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--c-border);
  border-radius: var(--radius); background: #fff; font-size: 14.5px;
}
.field-group input:focus, .field-group textarea:focus, .field-group select:focus {
  outline: none; border-color: var(--c-accent-dark);
}
.field-group textarea { min-height: 90px; resize: vertical; }
.field-hint { font-size: 12.5px; color: var(--c-steel); margin-top: 6px; font-weight: 400; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.card-panel {
  background: #fff; border: 1px solid var(--c-border); border-radius: 10px;
  padding: 24px; margin-bottom: 18px;
}
.card-panel-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px;
}
.card-panel-head h3 { font-family: var(--f-display); font-size: 15px; }

.repeater-item {
  border: 1px solid var(--c-border); border-radius: 8px; padding: 20px; margin-bottom: 14px; position: relative; background: #FCFCFD;
}
.repeater-item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.repeater-item-head .tag {
  font-family: var(--f-mono); font-size: 12px; color: var(--c-accent-dark);
  background: rgba(242,183,5,0.12); padding: 4px 10px; border-radius: 100px;
}
.add-item-btn {
  display: flex; align-items: center; gap: 8px; padding: 12px 16px;
  border: 1px dashed var(--c-border); border-radius: 8px; background: none;
  width: 100%; color: var(--c-steel); font-size: 14px; justify-content: center;
}
.add-item-btn:hover { border-color: var(--c-accent-dark); color: var(--c-accent-dark); }

.section-desc { color: var(--c-steel); font-size: 14px; margin-bottom: 24px; max-width: 620px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.theme-swatch-row { display: flex; align-items: center; gap: 12px; }
.theme-swatch-row input[type="color"] {
  width: 44px; height: 44px; border: 1px solid var(--c-border); border-radius: 8px; padding: 2px; background: #fff;
}
.theme-swatch-row input[type="text"] { flex: 1; font-family: var(--f-mono); }

.theme-size-row { display: flex; align-items: center; gap: 14px; }
.theme-size-row input[type="range"] { flex: 1; }
.theme-size-value {
  font-family: var(--f-mono); font-size: 13px; color: var(--c-steel);
  min-width: 48px; text-align: right; flex-shrink: 0;
}
.hero-bg-swatch {
  width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--c-border); flex-shrink: 0;
}

/* ---------- Image upload / gallery album editing ---------- */
.image-upload { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.upload-status { font-size: 12.5px; color: var(--c-steel); }
.cover-preview { margin-bottom: 10px; }
.cover-preview img {
  width: 100%; max-width: 220px; height: 130px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--c-border);
}
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.album-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--c-border);
}
.album-thumb img { width: 100%; height: 100%; object-fit: cover; }
.album-thumb-remove {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(16,24,40,0.75); color: #fff;
  font-size: 15px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.album-thumb-remove:hover { background: var(--c-danger); }

/* ---------- Nahrát fotky (zásobárna nezařazených fotek) ---------- */
.media-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}
.media-library-item {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}
.media-library-item img {
  width: 100%;
  height: 120px;
  object-fit: cover;
}
.media-library-item-actions {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.media-library-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: 13px;
  background: #fff;
}

@media (max-width: 900px) {
  .admin-app { position: relative; }

  .admin-menu-toggle { display: flex; }

  .admin-sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: 82%;
    max-width: 300px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 8px 0 24px rgba(0,0,0,0.25);
  }
  .admin-sidebar.open { transform: translateX(0); }

  .admin-topbar { padding: 0 16px; height: 60px; }
  #admin-tab-title { font-size: 16px; }
  .admin-topbar-actions { gap: 10px; }
  .admin-topbar-actions .btn { padding: 10px 16px; font-size: 13.5px; }
  .save-status { display: none; }
  .save-status.success, .save-status.error { display: inline; font-size: 12px; }

  .admin-content { padding: 18px; max-width: 100%; }
  .card-panel { padding: 18px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .repeater-item { padding: 16px; }

  /* Inputy o něco vyšší na mobilu, ať se do nich dobře trefí prst
     a při focusu se pohodlně otevře klávesnice. */
  .field-group input[type="text"],
  .field-group input[type="email"],
  .field-group input[type="tel"],
  .field-group input[type="url"],
  .field-group textarea,
  .field-group select {
    font-size: 16px; /* 16px+ zabraňuje iOS Safari automatickému přiblížení při focusu */
    padding: 13px 14px;
  }

  .album-grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
  .theme-swatch-row { flex-wrap: wrap; }

  /* Na mobilu není pro náhled vedle formuláře místo — schováme ho
     a necháme jen tlačítko "Zobrazit web" v postranním menu, kterým
     si Milan otevře plnohodnotný web v nové záložce. */
  .admin-body { flex-direction: column; }
  .admin-preview { display: none !important; }
  #preview-toggle-btn { display: none; }

  /* Malá tlačítka (upload, odebrat, atd.) dostávají na mobilu
     vyšší minimální dotykovou plochu — na desktopu se ovládají
     myší, kde je to v pořádku i menší, ale na mobilu je potřeba
     alespoň ~40px kvůli přesnosti dotyku prstem. */
  .btn-small { min-height: 40px; padding: 9px 14px; }
  .add-item-btn { min-height: 48px; }
  .album-thumb-remove { width: 28px; height: 28px; font-size: 18px; }
  .repeater-item-head { flex-wrap: wrap; gap: 8px; }
}

@media (max-width: 400px) {
  .admin-content { padding: 14px; }
  .card-panel { padding: 14px; }
  #admin-tab-title { font-size: 15px; }
  .admin-topbar-actions .btn { padding: 9px 12px; font-size: 13px; }
  .login-box { padding: 28px 22px; }
}

/* Vstupní pole na 16px+ velikosti fontu na všech mobilních
   šířkách — iOS Safari jinak automaticky přiblíží stránku při
   kliknutí do inputu s menším fontem, což je matoucí. */
@media (max-width: 900px) {
  .login-box input,
  .btn {
    font-size: 16px;
  }
}

/* ---------- Editor obrázků (modální okno) ---------- */
.img-editor-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 40, 0.72);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.img-editor-modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 880px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.img-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}
.img-editor-header h3 { font-family: var(--f-display); font-size: 17px; }
.img-editor-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none; background: var(--c-page);
  font-size: 20px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  color: var(--c-steel);
}
.img-editor-close:hover { background: rgba(225,83,83,0.1); color: var(--c-danger); }

.img-editor-body {
  display: flex;
  gap: 24px;
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}
.img-editor-canvas-wrap {
  position: relative;
  flex: 1.4;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-conic-gradient(#eee 0% 25%, #fafafa 0% 50%) 50% / 20px 20px;
  border-radius: 8px;
  min-height: 320px;
}
.img-editor-canvas { display: block; max-width: 100%; }

.img-editor-cropbox {
  position: absolute;
  border: 2px solid var(--c-accent);
  box-shadow: 0 0 0 2000px rgba(10, 22, 40, 0.45);
  cursor: move;
  touch-action: none;
}
.img-editor-handle {
  position: absolute;
  width: 18px; height: 18px;
  background: #fff;
  border: 2px solid var(--c-accent);
  border-radius: 50%;
  touch-action: none;
}
.handle-nw { top: -10px; left: -10px; cursor: nwse-resize; }
.handle-ne { top: -10px; right: -10px; cursor: nesw-resize; }
.handle-sw { bottom: -10px; left: -10px; cursor: nesw-resize; }
.handle-se { bottom: -10px; right: -10px; cursor: nwse-resize; }

.img-editor-controls {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.img-editor-row { display: flex; flex-direction: column; gap: 8px; }
.img-editor-row label {
  font-size: 12.5px; font-weight: 600; color: var(--c-steel);
  text-transform: uppercase; letter-spacing: 0.03em;
}
.img-editor-row input[type="range"] { width: 100%; }
.img-editor-row select {
  padding: 10px 12px; border: 1px solid var(--c-border); border-radius: var(--radius); font-size: 14px; background: #fff;
}
.img-editor-slider-with-value { display: flex; align-items: center; gap: 10px; }
.img-editor-slider-with-value input[type="range"] { flex: 1; }
.img-editor-value { font-family: var(--f-mono); font-size: 12.5px; color: var(--c-steel); min-width: 42px; text-align: right; }

.img-editor-aspect-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.img-editor-aspect-btn {
  padding: 7px 12px; border: 1px solid var(--c-border); border-radius: 100px;
  font-size: 12.5px; background: #fff; color: var(--c-text);
}
.img-editor-aspect-btn:hover { border-color: var(--c-accent-dark); }
.img-editor-aspect-btn.active { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }

.img-editor-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 22px;
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
}
.img-editor-footer .btn-small { width: auto; }
.img-editor-footer .btn { width: auto; padding: 11px 22px; }

@media (max-width: 760px) {
  .img-editor-body { flex-direction: column; padding: 16px; gap: 16px; }
  .img-editor-canvas-wrap { min-height: 260px; }
  .img-editor-modal { max-height: 96vh; }
  .img-editor-footer { padding: 14px 16px; }
  .img-editor-footer .btn-small,
  .img-editor-footer .btn { flex: 1; }
  .img-editor-close { width: 40px; height: 40px; }
  .img-editor-handle { width: 26px; height: 26px; }
  .handle-nw { top: -14px; left: -14px; }
  .handle-ne { top: -14px; right: -14px; }
  .handle-sw { bottom: -14px; left: -14px; }
  .handle-se { bottom: -14px; right: -14px; }
}

/* ---------- Hero: editor zvýraznění písmen v nadpisu ---------- */
.hero-highlight-row {
  align-items: end;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--c-border);
}
.hero-highlight-row:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.hero-highlight-word {
  padding: 11px 14px;
  background: var(--c-page);
  border-radius: var(--radius);
  font-family: var(--f-mono);
  font-size: 14px;
  color: var(--c-text);
}
.hero-highlight-row input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: 14.5px;
}
.hero-highlight-preview {
  margin-top: 16px;
  padding: 20px;
  background: var(--c-bg);
  border-radius: var(--radius);
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 20px;
  color: #fff;
  text-align: center;
  line-height: 1.4;
}
.hero-highlight-red { color: #E4463A; }
