/* =========================================================
   index.css
   Styl pro HTML editor + náhled + modální okno
========================================================= */

:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1d212b;
  --panel-3: #232834;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #f2f4f8;
  --muted: #b7becb;
  --accent: #8ab4ff;
  --accent-2: #5d8df6;
  --ok: #a8d5a2;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

body {
  display: flex;
  gap: 14px;
  padding: 14px;
  overflow-x: hidden;
}

/* =========================================================
   Levá část – editor
========================================================= */

.editor {
  flex: 1 1 58%;
  min-width: 0;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topbuttons {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(23, 26, 33, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
}

/* =========================================================
   Tlačítka
========================================================= */

.admin-button,
.insert-button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  width: auto;
  min-width: 0;
  max-width: 100%;
  flex: 0 0 auto;
  white-space: nowrap;
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, #2a303d 0%, #212632 100%);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  transition: transform 0.12s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.admin-button:hover,
.insert-button:hover {
  background: linear-gradient(180deg, #343b4b 0%, #272d39 100%);
  border-color: rgba(138, 180, 255, 0.4);
  transform: translateY(-1px);
}

.admin-button:active,
.insert-button:active {
  transform: translateY(0);
}

.admin-button:focus-visible,
.insert-button:focus-visible,
.group summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.insert-button.big {
  font-weight: 700;
}

.group-buttons.tight {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(54px, max-content));
  gap: 8px;
}

.group-buttons .insert-button {
  width: auto;
  max-width: 100%;
  text-align: left;
}

/* =========================================================
   Rozbalovací skupiny
========================================================= */

.group {
  flex: 0 0 auto;
  min-width: 100px;
  max-width: 250px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
}

.group summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: 12px 14px;
  font-weight: 700;
  color: var(--text);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.02) 100%);
  border-bottom: 1px solid transparent;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.group summary::-webkit-details-marker {
  display: none;
}

.group[open] summary {
  border-bottom-color: var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.03) 100%);
}

.group summary::after {
  content: "▾";
  float: right;
  color: var(--muted);
  transition: transform 0.18s ease;
}

.group[open] summary::after {
  transform: rotate(180deg);
}

.group-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  padding: 12px;
}

/* =========================================================
   CodeMirror
========================================================= */

#html-code {
  display: none;
}

.CodeMirror {
  height: 62vh;
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.45;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.CodeMirror-gutters {
  border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
  background: #1a1f29 !important;
}

.CodeMirror-linenumber {
  color: #8f98aa !important;
}

.CodeMirror-cursor {
  border-left: 2px solid #ffffff !important;
}

/* =========================================================
   Pravá část – náhled
========================================================= */

.preview {
  flex: 1 1 42%;
  min-width: 0;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  display: flex;
  flex-direction: column;
}

#preview-frame {
  width: 100%;
  min-height: calc(100vh - 52px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

/* =========================================================
   Modal
========================================================= */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.72);
  padding: 24px;
}

.modal-content {
  position: relative;
  width: min(1200px, 100%);
  height: min(90vh, 100%);
  margin: 0 auto;
  background: #11151c;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

#modal-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.close {
  position: absolute;
  top: 10px;
  right: 14px;
  z-index: 10;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: background 0.18s ease, transform 0.12s ease;
}

.close:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.04);
}

/* =========================================================
   Tooltip
========================================================= */

.tooltip {
  position: fixed;
  z-index: 10000;
  max-width: min(340px, calc(100vw - 24px));
  background: rgba(20, 22, 28, 0.96);
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

.tooltip code {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffe08a;
  font-family: Consolas, Monaco, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

/* =========================================================
   Drobnosti
========================================================= */

::selection {
  background: rgba(138, 180, 255, 0.3);
}

a {
  color: var(--accent);
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
}

/* =========================================================
   Responzivita
========================================================= */

@media (max-width: 1100px) {
  body {
    flex-direction: column;
  }

  .editor,
  .preview {
    flex: 1 1 auto;
    width: 100%;
  }

  #preview-frame {
    min-height: 420px;
  }
}

@media (max-width: 700px) {
  body {
    padding: 8px;
    gap: 8px;
  }

  .editor,
  .preview {
    padding: 8px;
    border-radius: 12px;
  }

  .topbuttons {
    gap: 6px;
    padding-bottom: 8px;
  }

  .admin-button,
  .insert-button {
    width: auto;
    max-width: 100%;
    text-align: left;
  }

  .buttons {
    flex-direction: column;
  }

  .group {
    min-width: 100%;
    max-width: 100%;
  }

  .group-buttons {
    flex-direction: column;
    align-items: flex-start;
  }

  .group-buttons.tight {
    grid-template-columns: repeat(auto-fit, minmax(56px, 1fr));
  }

  .CodeMirror {
    height: 52vh;
    min-height: 300px;
    font-size: 14px;
  }

  .modal {
    padding: 10px;
  }

  .modal-content {
    height: 92vh;
  }

  .close {
    top: 8px;
    right: 8px;
  }
}