/* public/css/responsive-pass.css
 * Tag-1-Responsive-Pass fuer Dashboard + Kevin-Dashboard (Skonto-Sektion).
 *
 * Regeln dieses Passes:
 *   - KEIN Farbtausch (Tag 5).
 *   - Nur Layout, Touch-Targets, kein horizontaler Scroll bei 375px.
 *   - Greift nur <= 768px - Desktop bleibt visuell unveraendert.
 *   - Input-Font 16px erzwingen (iOS Zoom-Stop).
 *
 * Eingebunden in views/layout.ejs zusammen mit tokens.css.
 */

/* Basis: Font 16px, kein horizontaler Overflow ========================== */
html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }

/* Medien & eingebettete Inhalte (Layout + Kevin-Shell) */
img,
video,
canvas { max-width: 100%; height: auto; }
svg { max-width: 100%; }
iframe { max-width: 100%; }
pre {
  overflow-x: auto;
  max-width: 100%;
}

.k-form-split-2 {
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 768px) {
  .k-form-split-2 {
    grid-template-columns: 1fr !important;
  }
}

/* Touch-Target-Minima fuer alle Buttons/Links im Cockpit (nur Mobile) === */
@media (max-width: 768px) {
  button,
  .btn,
  .btn-sm,
  .ribbon-tab,
  .tab-link,
  input[type="button"],
  input[type="submit"],
  a.button,
  .pill,
  .chip {
    min-height: var(--touch-min, 44px);
    padding: var(--touch-padding, 12px 16px);
    box-sizing: border-box;
  }

  /* Inputs 16px, damit iOS bei Fokus nicht zoomt. */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="password"],
  input[type="search"],
  textarea,
  select {
    font-size: 16px;
    min-height: var(--touch-min, 44px);
  }
}

/* Dashboard-Wrap: feste Breiten auf Mobile aufloesen ==================== */
@media (max-width: 768px) {
  .dashboard-wrap,
  .nautilus-dashboard,
  .master-only-zone,
  .dashboard-nbe-header {
    max-width: 100%;
    padding-left: 12px;
    padding-right: 12px;
    box-sizing: border-box;
  }

  .dashboard-nbe-header {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .dashboard-nbe-header .logo,
  .dashboard-nbe-header .dashboard-nbe-pilot,
  .dashboard-nbe-header .dashboard-nbe-time {
    flex: 1 1 auto;
    min-width: 0;
  }

  .dashboard-title {
    font-size: 1.375rem !important;
    line-height: 1.25;
    word-break: break-word;
  }

  /* Ribbon-Tabs: horizontaler Scroll statt Umbruch */
  .ribbon-tabs-wrap,
  .ribbon-tabs {
    overflow-x: auto;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
  }
  .ribbon-tabs::-webkit-scrollbar { height: 2px; }

  /* Karten-Grids auf 1 Spalte */
  .grid,
  .cards,
  .card-grid,
  .dashboard-cards {
    grid-template-columns: 1fr !important;
    display: grid !important;
    gap: 12px;
  }

  .card,
  .dashboard-card,
  .nautilus-card {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    box-sizing: border-box;
  }

  /* Tabellen responsive: scroll wrapper */
  .table-wrap,
  .table-scroll,
  .tbl-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table { width: 100%; }

  /* Hauptspalte */
  .nautilus-body {
    min-width: 0;
    padding-left: 12px;
    padding-right: 12px;
    max-width: 100%;
    box-sizing: border-box;
  }

  .nautilus-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 10px;
    text-align: center;
    padding: 10px 12px;
  }

  /* Benachrichtigungs-Panel (layout.ejs): nicht breiter als Viewport */
  .notif-panel {
    width: 100% !important;
    max-width: 100vw !important;
    right: -100% !important;
    box-sizing: border-box !important;
  }
  .notif-panel.open {
    right: 0 !important;
  }
}

/* T9-Topbar (_topbar.ejs) — kein Überlauf bei langem Namen / kleinem Viewport */
@media (max-width: 560px) {
  html[data-theme='t9'] .t9-topbar,
  html[data-theme='owner'] .t9-topbar,
  html[data-theme='kevin'] .t9-topbar {
    flex-wrap: wrap;
    align-items: flex-start;
    min-height: 0;
    padding-top: 10px;
    padding-bottom: 12px;
    row-gap: 8px;
  }
  html[data-theme='t9'] .t9-topbar__start,
  html[data-theme='owner'] .t9-topbar__start,
  html[data-theme='kevin'] .t9-topbar__start {
    flex: 1 1 100%;
    min-width: 0;
  }
  html[data-theme='t9'] .t9-topbar .user-pill,
  html[data-theme='owner'] .t9-topbar .user-pill,
  html[data-theme='kevin'] .t9-topbar .user-pill {
    flex: 1 1 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
}

/* Kevin-Dashboard / Skonto-Sektion ====================================== */
/* Skonto hat keine eigene View - die Sektion lebt in
   views/kevindashboard.ejs und views/dashboard.ejs (als Widget).
   Selektoren decken beide Varianten ab, ohne Farben zu aendern. */
@media (max-width: 768px) {
  [data-section="skonto"],
  .skonto-section,
  .skonto-widget,
  section.skonto,
  .kevin-skonto,
  #skonto-panel {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    padding: 12px !important;
    border-radius: var(--radius-md, 8px);
  }

  [data-section="skonto"] .row,
  .skonto-section .row,
  .skonto-widget .row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }

  [data-section="skonto"] .amount,
  .skonto-section .amount,
  .skonto-widget .amount {
    font-size: 1.5rem;
    font-weight: 700;
  }

  /* Skonto-Alarm als Karte, voll Breite */
  [data-section="skonto"] .alert,
  .skonto-section .alert {
    width: 100%;
    padding: 12px;
    border-radius: var(--radius-md, 8px);
  }
}

