/**
 * (c) 2026 Eric Bernstein
 * Alle Rechte vorbehalten. / All rights reserved.
 *
 * Mobile Layout fuer Smartphones (< 767px)
 */

/* Desktop: Mobile-Elemente verstecken */
.mobile-toolbar { display: none; }
.mobile-overlay { display: none; }
.mobile-hint-overlay { display: none; }
.mobile-fs-btn { display: none; }

@media (max-width: 767px) {

  /* Grundlayout: vertikal gestapelt */
  .wrap {
    display: flex !important;
    flex-direction: column;
    height: 100dvh;
    padding: 0;
    gap: 0;
  }

  /* Topbar kompakt */
  .topbar {
    border-radius: 0;
    padding: 8px 12px;
    min-height: auto;
    position: relative;
  }
  .topbar .actions { display: none; }
  .mobile-fs-btn {
    display: block;
    margin-left: auto;
    padding: 6px 14px;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
  }
  .brand { min-width: auto; }
  .titles .sub { display: none; }
  .titles .name span { display: none; }
  .topbar .status {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }

  /* Main: nur Terminal */
  .main {
    display: flex !important;
    flex-direction: column !important;
    flex: 1;
    min-height: 0;
    gap: 0;
  }

  /* Seitenpanels verstecken */
  .mapCol { display: none !important; }
  .side-right { display: none !important; }

  /* Terminal Card: volle Breite, Grid->Flex Override */
  .card-terminal {
    display: flex !important;
    flex-direction: column !important;
    flex: 1;
    border-radius: 0;
    border: none;
    min-height: 0;
  }

  /* Tab-Leiste komplett ausblenden */
  .card-terminal .cardhead { display: none; }

  #terminal { flex: 1; min-height: 0; background: #000; }

  /* Eingabefeld */
  .cmdline-wrap { padding: 6px 8px; }
  #cmdline { font-size: 16px; padding: 10px 12px; border-radius: 10px; }

  /* ---- Mobile Toolbar ---- */
  .mobile-toolbar {
    display: flex;
    justify-content: space-around;
    padding: 6px 4px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
    background: rgba(0, 0, 0, 0.4);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
  }

  .mobile-tb-btn {
    flex: 1;
    padding: 10px 4px !important;
    font-size: 20px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    text-align: center;
    line-height: 1;
  }
  .mobile-tb-btn:active {
    background: rgba(255, 255, 255, 0.1);
  }
  .mobile-tb-btn.active {
    background: rgba(52, 152, 219, 0.25);
  }

  /* ---- Mobile Overlay ---- */
  .mobile-overlay {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 70vh;
    background: rgba(11, 12, 15, 0.97);
    border-top: 1px solid rgba(52, 152, 219, 0.4);
    border-radius: 16px 16px 0 0;
    z-index: 5000;
    flex-direction: column;
    backdrop-filter: blur(10px);
  }
  .mobile-overlay.open {
    display: flex;
  }

  .mobile-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
  }

  .mobile-overlay-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
  }

  .mobile-overlay-location {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    padding: 2px 8px;
    background: linear-gradient(135deg, rgba(32,64,100,0.6), rgba(22,44,70,0.4));
    border: 1px solid rgba(52,152,219,0.3);
    border-radius: 3px;
    color: #3498db;
    font-size: 10px;
    font-weight: normal;
    letter-spacing: 0.5px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
  }
  .mobile-overlay-location:empty { display: none; }

  .mobile-overlay-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  .mobile-overlay-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    min-height: 0;
  }

  /* Steuerkreuz im Overlay */
  .mobile-overlay-body .padGrid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 280px;
    margin: 0 auto;
  }
  .mobile-overlay-body .padGrid button {
    padding: 18px 10px;
    font-size: 15px;
    font-weight: 650;
    border-radius: 12px;
  }

  /* Status im Overlay */
  .mobile-overlay-body .statusBox { padding: 8px 0; }

  /* Inventar im Overlay */
  .mobile-overlay-body .inventory-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .mobile-overlay-body .inventory-item { padding: 8px 12px; }

  /* Karte im Overlay */
  .mobile-overlay-body .map-grid { margin: 0 auto; }


  /* ---- Mobile Hinweis-Popup ---- */
  .mobile-hint-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
    padding: 20px;
  }
  .mobile-hint-overlay.visible { display: flex; }

  .mobile-hint-box {
    background: linear-gradient(135deg, rgba(15, 25, 40, 0.98), rgba(10, 18, 30, 0.98));
    border: 1px solid rgba(52, 152, 219, 0.5);
    border-radius: 16px;
    padding: 28px 24px;
    max-width: 340px;
    width: 100%;
    text-align: center;
    box-shadow: 0 0 30px rgba(52, 152, 219, 0.15), 0 10px 40px rgba(0, 0, 0, 0.5);
  }

  .mobile-hint-icon {
    font-size: 36px;
    margin-bottom: 12px;
    color: #3498db;
  }

  .mobile-hint-title {
    font-size: 18px;
    font-weight: 700;
    color: #3498db;
    margin-bottom: 14px;
  }

  .mobile-hint-text {
    font-size: 13px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.8);
    margin: 0 0 20px;
  }
  .mobile-hint-text b {
    color: #fff;
  }

  .mobile-hint-btn {
    width: 100%;
    padding: 14px;
    font-size: 15px;
    font-weight: 600;
    border: 1px solid rgba(52, 152, 219, 0.6);
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.25), rgba(52, 152, 219, 0.15));
    color: #3498db;
    cursor: pointer;
    transition: background 0.2s;
  }
  .mobile-hint-btn:active {
    background: rgba(52, 152, 219, 0.4);
  }

  /* Item-Tooltip auf Mobile: zentriert, breiter */
  .item-tooltip {
    left: 50% !important;
    transform: translateX(-50%);
    top: auto !important;
    bottom: 60px;
    min-width: 350px;
    max-width: calc(100vw - 40px);
  }

  /* Shortcuts im Overlay */
  .mobile-overlay-body .shortcut-body {
    padding: 8px;
    gap: 6px;
    background: transparent;
  }
  .mobile-overlay-body .sc-input {
    font-size: 16px; /* verhindert iOS-Zoom */
  }
}
