/**
 * iPhone / schmale Phones – kompakte Navigation (lädt zuletzt)
 */

.nav-drawer-head {
  display: none;
}

/* Alte Vollbild-Menü-Regeln aus mobile-app.css neutralisieren */
@media (max-width: 768px) {
  .nav.is-open {
    inset: auto !important;
    width: auto !important;
    height: auto !important;
  }

  body.is-phone .nav-link {
    min-height: 0;
    font-size: inherit;
    padding: inherit;
  }
}

/* ========== Schmale App-Leiste (48px) ========== */
@media (max-width: 768px) {
  body.is-phone #app-shell > .header {
    min-height: 0;
    height: auto;
    max-height: none;
    padding: max(0.25rem, env(safe-area-inset-top, 0px)) 0.4rem 0.25rem;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
  }

  body.is-phone #app-shell > .header .header-start {
    gap: 0.35rem;
  }

  body.is-phone .nav-toggle {
    display: none !important;
  }

  body.is-phone .nav-close {
    display: none;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
  }

  body.is-phone.nav-open .nav-toggle {
    display: none;
  }

  body.is-phone.nav-open .nav-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  body.is-phone .logo-text {
    font-size: 0.85rem;
    font-weight: 600;
  }

  body.is-phone .logo-mark {
    font-size: 1rem;
  }

  /* Seitenmenü: schmal, nicht Vollbild */
  body.is-phone #app-shell > .header .nav:not(.is-open) {
    display: none !important;
  }

  body.is-phone #app-shell > .header .nav.is-open {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: auto;
    width: min(17.5rem, 88vw);
    max-width: 88vw;
    z-index: 1100;
    flex-direction: column;
    align-items: stretch;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #151d2b;
    padding: max(0.45rem, env(safe-area-inset-top, 0px)) 0 0.5rem;
    margin: 0;
    border: none;
    box-shadow: 4px 0 28px rgba(0, 0, 0, 0.45);
    clip: auto;
  }

  body.is-phone #app-shell > .header .nav-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.5rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 0.25rem;
    flex-shrink: 0;
  }

  body.is-phone #app-shell > .header .nav-drawer-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #94a3b8;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  body.is-phone #app-shell > .header .nav-drawer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
  }

  body.is-phone #app-shell > .header .nav-group {
    padding: 0.15rem 0.35rem 0.35rem;
    margin: 0 0 0.15rem;
    border-bottom: none;
  }

  body.is-phone #app-shell > .header .nav-group-label {
    font-size: 0.62rem;
    padding: 0.35rem 0.45rem 0.15rem;
    opacity: 0.75;
  }

  body.is-phone #app-shell > .header .nav-link,
  body.is-phone #app-shell > .header .nav-footer .btn-text {
    min-height: 42px;
    padding: 0.4rem 0.55rem !important;
    font-size: 0.9rem !important;
    border-radius: 6px;
    width: 100%;
  }

  body.is-phone #main-nav .nav-link[data-view="mailclient"],
  body.is-phone #main-nav .nav-link[data-view="campaigns"],
  body.is-phone #main-nav .nav-link[data-view="campaign-new"],
  body.is-phone #main-nav .nav-link[data-view="tracking"] {
    display: none !important;
  }

  body.is-phone #app-shell > .header .nav-footer {
    margin-top: 0.25rem;
    padding-top: 0.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    gap: 0.1rem;
  }

  body.is-phone #app-shell > .dsgvo-footer-fixed {
    display: none !important;
  }

  body.is-phone #app-shell > #content.content {
    padding: 0.65rem 0.6rem;
    padding-bottom: calc(3.75rem + env(safe-area-inset-bottom, 0px));
  }

  body.is-phone #app-shell.mail-view-active > #content.content--mail {
    padding-bottom: calc(3.75rem + env(safe-area-inset-bottom, 0px));
  }

  body.is-phone #app-shell.mail-pane-read > #content.content--mail {
    padding-bottom: 0;
  }

}

body.is-phone #app-shell.mail-pane-read .mobile-bottom-nav {
  display: none !important;
}

/* ========== Bottom Navigation ========== */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1050;
  grid-template-columns: repeat(5, 1fr);
  align-items: stretch;
  background: rgba(21, 29, 43, 0.98);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

body.is-phone #app-shell:not(.hidden) .mobile-bottom-nav {
  display: grid;
}

