/**
 * Mini CMS — Public styles
 * Includes: base layout, components, dark mode, gallery lightbox.
 */

/* HTML5 hidden attr: kõrgema specificity reeglid (nt display:inline-flex) ei kirjuta üle */
[hidden] { display: none !important; }

/* ── CSS Variables (light mode defaults) ──────────────────── */
:root {
  --bg: var(--site-bg-color, #ffffff);
  --bg-surface: var(--site-bg-surface, #f5f5f5);
  --bg-card: var(--site-bg-color, #ffffff);
  --text: #1a1a1a;
  --text-muted: #666666;
  --border: #dddddd;
  /* Site branding colors - use injected values with fallbacks */
  --primary: var(--site-primary, #2563eb);
  --primary-hover: var(--site-secondary, #1d4ed8);
  --radius: var(--site-radius, 8px);
  --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, .12);
  --transition: .2s ease;
  --text-sm: 0.9rem;
  /* Ühtne ülariba (Mini CMS chrome) — tumeroheline, hea kontrast */
  --mcms-topbar-bg: #2c402f;
  --mcms-topbar-bg-hover: #384a3d;
  --mcms-topbar-text: #f2f7f3;
  --mcms-topbar-text-muted: #b8c9bc;
  --mcms-topbar-border: rgba(255, 255, 255, 0.14);
  --mcms-topbar-accent: #8fd99a;
  --mcms-topbar-height: 40px;
}

/* ── Dark mode (system) ───────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  body:not([data-theme="light"]) {
    --bg: #0f172a;
    --bg-surface: #1e293b;
    --bg-card: #1e293b;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #334155;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --shadow: 0 1px 3px rgba(0, 0, 0, .3);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, .4);
  }
}

/* ── Dark mode (forced via settings) ─────────────────────── */
body[data-theme="dark"] {
  --bg: #0f172a;
  --bg-surface: #1e293b;
  --bg-card: #1e293b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #334155;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --shadow: 0 1px 3px rgba(0, 0, 0, .3);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, .4);
}

/* ── Reset & base ─────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--site-font-body, system-ui), -apple-system, 'Segoe UI', sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  transition: background var(--transition), color var(--transition);
}

/* Site heading font */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--site-font-heading, var(--site-font-body, system-ui)), -apple-system, 'Segoe UI', sans-serif;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ── Utility ────────────────────────────────────────────────── */
.u-hidden {
  display: none !important;
}

/* ── Layout ───────────────────────────────────────────────── */
main {
  max-width: var(--site-max-width, 960px);
  margin: 0 auto;
  padding: 2.5rem 1.25rem;
}

header,
footer {
  padding: 1rem 2rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--site-max-width, 960px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

body[data-header-style="centered"] .header-inner {
  flex-direction: column;
  text-align: center;
}

footer {
  border-top: 1px solid var(--border);
  border-bottom: none;
  text-align: center;
}

.site-title {
  display: block;
  margin: 0;
  font-size: 1.5rem;
  font-weight: 400;
}

.tagline {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

footer p {
  margin: 0.25rem 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.logo {
  max-height: 48px;
  width: auto;
}

/* ── Navigation ───────────────────────────────────────────── */
.mcms-nav {
  margin: 0;
}

.mcms-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

body[data-header-style="centered"] .mcms-nav ul {
  justify-content: center;
}

.mcms-nav a {
  color: var(--text);
  text-decoration: none;
  font-weight: 400;
  font-size: 0.95rem;
  padding: 0.4rem 0;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}

.mcms-nav a:hover,
.mcms-nav a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  text-decoration: none;
}

/* ── 404 error page ─────────────────────────────────────────── */
.error-404 {
  text-align: center;
  padding: 100px 20px;
}

/* ── Blocks ───────────────────────────────────────────────── */
.block {
  margin: 2.5rem 0;
}

.block-text h1,
.block-text h2,
.block-text h3 {
  color: var(--text);
}

.block-hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  margin-bottom: 0.75rem;
  line-height: 1.2;
}

.block-hero p {
  font-size: 1.15rem;
  color: var(--text-muted);
}

/* ── Cards ────────────────────────────────────────────────── */
.cards {
  display: grid;
  gap: 1.5rem;
}

.cards.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

.cards.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.cards.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 900px) {
  .cards.cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {

  .cards.cols-3,
  .cards.cols-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .cards.cols-4 {
    grid-template-columns: 1fr;
  }
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #eeeeee;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
  padding-bottom: 1rem;
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card-body {
  padding: 0.75rem 1rem 1rem;
}

.card h3 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  color: var(--text);
}

.card p {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.card img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
}

/* Card placeholder matches image aspect ratio */
.card .card-image-placeholder {
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
}

.card-image-placeholder,
.image-placeholder,
.gallery-placeholder {
  height: 140px;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  border-radius: var(--radius) var(--radius) 0 0;
}

/* ── Table ────────────────────────────────────────────────── */
.block-table {
  /* drag-handle jaoks eemaldatud overflow: auto; vaata .table-responsive */
}

.table-responsive {
  overflow-x: auto;
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.8rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 400;
  background: var(--bg-surface);
  color: var(--text);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

td {
  font-size: var(--text-sm);
  color: var(--text);
}

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

tr:hover td {
  background: var(--bg-surface);
}

td.highlight {
  font-weight: 400;
  color: var(--primary);
}

/* ── Gallery ──────────────────────────────────────────────── */
.gallery {
  display: grid;
  gap: 1rem;
}

.gallery.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

.gallery.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.gallery.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 900px) {
  .gallery.cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .gallery.cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {

  .gallery.cols-4,
  .gallery.cols-3,
  .gallery.cols-2 {
    grid-template-columns: 1fr;
  }
}

.gallery figure {
  margin: 0;
  overflow: hidden;
  border-radius: var(--radius);
  cursor: pointer;
}

.gallery figure img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  transition: transform .3s ease;
}

.gallery figure:hover img {
  transform: scale(1.04);
}

.gallery figcaption {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  padding: 0 0.25rem;
}

/* ── Products ─────────────────────────────────────────────── */
.products {
  display: grid;
  gap: 1.5rem;
}

.products.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.products.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 768px) {
  main {
    padding: 1.5rem 0.75rem;
  }

  .section-layout {
    padding: 1rem 0.75rem;
  }

  .products.cols-3,
  .products.cols-2 {
    grid-template-columns: 1fr;
  }
}

.product-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}

.product-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.product-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
}

.product-image-placeholder {
  height: 160px;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.product-info {
  padding: 1rem;
}

.product-info h3 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  color: var(--text);
}

.product-info p {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.product-price {
  display: inline-block;
  background: var(--site-accent, var(--primary));
  color: #fff;
  font-weight: 400;
  font-size: 0.95rem;
  padding: 0.2rem 0.65rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.product-cta {
  display: inline-block;
  padding: 0.5rem 1.2rem;
  background: var(--primary);
  color: #fff !important;
  font-weight: 400;
  font-size: 0.875rem;
  border-radius: var(--radius);
  text-decoration: none !important;
  transition: background var(--transition), transform var(--transition);
}

.product-cta:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

/* ── Button block ─────────────────────────────────────────── */
.button-block {
  padding: 1rem 0;
}

.button-block.align-center {
  text-align: center;
}

.button-block.align-left {
  text-align: left;
}

.button-block.align-right {
  text-align: right;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-weight: 400;
  font-family: inherit;
  border-radius: var(--radius);
  text-decoration: none !important;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff !important;
  border: 2px solid var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(37, 99, 235, .3);
}

.btn-outline {
  background: transparent;
  color: var(--primary) !important;
  border: 2px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary);
  color: #fff !important;
}

.btn-ghost {
  background: transparent;
  color: var(--text) !important;
  border: 2px solid transparent;
}

.btn-ghost:hover {
  background: var(--bg-surface);
}

.btn-icon {
  font-size: 1.1em;
}

/* ── Split layout ─────────────────────────────────────────── */
.split-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: center;
}

.split-layout.img-right .split-image {
  order: 2;
}

.split-layout.img-right .split-text {
  order: 1;
}

.split-image img {
  width: 100%;
  border-radius: var(--radius);
  object-fit: cover;
}

.split-text h1,
.split-text h2,
.split-text h3 {
  margin-top: 0;
  color: var(--text);
}

.split-text p {
  color: var(--text-muted);
  line-height: 1.7;
}

@media (max-width: 768px) {
  .split-layout {
    grid-template-columns: 1fr;
  }

  .split-layout.img-right .split-image {
    order: 1;
  }

  .split-layout.img-right .split-text {
    order: 2;
  }
}

/* ── Section layout ──────────────────────────────────────── */
.section-layout {
  display: grid;
  gap: 2rem;
  align-items: stretch;
  padding: 2rem 1.5rem;
}

.section-layout.cols-1 {
  grid-template-columns: 1fr;
}

.section-layout.cols-2 {
  grid-template-columns: 1fr 1fr;
}

.section-layout.cols-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.section-layout.wide-left {
  grid-template-columns: 2fr 1fr;
}

.section-layout.wide-right {
  grid-template-columns: 1fr 2fr;
}

.section-col {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
}

.section-col-empty {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

/* Nested block styles within section */
.nested-block {
  width: 100%;
}

/* Vertikaalne joondus veerus */
.section-col[data-valign="center"] {
  justify-content: center;
}

.section-col[data-valign="bottom"] {
  justify-content: flex-end;
}

/* Horisontaalne joondus veerus */
.section-col[data-halign="center"] {
  align-items: center;
  text-align: center;
}

.section-col[data-halign="end"] {
  align-items: flex-end;
  text-align: right;
}


/* Stretch image — täidab veeru kõrguse ja laiuse */
.nested-block-image.img-cover {
  display: flex;
  align-self: stretch;
  overflow: hidden;
}

.nested-block-image.img-cover .mcms-img,
.nested-block-image.img-cover img {
  width: 100%;
  height: 100%;
  min-height: 280px;
  object-fit: cover;
  border-radius: 0;
  display: block;
}

/* Veerg, millel stretch image, venib täiskõrgusele ja sektsiooniserva */
.section-col:has(.img-cover) {
  padding: 0;
  margin-top: -2rem;
  margin-bottom: -2rem;
}

.section-col:first-child:has(.img-cover) {
  margin-left: -1.5rem;
}

.section-col:last-child:has(.img-cover) {
  margin-right: -1.5rem;
}

.nested-block img {
  width: 100%;
  display: block;
  margin: 0 auto;
  border-radius: var(--radius);
  object-fit: cover;
}

/* Image block sizes */
.nested-block-image.img-size-sm img {
  width: 33%;
}

.nested-block-image.img-size-md img {
  width: 66%;
}

/* img-size-lg = 100% (default) */

.nested-block h1,
.nested-block h2,
.nested-block h3,
.nested-block h4,
.nested-block h5,
.nested-block h6 {
  margin: 0;
  color: var(--text);
}

.nested-block p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.7;
}

.nested-block ul,
.nested-block ol {
  margin: 0.25rem 0;
  padding-left: 1.5rem;
  color: inherit;
}

.nested-block li {
  margin-bottom: 0.25rem;
  line-height: 1.6;
}

/* ── Section text color override ────────────────────────── */
.mcms-section[data-text-color="light"] .nested-block p,
.mcms-section[data-text-color="light"] .nested-block li,
.mcms-section[data-text-color="light"] .nested-block h1,
.mcms-section[data-text-color="light"] .nested-block h2,
.mcms-section[data-text-color="light"] .nested-block h3,
.mcms-section[data-text-color="light"] .nested-block h4 {
  color: rgba(255, 255, 255, 0.92);
}

.mcms-section[data-text-color="dark"] .nested-block p,
.mcms-section[data-text-color="dark"] .nested-block li,
.mcms-section[data-text-color="dark"] .nested-block h1,
.mcms-section[data-text-color="dark"] .nested-block h2,
.mcms-section[data-text-color="dark"] .nested-block h3,
.mcms-section[data-text-color="dark"] .nested-block h4 {
  color: rgba(0, 0, 0, 0.85);
}

/* ── Column background image ────────────────────────────── */
.section-col[style*="background-image"] {
  background-size: cover;
  background-position: center;
}

.section-col[style*="background-image"]::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  pointer-events: none;
  z-index: 0;
}

