/* ============================================================
   MALA OS v2 — Responsive & Mobile
   ============================================================ */

@import url('tokens.css');

/* ── Tablet (768px - 1199px) ── */
@media (max-width: 1199px) {
  .app {
    grid-template-columns: var(--rail-width) 1fr;
  }

  .main {
    padding: var(--space-5);
  }

  .kpi-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }

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

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

  .header-search input {
    width: 180px;
  }

  .header-search input:focus {
    width: 220px;
  }
}

/* ── Mobile (< 768px) ── */
@media (max-width: 767px) {
  .app {
    grid-template-areas:
      "header"
      "main"
      "mobile-nav";
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-height) 1fr 60px;
  }

  .rail {
    display: none;
  }

  .header {
    padding: 0 var(--space-4);
  }

  .header-search {
    display: none;
  }

  .header-breadcrumb {
    font-size: var(--text-lg);
  }

  .main {
    padding: var(--space-4);
    padding-bottom: calc(var(--space-4) + 60px);
  }

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

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

  .section-header h1 {
    font-size: var(--text-xl);
  }

  .panel {
    padding: var(--space-4);
  }

  .panel-header {
    flex-direction: column;
    gap: var(--space-3);
  }

  .data-table {
    font-size: var(--text-xs);
  }

  .data-table th,
  .data-table td {
    padding: var(--space-2) var(--space-3);
  }

  /* Mobile bottom navigation */
  .mobile-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--surface-deep);
    border-top: 1px solid var(--surface-glass-border);
    z-index: var(--z-sticky);
    justify-content: space-around;
    align-items: center;
    padding: 0 var(--space-2);
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-1) var(--space-2);
    color: var(--text-muted);
    font-size: 10px;
    cursor: pointer;
    transition: color var(--transition-fast);
    border: none;
    background: none;
  }

  .mobile-nav-item.active {
    color: var(--gold-500);
  }

  .mobile-nav-item svg {
    width: 20px;
    height: 20px;
  }

  /* Modal adjustments */
  .modal-overlay {
    padding: var(--space-3);
    align-items: flex-end;
  }

  .modal-box {
    width: 100%;
    max-height: 85vh;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    animation: slideUp 0.3s ease;
  }

  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  /* Audit cards */
  .audit-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ── Small Mobile (< 480px) ── */
@media (max-width: 479px) {
  .kpi-grid {
    grid-template-columns: 1fr !important;
  }

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

  .chips {
    gap: var(--space-1);
  }

  .chip {
    padding: var(--space-1) var(--space-2);
    font-size: 10px;
  }

  .header-right .header-btn:not(:last-child) {
    display: none;
  }
}

/* ── Print ── */
@media print {
  .rail,
  .header,
  .mobile-nav {
    display: none !important;
  }

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

  .main {
    padding: 0;
    background: white;
    color: black;
  }

  .panel {
    border: 1px solid #ccc;
    background: white;
    break-inside: avoid;
  }
}
