/* =========================================================
   SELAM — MOBILE LAYOUT (ONE PLACE TO EDIT)
   Folder: assets/css/mobile/
   File:   mobile.css

   This file loads LAST on every page.
   Change phone / tablet layout ONLY here.
   ========================================================= */

/* Shared helpers (hidden on desktop via rules below) */
.mobile-only { display: none !important; }
.desktop-only { display: block; }
.scroll-hint {
  display: none;
  font-size: 0.75rem;
  color: #64748b;
  margin: 0 0 0.75rem;
}
.nav-hint { display: none; }

/* Mobile card list components */
.mobile-card-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.mobile-card {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 1rem;
}
.mobile-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.mobile-card-title {
  font-weight: 800;
  color: #fff;
  font-size: 1rem;
  text-decoration: none;
  word-break: break-word;
}
.mobile-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
  color: #94a3b8;
  font-size: 0.85rem;
}
.mobile-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.mobile-card-actions .btn {
  width: auto;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.55rem 0.75rem;
  font-size: 0.78rem;
}

/* ---------------------------------------------------------
   TABLET / PHONE (max 900px)
   --------------------------------------------------------- */
@media (max-width: 900px) {
  html, body {
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .desktop-only { display: none !important; }
  .mobile-only { display: block !important; }
  .mobile-only.mobile-card-list { display: flex !important; }
  .scroll-hint { display: block; }

  /* Header */
  .header-flex {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.85rem 0;
  }
  .header-left .title {
    font-size: 1.15rem;
    letter-spacing: 0.02em;
  }
  .header-tagline {
    font-size: 0.65rem;
    letter-spacing: 0.08em;
  }
  .user-pill {
    width: 100%;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
  }
  .user-pill-label { display: none; }
  .user-pill-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.85rem;
  }
  .user-pill-link {
    padding-right: 0.5rem;
    font-size: 0.75rem;
  }

  /* Navbar */
  .navbar { padding: 0.45rem 0; }
  .nav-wrapper { padding: 0; }
  .nav-links {
    border-radius: 0 !important;
    background: rgba(0, 0, 0, 0.35) !important;
    border: none !important;
    border-top: 1px solid rgba(255, 255, 255, 0.04) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04) !important;
    padding: 6px 10px !important;
    gap: 0.35rem !important;
    justify-content: flex-start !important;
    max-width: 100vw !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .nav-item {
    padding: 8px 12px !important;
    font-size: 0.75rem !important;
    border-radius: 10px !important;
    flex-shrink: 0;
  }
  .nav-hint {
    display: block !important;
    text-align: center;
    font-size: 0.65rem;
    color: #64748b;
    padding: 0.25rem 0 0.15rem;
  }

  /* Page shell */
  .container {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .spacing-lg { padding: 1rem 0.75rem 1.5rem !important; }

  .glass-panel,
  .panel,
  .page-form,
  .payment-card,
  .table-card {
    border-radius: 16px !important;
    padding: 1rem !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100% !important;
  }
  .section-title { font-size: 1.05rem !important; }

  /* Dashboard KPIs */
  .kpi-grid {
    grid-template-columns: 1fr !important;
    gap: 0.85rem !important;
  }
  .kpi-card {
    padding: 1.15rem !important;
    border-radius: 16px !important;
  }
  .kpi-card:hover { transform: none !important; }
  .kpi-card .value { font-size: 2rem !important; }
  .mid-section .table tbody tr:hover { transform: none !important; }
  .mid-section .table td:nth-child(4) { max-width: 160px; }

  /* Forms — all pages */
  .form-row.two,
  .row.two,
  .payment-form {
    grid-template-columns: 1fr !important;
  }
  .field-group--wide,
  .payment-summary,
  .form-footer {
    grid-column: 1 / -1 !important;
  }
  .section { padding: 1rem !important; }

  input, select, textarea, .field-input {
    font-size: 16px !important;
    max-width: 100% !important;
  }

  .form-footer {
    flex-direction: column !important;
  }
  .form-footer .btn,
  .btn.green,
  .btn.ghost {
    width: 100%;
  }
  .mobile-card-actions .btn,
  .mobile-card-actions .btn.green,
  .mobile-card-actions .btn.ghost,
  .mobile-card-actions .btn.red {
    width: auto;
  }

  /* Payments page */
  .payment-card {
    margin: 1rem auto !important;
    padding: 1.15rem !important;
    border-radius: 18px !important;
  }
  .payment-header {
    flex-direction: column !important;
    gap: 0.75rem !important;
    align-items: flex-start !important;
    padding-bottom: 1rem !important;
    margin-bottom: 1.25rem !important;
  }
  .payment-summary {
    flex-direction: column !important;
    gap: 1rem !important;
    text-align: center;
  }
  .payment-summary > div[style*="border-left"] {
    border-left: none !important;
    padding-left: 0 !important;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 0.75rem;
  }

  /* Rooms / Electricity layout */
  .rooms-layout {
    display: flex !important;
    flex-direction: column !important;
    gap: 1rem !important;
    padding: 0.5rem 0 !important;
    max-width: 100% !important;
  }
  .rooms-form { order: -1; }
  .elec-main {
    width: 100% !important;
    max-width: 100% !important;
    padding: 1rem 0.75rem 2rem !important;
  }
  .mobile-toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }
  .mobile-toolbar form,
  .mobile-toolbar select {
    width: 100% !important;
  }

  /* Electricity page */
  .elec-page { padding: 1rem 0.75rem 2rem !important; }
  .elec-layout {
    grid-template-columns: 1fr !important;
  }
  .elec-logger {
    position: static !important;
    order: -1;
  }
  .elec-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .meter-board {
    grid-template-columns: 1fr 1fr !important;
  }
  .elec-month-form,
  .elec-month-select {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Tables — scroll inside box only */
  .table-wrap,
  .strict-scroll-container {
    margin: 0 !important;
    border-radius: 12px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    max-width: 100% !important;
  }
  .table-wrap .table,
  .strict-scroll-container .table,
  .customers-table,
  .payments-grid,
  .table {
    min-width: 560px !important;
  }
  /* Card pages hide desktop table — no min-width needed */
  .desktop-only .table,
  .desktop-only .customers-table {
    min-width: 560px !important;
  }
  .table-wrap .table th,
  .table-wrap .table td,
  .strict-scroll-container .table th,
  .strict-scroll-container .table td {
    padding: 0.75rem 0.85rem !important;
    font-size: 0.85rem !important;
  }

  .table-wrap::before {
    content: "Swipe table sideways →";
    display: block;
    font-size: 0.72rem;
    color: #64748b;
    padding: 0.5rem 0.75rem 0;
  }
  .desktop-only.table-wrap::before,
  .desktop-only .table-wrap::before {
    content: none;
    display: none;
  }

  /* Login */
  .login-wrap { padding: 1rem !important; }
  .login-card {
    padding: 1.5rem !important;
    border-radius: 1.15rem !important;
  }
  .login-title { font-size: 1.45rem !important; }
}

/* ---------------------------------------------------------
   SMALL PHONES (max 480px)
   --------------------------------------------------------- */
@media (max-width: 480px) {
  .header-left .title { font-size: 1.05rem !important; }
  .nav-item {
    padding: 7px 10px !important;
    font-size: 0.72rem !important;
  }
  .kpi-card .value { font-size: 1.75rem !important; }
  .mobile-card { padding: 0.85rem !important; }
  .login-card { padding: 1.25rem !important; }
  .login-title { font-size: 1.3rem !important; }
  .meter-board { grid-template-columns: 1fr !important; }
}