body.is-phone.mail-view-active.mail-pane-read .mobile-bottom-nav {
  display: none !important;
}

.mobile-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.05rem;
  min-height: 46px;
  padding: 0.2rem 0.1rem;
  border: none;
  background: transparent;
  color: #94a3b8;
  text-decoration: none;
  font: inherit;
  font-size: 0.62rem;
  line-height: 1.1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mobile-tab-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.mobile-tab-label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-tab.active,
.mobile-tab.mobile-tab--active {
  color: #93c5fd;
}

.mobile-tab--cta .mobile-tab-icon {
  font-size: 1.25rem;
}

.mobile-tab--cta.active {
  color: #fff;
}

/* Inhalte kompakter */
@media (max-width: 768px) {
  body.is-phone .page-header {
    margin-bottom: 0.65rem;
    padding-bottom: 0.5rem;
    gap: 0.45rem;
  }

  body.is-phone .page-header h2 {
    font-size: 1.05rem;
  }

  body.is-phone .page-lead,
  body.is-phone .subtitle {
    font-size: 0.82rem;
  }

  body.is-phone .card {
    padding: 0.65rem;
    border-radius: 10px;
  }

  body.is-phone .page-actions .btn-primary,
  body.is-phone .page-actions .btn-ghost {
    min-height: 42px;
    font-size: 0.88rem;
  }

  body.is-phone .empty-state {
    padding: 0.75rem;
    font-size: 0.88rem;
  }

  body.is-phone .empty-state h3 {
    font-size: 1rem;
  }

  body.is-phone .btn,
  body.is-phone .btn-primary,
  body.is-phone .btn-ghost,
  body.is-phone .btn-danger {
    min-height: 40px;
    padding: 0.4rem 0.75rem;
    font-size: 0.88rem;
  }

  body.is-phone .btn-sm {
    min-height: 36px;
    padding: 0.3rem 0.55rem;
    font-size: 0.82rem;
  }

  body.is-phone table {
    font-size: 0.82rem;
  }

  body.is-phone th,
  body.is-phone td {
    padding: 0.4rem 0.35rem;
  }

  body.is-phone .campaign-card,
  body.is-phone .stat-card {
    padding: 0.6rem;
  }

  body.is-phone .mail-folders-panel .mail-folder-btn {
    min-height: 40px;
    padding: 0.45rem 0.65rem;
    font-size: 0.88rem;
  }

  body.is-phone .mail-app-toolbar {
    min-height: 40px;
    padding: 0.25rem 0.35rem;
    gap: 0.25rem;
  }

  body.is-phone .mail-app-toolbar .btn-ghost,
  body.is-phone .mail-app-toolbar .btn-primary {
    min-height: 36px;
    padding: 0.25rem 0.45rem;
    font-size: 0.8rem;
  }
}

/* ========== Postfach: kompakte Toolbar je Ansicht ========== */
@media (max-width: 768px) {
  body.is-phone #mail-open-new-tab,
  body.is-phone #mail-toggle-fullscreen,
  body.is-phone #mail-open-fullscreen-tab,
  body.is-phone #mail-chrome-move,
  body.is-phone #mail-ki-settings-btn {
    display: none !important;
  }

  body.is-phone #app-shell.mail-pane-folders .mail-chrome-search-wrap,
  body.is-phone #app-shell.mail-pane-folders #mail-folders-toggle,
  body.is-phone #app-shell.mail-pane-folders #mail-new-mail-btn,
  body.is-phone #app-shell.mail-pane-folders #mail-reply-toolbar,
  body.is-phone #app-shell.mail-pane-folders #mail-delete-toolbar,
  body.is-phone #app-shell.mail-pane-folders #mail-ki-toggle {
    display: none !important;
  }

  body.is-phone #app-shell.mail-pane-list #mail-reply-toolbar,
  body.is-phone #app-shell.mail-pane-list #mail-delete-toolbar,
  body.is-phone #app-shell.mail-pane-read #mail-folders-toggle,
  body.is-phone #app-shell.mail-pane-read #mail-new-mail-btn {
    display: none !important;
  }

  body.is-phone #mail-mobile-back {
    min-width: 44px;
    font-size: 1.1rem;
  }

  body.is-phone #mail-sync-btn,
  body.is-phone #mail-new-mail-btn,
  body.is-phone #mail-ki-toggle {
    min-width: 44px;
  }

  body.is-phone .mail-fs-btn-label {
    display: none;
  }

  body.is-phone .mail-chrome-actions .btn-ghost,
  body.is-phone .mail-chrome-actions .btn-primary,
  body.is-phone .mail-chrome-actions .mail-sync-btn {
    padding: 0.35rem 0.5rem;
    font-size: 0.78rem;
  }

  body.is-phone .mail-account-select {
    font-size: 16px;
  }
}

