/*
 * ui.css – globales Layout-Finish fuer alle Seiten.
 *
 * - Inhalt wird zentriert und auf eine maximale Breite begrenzt
 *   (grosse Monitore), statt sich ueber die ganze Breite zu ziehen.
 * - Sauberes Verhalten in kleinen bzw. nicht maximierten Fenstern:
 *   Sidebar wird zur Kopfleiste, Karten fallen geordnet um, nichts
 *   laeuft horizontal aus dem Bild.
 * - Logo-Mark (statt Buchstabe "A") in Sidebar und Login.
 *
 * Wird nach style.css / dashboard.css / theme.css geladen und
 * ergaenzt diese nur.
 */

:root {
  --content-max: 1280px;
  --page-pad-x: 40px;
}

/* =========================
   LOGO
========================= */

.brand-mark {
  position: relative;
  overflow: hidden;
  color: transparent !important;
  font-size: 0 !important;
  /* Markenfarbe bleibt in jedem Theme gleich (passend zum App-Icon) */
  background-image:
    url("/img/logo-mark.svg"),
    linear-gradient(135deg, #a78bfa, #5b21b6);
  background-size: 72% 72%, 100% 100%;
  box-shadow: 0 6px 18px rgba(109, 40, 217, 0.28);
  background-position: center, center;
  background-repeat: no-repeat;
}

.empty-icon {
  color: transparent !important;
  font-size: 0 !important;
  background-image: url("/img/logo-mark.svg");
  background-size: 56% 56%;
  background-position: center;
  background-repeat: no-repeat;
}

/* =========================
   DASHBOARD: ZENTRIERUNG
========================= */

.app-shell {
  width: 100%;
}

.dashboard-main {
  width: 100%;
  min-width: 0;
  padding: 32px var(--page-pad-x) 56px;
}

.dashboard-main > * {
  width: 100%;
  max-width: var(--content-max);
  margin-left: auto;
  margin-right: auto;
}

/* Nichts darf breiter als sein Container werden */
.dashboard-main :is(section, article, aside, div, form, header, nav, ul, ol, li, fieldset) {
  min-width: 0;
}

.dashboard-main :is(img, svg, video, canvas, iframe) {
  max-width: 100%;
}

.dashboard-main table {
  max-width: 100%;
}

.dashboard-main :is(input, select, textarea) {
  max-width: 100%;
}

.dashboard-topbar h1 {
  overflow-wrap: anywhere;
}

/* =========================
   AUTH-SEITEN (Login / Register)
========================= */

.auth-page {
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
}

.auth-side {
  padding: 32px 40px;
}

/* "Angemeldet bleiben" */
.remember-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -4px 0 18px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
}

.check input {
  width: 18px;
  height: 18px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.check:hover {
  color: var(--text);
}

.remember-hint {
  color: var(--text-faint);
  font-size: 11px;
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 1400px) {
  :root {
    --page-pad-x: 32px;
  }
}

@media (max-width: 1100px) {
  :root {
    --page-pad-x: 26px;
  }

  .dashboard-main {
    padding-top: 26px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-side-column {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Zweispaltige Seitenlayouts (inline gesetzt, z. B. Settings) untereinander */
  .dashboard-main > section[style*="grid-template-columns"],
  .dashboard-main > div[style*="grid-template-columns"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

/* Sidebar wird zur Kopfleiste */
@media (max-width: 850px) {
  :root {
    --page-pad-x: 18px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand bottom"
      "nav nav";
    align-items: center;
    gap: 12px 16px;
    width: 100%;
    height: auto;
    padding: 14px var(--page-pad-x) 12px;
    border-right: 0;
    border-bottom: 1px solid rgba(var(--ink-rgb), 0.07);
  }

  .sidebar-brand {
    grid-area: brand;
    padding: 0;
    min-width: 0;
  }

  .sidebar-brand strong,
  .sidebar-brand span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sidebar-nav {
    grid-area: nav;
    flex-direction: row;
    gap: 6px;
    margin: 0 calc(var(--page-pad-x) * -1);
    padding: 0 var(--page-pad-x);
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    flex-shrink: 0;
    min-height: 40px;
    padding: 0 14px;
    font-size: 13px;
    white-space: nowrap;
  }

  .nav-item:hover {
    transform: none;
  }

  .sidebar-bottom {
    grid-area: bottom;
    display: block;
    margin: 0;
  }

  .community-card {
    display: none;
  }

  .logout-btn {
    width: auto;
    height: 38px;
    padding: 0 14px;
    font-size: 12px;
  }

  .dashboard-main {
    padding: 22px var(--page-pad-x) 44px;
  }

  .dashboard-topbar {
    margin-bottom: 24px;
  }

  .dashboard-topbar h1 {
    font-size: 26px;
  }
}

@media (max-width: 650px) {
  .dashboard-topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .topbar-actions .user-badge {
    margin-left: auto;
  }

  /* Alle inneren Grids einspaltig (inline gesetzt) */
  .dashboard-main [style*="grid-template-columns"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .stat-card {
    min-height: 118px;
    padding: 18px;
  }

  .stat-value {
    margin: 10px 0 6px;
    font-size: 28px;
  }

  .dashboard-side-column {
    display: flex;
  }

  .dashboard-panel {
    padding: 18px;
    border-radius: 16px;
  }

  .panel-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .slot-breakdown {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  /* Alle weiteren Seiten-Grids einspaltig (ausser Inventar-Raster) */
  .dashboard-main [class*="-grid"]:not([class*="mc-"]):not(.stats-grid):not(.theme-grid):not(.download-grid) {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .theme-grid {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)) !important;
  }

  .download-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 440px) {
  :root {
    --page-pad-x: 14px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .download-grid {
    grid-template-columns: 1fr !important;
  }

  .sidebar-brand span {
    display: none;
  }

  .user-badge {
    padding-right: 10px;
  }
}

/* Auth-Seiten in schmalen Fenstern */
@media (max-width: 980px) {
  .auth-page {
    display: flex;
    flex-direction: column;
  }

  .auth-hero {
    align-items: center;
    text-align: center;
    padding: 28px 24px 8px;
  }

  .hero-copy {
    margin: 0 auto;
    padding: 36px 0 20px;
  }

  .hero-copy p {
    margin: 0 auto;
  }

  .hero-features {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    text-align: left;
  }

  .hero-footer {
    display: none;
  }

  .auth-side {
    padding: 8px 20px 44px;
  }
}

@media (max-width: 700px) {
  .hero-kicker {
    margin-bottom: 16px;
  }

  .hero-copy {
    padding: 24px 0 8px;
  }

  .hero-copy h1 {
    font-size: clamp(32px, 9vw, 44px);
  }

  .hero-copy p {
    font-size: 15px;
  }

  .hero-features {
    display: none;
  }

  .auth-card {
    padding: 26px 20px;
    border-radius: 20px;
  }

  .auth-card-top {
    flex-direction: column;
  }

  .language-switcher {
    width: 100%;
  }

  .language-btn {
    flex: 1;
  }
}
