/* ══════════════════════════════════════════════════════════
   TULIP TECH — MOBILE RESPONSIVE STYLES
   Applies on top of app.css. Desktop layout is unchanged.
   ═════════════════════════════════════════════════════════ */

/* ── DEFAULT: hide mobile-only elements on desktop ──────── */
.mobile-tab-bar      { display: none; }
.mobile-meer-overlay { display: none; }
.mobile-meer-sheet   { display: none; }
.mobile-fab          { display: none; }

/* ══════════════════════════════════════════════════════════
   MOBILE  (max-width: 768px)
   ═════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── BODY — unlock scroll on mobile ──────────────────── */
  html, body {
    height: auto;
    overflow: auto;
  }
  body {
    padding-bottom: 60px;
  }
  .main {
    overflow: visible;
    flex: none;
  }
  .view {
    overflow: visible;
  }
  .view.active {
    display: flex;
    flex-direction: column;
  }
  .content {
    overflow: visible;
    padding: 12px;
  }

  /* ── HEADER ─────────────────────────────────────────── */
  header {
    padding: 0 12px;
  }
  .header-inner {
    height: 48px;
  }
  .logo {
    margin-right: 8px;
  }
  .logo-text p {
    display: none;
  }
  .logo-text h1 {
    font-size: 14px;
    letter-spacing: 2px;
  }
  nav {
    display: none;
  }
  /* Override the 700px rule that hides header-stats */
  .header-stats {
    display: flex !important;
    gap: 10px;
    margin-left: auto;
  }
  .hstat .v {
    font-size: 14px;
  }
  .hstat .l {
    display: none;
  }

  /* ── BOTTOM TAB BAR ─────────────────────────────────── */
  .mobile-tab-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg2);
    border-top: 2px solid var(--border2);
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
  }
  .mobile-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 0;
    color: var(--text2);
    transition: color 0.15s;
  }
  .mobile-tab.active {
    color: var(--accent);
  }
  .mobile-tab-icon {
    font-size: 18px;
    line-height: 1;
  }
  .mobile-tab-label {
    font-size: 8px;
    font-family: var(--font-m);
    letter-spacing: 1px;
    text-transform: uppercase;
  }

  /* ── MEER OVERLAY ───────────────────────────────────── */
  .mobile-meer-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }
  .mobile-meer-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  /* ── MEER SHEET ─────────────────────────────────────── */
  .mobile-meer-sheet {
    display: none;
    position: fixed;
    bottom: 60px;
    left: 0;
    right: 0;
    background: var(--bg2);
    border-top: 2px solid var(--border2);
    border-radius: 12px 12px 0 0;
    z-index: 201;
    padding: 8px 0 16px;
    box-shadow: 0 -8px 30px rgba(0,0,0,0.6);
  }
  .mobile-meer-sheet.open {
    display: block;
  }
  .mobile-meer-handle {
    width: 40px;
    height: 4px;
    background: var(--border2);
    border-radius: 2px;
    margin: 0 auto 12px;
  }
  .mobile-meer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 20px;
    background: none;
    border: none;
    color: var(--text);
    font-family: var(--font-d);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 1px;
    cursor: pointer;
    text-align: left;
    transition: background 0.1s, color 0.1s;
  }
  .mobile-meer-item:hover {
    background: var(--panel);
    color: var(--accent);
  }
  .mobile-meer-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 20px;
  }
  .mobile-meer-add {
    display: block;
    width: calc(100% - 40px);
    margin: 8px 20px 0;
    padding: 14px;
    border-radius: 4px;
    border: 1px solid var(--accent);
    background: rgba(62,198,255,0.08);
    color: var(--accent);
    font-family: var(--font-d);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 2px;
    cursor: pointer;
    text-transform: uppercase;
    transition: background 0.15s;
  }
  .mobile-meer-add:hover {
    background: rgba(62,198,255,0.18);
  }

  /* ── FAB ────────────────────────────────────────────── */
  .mobile-fab {
    display: flex;
    position: fixed;
    bottom: 72px;
    right: 16px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--accent);
    background: rgba(62,198,255,0.12);
    color: var(--accent);
    font-size: 24px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 50;
    box-shadow: 0 4px 16px rgba(62,198,255,0.2);
    transition: background 0.15s;
  }
  .mobile-fab:hover {
    background: rgba(62,198,255,0.22);
  }
  .mobile-fab.hidden {
    display: none;
  }

  /* ── TOOLBAR ─────────────────────────────────────────── */
  .toolbar {
    padding: 8px 12px;
    gap: 6px;
    flex-wrap: wrap;
  }
  .search-wrap {
    flex: 0 0 100%;
    order: -1;
    min-width: 0;
  }
  .btn-add {
    display: none;
  }

  /* ── OVERVIEW ────────────────────────────────────────── */
  #overview {
    overflow: visible;
    display: flex;
    flex-direction: column;
  }
  .ov-stats {
    padding: 8px 12px;
  }
  .ov-charts {
    grid-template-columns: 1fr;
    padding: 8px 12px;
  }
  .ov-strip-header {
    padding: 0 12px 5px;
  }
  .ov-strip {
    padding: 0 12px 8px;
  }
  .ov-bottom {
    flex: none;
    flex-direction: column;
    overflow: visible;
    min-height: auto;
    border-top: none;
  }
  #overview-map-container {
    height: 250px;
    flex: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .ov-loc-sidebar {
    width: 100%;
    max-height: none;
    overflow-y: visible;
    padding: 12px;
  }

  /* ── DEVICE CARDS ────────────────────────────────────── */
  .device-grid {
    grid-auto-rows: unset;
  }

  /* ── MODALS (bottom-sheet style on mobile) ───────────── */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .modal-overlay .modal {
    position: relative;
    max-width: none;
    max-height: 95vh;
    width: 100%;
    border-radius: 12px 12px 0 0;
  }

  /* ── WEBHOOK LOG (table → cards) ────────────────────── */
  .log-table thead {
    display: none;
  }
  .log-table,
  .log-table tbody,
  .log-table tr,
  .log-table td {
    display: block;
    width: 100%;
  }
  .log-table tbody tr {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 8px;
    padding: 4px 0;
  }
  .log-table td {
    padding: 4px 12px;
    border-bottom: none;
  }
  .log-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 8px;
    letter-spacing: 2px;
    color: var(--text2);
    text-transform: uppercase;
    margin-bottom: 2px;
    font-family: var(--font-m);
  }

  /* ── NAMES — scrollable tabs ─────────────────────────── */
  .theme-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 10px 12px;
  }
  .theme-tab {
    flex-shrink: 0;
  }

  /* ── MAP VIEW ────────────────────────────────────────── */
  .map-layout {
    height: 100%;
  }
  #map-container {
    height: 100%;
  }

}

/* ══════════════════════════════════════════════════════════
   SMALL PHONE  (max-width: 480px)
   ═════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .logo-text h1 {
    font-size: 12px;
    letter-spacing: 1px;
  }
  .logo-ring {
    width: 28px;
    height: 28px;
  }
  .logo-ring::before {
    width: 12px;
    height: 12px;
  }
  .logo-ring::after {
    width: 5px;
    height: 5px;
  }
  .toolbar {
    padding: 6px 10px;
  }
  .sel {
    font-size: 10px;
    padding: 5px 8px;
  }
  .hstat .v {
    font-size: 12px;
  }
}