.section-col[style*="background-image"]>* {
  position: relative;
  z-index: 1;
}

.section-col[data-text-color="light"] .nested-block p,
.section-col[data-text-color="light"] .nested-block li,
.section-col[data-text-color="light"] .nested-block h1,
.section-col[data-text-color="light"] .nested-block h2,
.section-col[data-text-color="light"] .nested-block h3,
.section-col[data-text-color="light"] .nested-block h4 {
  color: rgba(255, 255, 255, 0.92);
}

/* ── Cards on dark bg (section/col text-color=light) ────── */
.mcms-section[data-text-color="light"] .card,
.section-col[data-text-color="light"] .card {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.18);
}

.mcms-section[data-text-color="light"] .card h3,
.section-col[data-text-color="light"] .card h3 {
  color: rgba(255, 255, 255, 0.92);
}

.mcms-section[data-text-color="light"] .card p,
.section-col[data-text-color="light"] .card p {
  color: rgba(255, 255, 255, 0.70);
}

.nested-block .button-block {
  margin: 0;
}

.nested-block .cards,
.nested-block .gallery {
  margin: 0;
}

@media (max-width: 768px) {
  .section-layout {
    grid-template-columns: 1fr !important;
  }

  .section-col-empty {
    padding: 1rem;
  }
}

