/* Samostatný dizajn admin rozhrania — nezávislý od frontendového style.css
   (ten je vyhradený len pre verejnú časť webu, pozri layout.php). */

html:has(body.admin-body) {
  font-size: 18px;
}

* { box-sizing: border-box; }

.admin-body {
  --a-bg: #0f1115;
  --a-sidebar: #0a0c0f;
  --a-surface: #1a1d23;
  --a-surface-alt: #20242c;
  --a-border: #2b2f38;
  --a-ink: #e8e6e2;
  --a-muted: #8b909b;
  --a-accent: #d1a869;
  --a-accent-ink: #1a1207;
  --a-danger: #e5534b;
  --a-danger-bg: #3a1d1b;

  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  background: var(--a-bg);
  color: var(--a-ink);
  min-height: 100vh;
}

.admin-body a { color: var(--a-accent); text-decoration: none; }
.admin-body img { max-width: 100%; }

.admin-shell {
  display: flex;
  min-height: 100vh;
}

.admin-nav-toggle-input { display: none; }

.admin-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--a-sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  border-right: 1px solid var(--a-border);
}

.admin-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--a-border);
  margin-bottom: 12px;
  color: var(--a-ink);
}

.admin-brand a { color: inherit; text-decoration: none; }
.admin-brand a:hover { color: var(--a-accent); }

.admin-nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  flex-shrink: 0;
}

.admin-nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--a-ink);
  border-radius: 2px;
}

.admin-sidebar nav {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.admin-sidebar nav a {
  padding: 12px 20px;
  color: var(--a-muted);
  font-size: 0.95rem;
}

.admin-sidebar nav a:hover,
.admin-sidebar nav a.active {
  color: #fff;
  background: rgba(255,255,255,0.06);
  border-left: 3px solid var(--a-accent);
}

.admin-nav-divider {
  margin: 16px 20px 6px;
  padding-top: 12px;
  border-top: 1px solid var(--a-border);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--a-ink);
}

.admin-logout {
  padding: 16px 20px 0;
  border-top: 1px solid var(--a-border);
  margin-top: 12px;
}

.admin-user {
  font-size: 0.85rem;
  color: var(--a-muted);
  margin-bottom: 10px;
}

.admin-logout button {
  width: 100%;
  background: transparent;
  border: 1px solid var(--a-border);
  color: var(--a-ink);
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}

.admin-logout button:hover { background: rgba(255,255,255,0.08); }

.admin-main {
  flex-grow: 1;
  padding: 32px 40px;
  max-width: 1100px;
  min-width: 0;
}

.admin-main .section-title { color: var(--a-ink); font-size: 1.25rem; font-weight: 700; }

.admin-auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.admin-card {
  background: var(--a-surface);
  border: 1px solid var(--a-border);
  border-radius: 12px;
  padding: 36px;
  width: 100%;
  max-width: 380px;
}

.admin-card h1 {
  font-size: 1.3rem;
  margin: 0 0 24px;
  color: var(--a-ink);
}

/* Logo has dark-navy lettering, so it sits on a light tile in the dark admin theme. */
.admin-login-logo {
  display: block;
  width: 140px;
  margin: 0 auto 24px;
  padding: 10px 14px;
  background: #fff;
  border-radius: 10px;
}

.admin-login-logo img { display: block; width: 100%; height: auto; }

.admin-form .checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  cursor: pointer;
}

.admin-form .checkbox-label input { margin: 0; width: 16px; height: 16px; accent-color: var(--a-accent); }

.admin-breadcrumbs { margin-bottom: 10px; font-size: 0.82rem; }

.admin-breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--a-muted);
}

.admin-breadcrumbs li + li::before { content: "›"; margin-right: 4px; }

.admin-breadcrumbs a:hover { text-decoration: underline; }

.admin-breadcrumbs [aria-current="page"] { color: var(--a-ink); }

.admin-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.admin-page-header h1 { margin: 0; font-size: 1.5rem; color: var(--a-ink); }

.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.admin-tabs a {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--a-border);
  color: var(--a-muted);
  font-size: 0.88rem;
}

.admin-tabs a.active {
  background: var(--a-accent);
  color: var(--a-accent-ink);
  border-color: var(--a-accent);
}