/* ========== Menü „Mehr“: Vollbild-Drawer ========== */
@media (max-width: 768px) {
  body.nav-open .nav-backdrop {
    z-index: 1190;
    background: rgba(0, 0, 0, 0.65);
  }

  body.nav-open #app-shell > #content,
  body.nav-open #app-shell > .dsgvo-footer-fixed,
  body.nav-open .mobile-bottom-nav {
    pointer-events: none;
  }

  body.nav-open #app-shell > .header .nav.is-open {
    z-index: 1205;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    box-shadow: none;
  }

  body.nav-open .mobile-bottom-nav {
    display: none !important;
  }
}

/* ========== Neue E-Mail (Compose) – phone-first ========== */
@media (max-width: 768px) {
  .mail-compose-overlay--phone,
  .mail-compose-overlay--fullscreen {
    padding: 0;
    z-index: 1300;
  }

  .mail-compose-overlay--phone .mail-compose-window,
  .mail-compose-overlay--fullscreen .mail-compose-window {
    width: 100%;
    height: 100%;
    max-height: 100dvh;
    max-height: 100svh;
    border-radius: 0;
  }

  .mail-compose-overlay--phone .mail-compose-titlebar {
    flex-wrap: wrap;
    padding: max(0.45rem, env(safe-area-inset-top, 0px)) 0.55rem 0.4rem;
    gap: 0.35rem;
  }

  .mail-compose-overlay--phone .mail-compose-titlebar strong {
    flex: 1 1 100%;
    font-size: 1rem;
  }

  .mail-compose-overlay--phone .mail-compose-from {
    flex: 1 1 100%;
    max-width: 100%;
    font-size: 0.8rem;
  }

  .mail-compose-overlay--phone #mail-compose-toggle-fs {
    display: none;
  }

  .mail-compose-overlay--phone .mail-compose-ribbon {
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    padding: 0.4rem 0.55rem;
    max-height: 38vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mail-compose-overlay--phone .mail-compose-ribbon-group {
    flex-wrap: wrap;
    border-right: none;
    margin-right: 0;
    padding-right: 0;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid #e2e8f0;
  }

  .mail-compose-overlay--phone .mail-compose-ribbon-group:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  .mail-compose-overlay--phone .mail-compose-ribbon-advanced {
    display: none !important;
  }

  .mail-compose-overlay--phone .mail-compose-ribbon button,
  .mail-compose-overlay--phone .mail-compose-ribbon select {
    min-height: 40px;
    font-size: 0.85rem;
  }

  .mail-compose-overlay--phone .mail-compose-field-row label {
    width: 2.75rem;
  }

  .mail-compose-overlay--phone .mail-compose-field-row input {
    font-size: 16px;
    min-height: 44px;
  }

  .mail-compose-overlay--phone .mail-compose-body-wrap {
    flex: 1;
    min-height: 8rem;
    padding: 0.4rem 0.55rem;
  }

  .mail-compose-overlay--phone .mail-compose-editor-html,
  .mail-compose-overlay--phone .mail-compose-editor-text {
    min-height: 10rem;
    font-size: 16px;
  }

  .mail-compose-overlay--phone .mail-compose-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    padding: 0.55rem 0.65rem;
    padding-bottom: max(0.55rem, env(safe-area-inset-bottom, 0px));
  }

  .mail-compose-overlay--phone .mail-compose-footer .btn-primary,
  .mail-compose-overlay--phone .mail-compose-footer .btn-ghost {
    width: 100%;
    min-height: 48px;
    margin: 0;
  }

  .mail-compose-overlay--phone .mail-compose-hint,
  .mail-compose-overlay--phone #mail-compose-hint {
    display: none !important;
  }

  .mail-compose-overlay--phone .mail-compose-tracking-opt {
    width: 100%;
    margin: 0;
  }
}