/* ── Contact form ─────────────────────────────────────────── */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 480px;
}

.contact-form input,
.contact-form textarea {
  padding: 0.65rem 0.9rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.contact-form input:focus,
.contact-form textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

.contact-form textarea {
  min-height: 130px;
  resize: vertical;
}

.contact-form button {
  align-self: flex-start;
  padding: 0.65rem 1.5rem;
  font-size: 1rem;
  font-family: inherit;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 400;
  transition: background var(--transition), transform var(--transition);
}

.contact-form button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.contact-form button:active {
  transform: none;
}

/* ── mcms-top-bar: ühtne ülariba (saidi login, redaktor, eelvaade) ─ */

.mcms-top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9998;
  box-sizing: border-box;
  min-height: var(--mcms-topbar-height);
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--mcms-topbar-bg);
  color: var(--mcms-topbar-text);
  border-bottom: 1px solid var(--mcms-topbar-border);
  font-size: 0.8125rem;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
}

.mcms-top-bar__start {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mcms-top-bar__end {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  flex-wrap: nowrap;
  min-width: 0;
}

/* Redaktor: Vaata → Avalda → Logout — ühtlane vahe, mitte hunnik */
.mcms-top-bar--editor .mcms-top-bar__end {
  gap: 1.25rem;
}

/* Tegevuste grupp (eelvaate seadmed, mitu nuppu); väljalogimise ikoon on DOM-is viimane */
.mcms-top-bar__action-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  min-width: 0;
}