.admin-body .btn {
  display: inline-block;
  background: var(--a-accent);
  color: var(--a-accent-ink);
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
}

.admin-body .btn:hover { opacity: 0.88; }

.admin-body .btn-secondary {
  background: transparent;
  color: var(--a-ink);
  border: 1px solid var(--a-border);
}

.admin-body .btn-danger {
  background: var(--a-danger);
  color: #fff;
}

.admin-body .btn-icon {
  padding: 10px 14px;
  font-size: 1.1rem;
  line-height: 1;
}

.admin-form .field {
  margin-bottom: 18px;
}

.admin-form label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--a-ink);
}

.admin-form input[type=text],
.admin-form input[type=email],
.admin-form input[type=password],
.admin-form input[type=tel],
.admin-form input[type=number],
.admin-form input[type=url],
.admin-form input[type=date],
.admin-form input[type=file],
.admin-form select,
.admin-form textarea {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 10px 12px;
  border: 1px solid var(--a-border);
  border-radius: 8px;
  background: var(--a-surface);
  color: var(--a-ink);
}

.admin-form input::placeholder,
.admin-form textarea::placeholder {
  color: var(--a-muted);
}

.admin-form input:focus,
.admin-form select:focus,
.admin-form textarea:focus {
  outline: none;
  border-color: var(--a-accent);
}

/* Required-field marker (required_mark()) */
abbr.required {
  color: #ff8a80;
  text-decoration: none;
  border: 0;
  cursor: help;
}

.admin-form .hint {
  color: var(--a-muted);
  font-size: 0.82rem;
  margin-top: 4px;
}

.admin-form .error {
  color: #ff8a80;
  font-size: 0.85rem;
  margin-top: 4px;
}

.admin-form .current-file {
  font-size: 0.85rem;
  margin-bottom: 8px;
  color: var(--a-muted);
}

.admin-form .current-file img {
  max-width: 180px;
  height: auto;
  border-radius: 8px;
  display: block;
  margin-bottom: 6px;
  border: 1px solid var(--a-border);
}

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.alert-error {
  background: var(--a-danger-bg);
  color: #ff8a80;
}

.alert-success {
  background: #163a2c;
  color: #7fd8a3;
}

.admin-main table.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--a-surface);
  border: 1px solid var(--a-border);
  border-radius: 10px;
  overflow: hidden;
}

table.admin-table th,
table.admin-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--a-border);
  font-size: 0.92rem;
  color: var(--a-ink);
}

table.admin-table th {
  background: var(--a-surface-alt);
  font-weight: 600;
  color: var(--a-muted);
}

table.admin-table tr:last-child td { border-bottom: none; }

table.admin-table a { text-decoration: underline; }

table.admin-table a:hover { text-decoration: none; }

table.admin-table tr:hover td { background: rgba(255,255,255,0.02); }

.admin-table .actions {
  display: flex;
  gap: 10px;
  white-space: nowrap;
}

.admin-table .actions form { margin: 0; }

.admin-table .actions button.link {
  background: none;
  border: none;
  padding: 0;
  color: #ff8a80;
  cursor: pointer;
  font-size: 0.92rem;
  font-family: inherit;
  text-decoration: underline;
}

.admin-table .actions button.link:hover { text-decoration: none; }

.admin-empty {
  padding: 32px;
  margin-bottom: 20px;
  text-align: center;
  color: var(--a-muted);
  background: var(--a-surface);
  border: 1px dashed var(--a-border);
  border-radius: 10px;
}

.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.photo-gallery-item {
  margin: 0;
  background: var(--a-surface);
  border: 1px solid var(--a-border);
  border-radius: 10px;
  overflow: hidden;
}

.photo-gallery-item > a {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
}

.photo-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-gallery-item figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
}

.photo-gallery-item figcaption span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--a-muted);
}

.photo-gallery-item figcaption .actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.photo-gallery-item figcaption .actions form { margin: 0; }

.photo-gallery-item figcaption .actions button.link {
  background: none;
  border: none;
  padding: 0;
  color: #ff8a80;
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
  text-decoration: underline;
}