/* 375px explizit: kein horizontaler Scroll */
@media (max-width: 430px) {
  body { min-width: 0; }
  .dashboard-wrap { padding-left: 8px; padding-right: 8px; }
  h1, h2, h3 { word-break: break-word; }
}

/* Kevin Mobile Bottom-Tab-Leiste (nur <640px) =============================== */
@media (max-width: 639px) {
  body.has-kevin-app-tabs {
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }
  .kevin-page.k-body.has-kevin-app-tabs {
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }
  .bottom-nav {
    display: none !important;
  }
}

.bottom-tab-bar {
  display: none;
}

@media (max-width: 639px) {
  .bottom-tab-bar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9998;
    height: 56px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-sizing: border-box;
    align-items: stretch;
    justify-content: space-around;
    background: rgba(255, 251, 235, 0.96);
    border-top: 1px solid rgba(120, 113, 108, 0.2);
    backdrop-filter: blur(8px);
  }

  .bottom-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 44px;
    padding: 6px 4px;
    text-decoration: none;
    color: var(--kevin-muted);
    font-size: 0.65rem;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
  }

  .bottom-tab:active {
    transform: scale(0.95);
  }

  .bottom-tab--active {
    color: var(--kevin-warm);
  }

  .bottom-tab__icon {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .bottom-tab__label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.kevin-install-banner-visible.has-kevin-app-tabs {
    padding-bottom: calc(112px + env(safe-area-inset-bottom, 0px));
  }
}

/* === Kevin Persona · Hero / Daily / Bubble === */
.k-hero {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1rem 1rem;
  background: linear-gradient(180deg, #FFFBEB 0%, #FFFDF7 100%);
}
.k-hero__avatar {
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.18);
}
.k-hero__text { flex: 1 1 auto; min-width: 0; }
.k-hero__greeting {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 0.15rem;
  color: #1C1917;
  line-height: 1.2;
}
.k-hero__sub {
  font-size: 0.95rem;
  color: #57534E;
  margin: 0;
}

.k-daily {
  margin: 0.75rem 0;
  padding: 1rem;
  background: #fff;
  border: 1px solid #F5F5F4;
  border-radius: 12px;
}
.k-daily__title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  color: #44403C;
}
.k-daily__list { list-style: none; margin: 0; padding: 0; }
.k-daily__item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid #FAFAF9;
}
.k-daily__item:last-child { border-bottom: 0; }
.k-daily__icon { font-size: 1.25rem; flex: 0 0 auto; }
.k-daily__body { flex: 1 1 auto; min-width: 0; }
.k-daily__head { font-weight: 500; color: #1C1917; }
.k-daily__sub { font-size: 0.85rem; color: #78716C; margin-top: 0.1rem; }
.k-daily__empty { padding: 0.5rem 0; color: #78716C; font-style: italic; }

.k-bubble {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 0.9rem;
  background: #FFFBEB;
  border-left: 3px solid #F59E0B;
  border-radius: 8px;
  margin: 0.5rem 0;
}
.k-bubble--success { background: #F0FDF4; border-left-color: #22C55E; }
.k-bubble--warn { background: #FEF2F2; border-left-color: #EF4444; }
.k-bubble__avatar { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; }
.k-bubble__body { flex: 1 1 auto; min-width: 0; color: #292524; font-size: 0.95rem; line-height: 1.4; }
.k-bubble__cta {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #B45309;
  text-decoration: underline;
}

/* === Kevin Footer === */
.k-footer {
  padding: 24px 16px;
  text-align: center;
  color: #78716C;
  border-top: 1px solid #e7e5e4;
  background: transparent;
}
.k-footer__legal { font-size: 0.9rem; }
.k-footer__legal a {
  color: #78716C;
  text-decoration: underline;
  padding: 8px 4px;
  min-height: 44px;
  display: inline-block;
}
.k-footer__copy {
  font-size: 13px;
  margin: 8px 0 0;
}
@media (max-width: 639px) {
  .k-footer {
    padding-bottom: calc(24px + 56px + env(safe-area-inset-bottom, 0px));
  }
  body.has-kevin-app-tabs .k-footer {
    padding-bottom: calc(24px + 88px + env(safe-area-inset-bottom, 0px));
  }
}