/* Eelvaate riba: tegevused + selge vahe */
.mcms-top-bar--preview .mcms-top-bar__action-group {
  gap: 1rem;
}

.mcms-top-bar__action-group .mcms-top-bar__btn {
  white-space: nowrap;
  flex-shrink: 0;
}

/* Tekstilüli (Vaata, Redigeeri): ilma outline-nuputa; hover ilma alajoonta */
.mcms-top-bar__link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 4px 2px;
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.9);
  background: transparent;
  border: none;
  border-radius: 0;
  border-bottom: none;
  cursor: pointer;
  transition: color 0.15s ease, opacity 0.15s ease;
  -webkit-font-smoothing: antialiased;
}

.mcms-top-bar__link:hover {
  color: #fff;
  text-decoration: none;
  border-bottom: none;
}

.mcms-top-bar__link svg {
  flex-shrink: 0;
  opacity: 0.92;
}

.mcms-top-bar__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 34px;
  flex-shrink: 0;
  box-sizing: border-box;
  border-radius: 6px;
  color: var(--mcms-topbar-text-muted);
  background: transparent;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.mcms-top-bar__icon-btn:hover {
  color: var(--mcms-topbar-text);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  text-decoration: none;
}

.mcms-top-bar__icon-btn svg {
  display: block;
}

.mcms-top-bar__label {
  color: var(--mcms-topbar-text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mcms-top-bar__role {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mcms-topbar-text);
}

.mcms-top-bar__status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mcms-topbar-accent);
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.mcms-top-bar__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
  color: var(--mcms-topbar-text);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--mcms-topbar-border);
}

.mcms-top-bar__btn:hover {
  background: var(--mcms-topbar-bg-hover);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
  text-decoration: none;
}

.mcms-top-bar__btn--outline {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.38);
  color: var(--mcms-topbar-text);
}

.mcms-top-bar__btn--outline:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.mcms-top-bar__btn--primary {
  background: rgba(143, 217, 154, 0.2);
  color: #f0fff2;
  border-color: rgba(143, 217, 154, 0.45);
}

.mcms-top-bar__btn--primary:hover {
  background: rgba(143, 217, 154, 0.32);
  color: #fff;
}

/* Avalda — rõhutatud hoiatuslik (kõik näevad); ei ole “hea” primary-roheline */
.mcms-top-bar__btn--danger {
  background: rgba(251, 191, 36, 0.12);
  color: #fff8e8;
  border-color: rgba(251, 191, 36, 0.55);
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.12);
}

.mcms-top-bar__btn--danger:hover:not(:disabled) {
  background: rgba(251, 191, 36, 0.22);
  color: #fff;
  border-color: rgba(253, 224, 71, 0.65);
}

.mcms-top-bar__btn--danger:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  box-shadow: none;
}

.mcms-top-bar__btn--danger .mcms-top-bar__btn-icon {
  color: #fde68a;
}

.mcms-top-bar__btn--ghost {
  background: transparent;
  color: var(--mcms-topbar-text-muted);
  border-color: transparent;
}