.photo-gallery-item figcaption .actions a { text-decoration: underline; color: var(--a-accent); }

.photo-gallery-item figcaption .actions a:hover,
.photo-gallery-item figcaption .actions button.link:hover { text-decoration: none; }

/* Stacked list on the photo-management page: thumbnail left, details right. */
.photo-gallery.photo-gallery--list {
  grid-template-columns: 1fr;
  gap: 12px;
}

.photo-gallery--list .photo-gallery-item {
  display: flex;
  align-items: stretch;
}

.photo-gallery--list .photo-gallery-item > a {
  flex: 0 0 200px;
}

.photo-gallery--list .photo-gallery-item figcaption {
  flex: 1;
  min-width: 0;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
}

.photo-gallery--list .photo-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.photo-gallery--list .photo-meta .photo-name { color: var(--a-ink); }

.photo-gallery--list .photo-title span {
  display: block;
  margin-bottom: 4px;
  font-size: 0.78rem;
}

.photo-gallery--list .photo-title input {
  width: 100%;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 7px 10px;
  border: 1px solid var(--a-border);
  border-radius: 8px;
  background: var(--a-surface-alt);
  color: var(--a-ink);
}

.photo-gallery--list .photo-title input:focus {
  outline: none;
  border-color: var(--a-accent);
}

.photo-title-status {
  display: inline-block;
  margin-left: 6px;
  font-style: normal;
  font-weight: 600;
  opacity: 0;
}

.photo-title-status.is-saving { color: var(--a-muted); opacity: 1; }