.mcms-top-bar__btn--ghost:hover {
  color: var(--mcms-topbar-text);
  background: rgba(255, 255, 255, 0.08);
}

.mcms-top-bar--site {
  justify-content: flex-end;
}

.mcms-top-bar--site .mcms-top-bar__end {
  flex: 0 0 auto;
}

body:has(.mcms-top-bar--site) {
  padding-top: var(--mcms-topbar-height);
}

.mcms-top-bar__device-toggle {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 4px;
}

/* Vaata / preview shell: üks rida, keskosa vajadusel keritav */
.mcms-top-bar--preview {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: var(--mcms-topbar-height);
}

.mcms-top-bar--preview .mcms-top-bar__label {
  flex: 0 0 auto;
}

.mcms-top-bar--preview .mcms-top-bar__device-toggle {
  flex: 1 1 auto;
  min-width: 0;
  justify-content: center;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.mcms-top-bar--preview .mcms-top-bar__btn {
  flex: 0 0 auto;
}

.mcms-top-bar__segment {
  background: transparent;
  border: 1px solid transparent;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  color: var(--mcms-topbar-text-muted);
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  font-weight: 500;
  font-family: inherit;
  flex-shrink: 0;
  white-space: nowrap;
}

.mcms-top-bar__segment:hover {
  color: var(--mcms-topbar-text);
}

.mcms-top-bar__segment.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--mcms-topbar-text);
  border-color: rgba(255, 255, 255, 0.22);
}

body:has(.mcms-top-bar--preview) {
  padding-top: var(--mcms-topbar-height);
}

/* ── Gallery lightbox (public + edit mode) ────────────────── */
.mcms-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10010;
  background: rgba(0, 0, 0, .92);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
}

.mcms-lightbox.mcms-open {
  opacity: 1;
  visibility: visible;
}

.mcms-lightbox img {
  max-width: 90vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 4px;
  user-select: none;
  -webkit-user-select: none;
}

.mcms-lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, .15);
  border: none;
  color: #fff;
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease;
}

.mcms-lightbox-close:hover {
  background: rgba(255, 255, 255, .28);
}

.mcms-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, .1);
  border: none;
  color: #fff;
  font-size: 1.8rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease;
}

.mcms-lightbox-nav:hover {
  background: rgba(255, 255, 255, .25);
}

.mcms-lightbox-prev {
  left: 16px;
}

.mcms-lightbox-next {
  right: 16px;
}

.mcms-lightbox-counter {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, .7);
  font-size: .85rem;
}

@media (max-width: 480px) {
  .mcms-lightbox-nav {
    width: 40px;
    height: 40px;
    font-size: 1.4rem;
  }

  .mcms-lightbox-prev {
    left: 8px;
  }

  .mcms-lightbox-next {
    right: 8px;
  }
}

/* ── Template: Minimal ───────────────────────────────────── */
.tpl-minimal header {
  background: transparent;
  border-bottom: none;
}

.tpl-minimal footer {
  background: transparent;
  border-top: none;
}

.tpl-minimal .mcms-nav a {
  font-weight: 400;
}

/* ── Template: Corporate ─────────────────────────────────── */
.tpl-corporate header {
  background: var(--primary);
  color: #fff;
}

.tpl-corporate .site-title {
  color: #fff;
}

.tpl-corporate .tagline {
  color: rgba(255, 255, 255, .8);
}

.tpl-corporate .mcms-nav a {
  color: rgba(255, 255, 255, .85);
}

.tpl-corporate .mcms-nav a:hover,
.tpl-corporate .mcms-nav a.active {
  color: #fff;
  border-bottom-color: #fff;
}

/* ── Template: Portfolio ─────────────────────────────────── */
.tpl-portfolio main {
  max-width: 100%;
  padding: 0;
}

.tpl-portfolio .block {
  margin: 0;
  padding: 2.5rem 1.25rem;
}

.tpl-portfolio .block:nth-child(even) {
  background: var(--bg-surface);
}

/* ── Rich footer ─────────────────────────────────────────── */
footer.footer-rich {
  padding: 2.5rem 2rem 1.5rem;
}

.footer-inner {
  max-width: var(--site-max-width, 960px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 2rem;
  text-align: left;
}

.footer-col h4 {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.footer-col p,
.footer-col a {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.25rem 0;
  line-height: 1.6;
}

.footer-col a:hover {
  color: var(--primary);
}

.footer-social {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.footer-social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}

.footer-social a:hover {
  background: var(--primary);
  color: #fff;
  text-decoration: none;
}

.footer-bottom {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

@media (max-width: 768px) {
  .footer-inner {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .footer-social {
    justify-content: center;
  }
}