.photo-title-status.is-saved { color: #7fd18b; }

.photo-title-status.is-error { color: #ff8a80; opacity: 1; }

/* "Uložené ✓": pop in, hold, fade out. */
.photo-title-status.is-saved.is-animating {
  animation: photo-title-saved 2.2s ease-out forwards;
}

.photo-title-status.is-error.is-animating {
  animation: photo-title-shake 0.4s ease-in-out;
}

@keyframes photo-title-saved {
  0% { opacity: 0; transform: translateY(4px) scale(0.9); }
  12% { opacity: 1; transform: translateY(0) scale(1.08); }
  22% { transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes photo-title-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.photo-gallery--list .photo-title input { transition: border-color 0.3s; }

.photo-gallery--list .photo-title input.is-saved-flash { border-color: #7fd18b; }

@media (max-width: 600px) {
  .photo-gallery--list .photo-gallery-item { flex-direction: column; }
  .photo-gallery--list .photo-gallery-item > a { flex-basis: auto; }
}

/* "odoslať e-mailom" inside a PDF/DWG row: address select + link-style button */
.admin-table .actions .file-send-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.admin-table .actions .file-send-form select {
  max-width: 200px;
  font-family: inherit;
  font-size: 0.85rem;
  padding: 3px 6px;
  border: 1px solid var(--a-border);
  border-radius: 6px;
  background: var(--a-surface-alt);
  color: var(--a-ink);
}

.admin-table .actions button.link.link-accent { color: var(--a-accent); }

/* PhotoSwipe caption (popis fotografie), https://photoswipe.com/caption/ */
.pswp__custom-caption {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 600px;
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 16px;
  text-align: center;
}

.pswp__custom-caption[hidden] { display: none; }

/* Stav geometrického plánu */
.hint { color: var(--a-muted); font-size: 0.85rem; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.record-status-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--a-surface);
  border: 1px solid var(--a-border);
  border-radius: 10px;
}

.record-status-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.record-status-form select {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 7px 10px;
  border: 1px solid var(--a-border);
  border-radius: 8px;
  background: var(--a-surface-alt);
  color: var(--a-ink);
}

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge.status-received { background: #1d2c3f; color: #8cc4ff; }

.status-badge.status-in_progress { background: #3a2f17; color: var(--a-accent); }

.status-badge.status-done { background: #1b3322; color: #7fd18b; }

/* Viacriadková bunka (meno + e-mail + telefón) v zozname plánov */
table.admin-table td .cell-sub {
  display: block;
  color: var(--a-muted);
  font-size: 0.85rem;
}

.admin-body .dropzone {
  background: var(--a-surface);
  border: 2px dashed var(--a-border);
  border-radius: 10px;
  min-height: 120px;
  color: var(--a-muted);
}

.admin-body .dropzone.dz-drag-hover {
  border-color: var(--a-accent);
  background: var(--a-surface-alt);
}

.admin-body .dropzone .dz-message {
  margin: 2em 0;
  font-size: 0.95rem;
  color: var(--a-muted);
}

.admin-body .dropzone .dz-preview .dz-details {
  color: rgba(255, 255, 255, 0.92);
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 28px;
}

/* Compact tile: number and label side by side. */
.admin-stat {
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: var(--a-surface);
  border: 1px solid var(--a-border);
  border-radius: 8px;
  padding: 8px 12px;
  transition: border-color 0.15s, background 0.15s;
}

a.admin-stat:hover {
  border-color: var(--a-accent);
  background: var(--a-surface-alt);
}

.admin-stat .num {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--a-accent);
}

.admin-stat .label {
  color: var(--a-muted);
  font-size: 0.82rem;
}

.pagination {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.pagination a {
  padding: 6px 12px;
  border: 1px solid var(--a-border);
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--a-ink);
}

.pagination a:hover { border-color: var(--a-accent); color: var(--a-accent); }

/* --- Responzívne správanie -------------------------------------------- */

@media (max-width: 860px) {
  .admin-shell { flex-direction: column; min-height: auto; }

  .admin-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--a-border);
    padding: 14px 0;
  }

  .admin-brand { padding: 0 16px; border-bottom: none; margin-bottom: 0; }

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

  .admin-sidebar nav {
    flex-direction: column;
    max-height: 0;
    overflow: hidden;
    transition: max-height .2s ease;
  }

  .admin-nav-toggle-input:checked ~ .admin-shell .admin-sidebar nav,
  .admin-nav-toggle-input:checked ~ .admin-shell .admin-logout {
    max-height: 600px;
  }

  .admin-logout {
    max-height: 0;
    overflow: hidden;
    padding: 0 16px;
    border-top: none;
    margin-top: 0;
    transition: max-height .2s ease;
  }

  .admin-nav-toggle-input:checked ~ .admin-shell .admin-logout {
    padding: 12px 16px 0;
    border-top: 1px solid var(--a-border);
    margin-top: 8px;
  }

  .admin-main { padding: 20px 16px; }

  .admin-page-header h1 { font-size: 1.25rem; }

  table.admin-table { display: block; overflow-x: auto; white-space: nowrap; }

  table.admin-table.responsive-stack {
    white-space: normal;
    overflow-x: visible;
    border: none;
    background: transparent;
  }

  table.admin-table.responsive-stack thead { display: none; }

  table.admin-table.responsive-stack,
  table.admin-table.responsive-stack tbody,
  table.admin-table.responsive-stack tr,
  table.admin-table.responsive-stack td {
    display: block;
    width: 100%;
  }

  table.admin-table.responsive-stack tr {
    margin-bottom: 14px;
    border: 1px solid var(--a-border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--a-surface);
  }

  table.admin-table.responsive-stack td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--a-border);
    padding: 10px 14px;
    text-align: right;
    overflow-wrap: anywhere;
  }

  table.admin-table.responsive-stack td > * { min-width: 0; }

  /* Row without any action — don't render an empty card line. */
  table.admin-table.responsive-stack td.actions:not(:has(*)) { display: none; }

  table.admin-table.responsive-stack td:last-child { border-bottom: none; }

  table.admin-table.responsive-stack td.actions {
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
  }

  table.admin-table.responsive-stack td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--a-muted);
    text-align: left;
    flex-shrink: 0;
  }
}

@media (max-width: 480px) {
  html:has(body.admin-body) { font-size: 16px; }

  .admin-card { padding: 24px; }
}

.status-heading {
  font-size: 1.05rem;
  margin: 28px 0 10px;
}

.status-table { max-width: 900px; }
.status-table th { width: 220px; text-align: left; font-weight: 600; vertical-align: top; }
.status-table td { white-space: normal; overflow-wrap: anywhere; }

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
}

.status-dot.is-ok { background: #7fd8a3; }
.status-dot.is-off { background: var(--a-danger); }
