/* =========================================================
   Selam Apartment — Production Design System
   Deep Slate · Emerald · Amber
   ========================================================= */

:root {
  --slate-950: #0f172a;
  --slate-900: #1e293b;
  --slate-800: #334155;
  --slate-700: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-200: #e2e8f0;
  --slate-50: #f8fafc;

  --emerald: #10b981;
  --emerald-soft: rgba(16, 185, 129, 0.15);
  --emerald-border: rgba(16, 185, 129, 0.35);
  --amber: #facc15;
  --amber-soft: rgba(250, 204, 21, 0.12);
  --amber-border: rgba(250, 204, 21, 0.35);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --danger-border: rgba(239, 68, 68, 0.4);

  --bg-start: #0f172a;
  --bg-mid: #1e293b;
  --bg-end: #0b1220;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --panel-bg: rgba(30, 41, 59, 0.55);
  --panel-border: rgba(255, 255, 255, 0.08);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.45);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
}

* { box-sizing: border-box; }
html, body { height: 100%; max-width: 100%; overflow-x: hidden; }

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(16, 185, 129, 0.12), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(250, 204, 21, 0.06), transparent 50%),
    linear-gradient(160deg, var(--bg-start), var(--bg-mid) 45%, var(--bg-end));
  background-attachment: fixed;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6, p, ul, ol, figure { margin: 0; }
ul, ol { padding-left: 1.25rem; }
img { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; }

.container {
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
  width: 100%;
}

.spacing-lg { padding: var(--space-6); }
.mt { margin-top: var(--space-4); }
.mt-lg { margin-top: var(--space-6); }

/* ---------- Header ---------- */
.site-header {
  background: linear-gradient(90deg, #020617 0%, var(--slate-950) 100%);
  border-bottom: 1px solid var(--panel-border);
  box-shadow: var(--shadow-sm);
}

.header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 0;
  flex-wrap: wrap;
}

.header-left .title {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: linear-gradient(90deg, #fff, #94a3b8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-tagline {
  color: var(--slate-500);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  margin-top: 0.2rem;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  backdrop-filter: blur(8px);
}

.user-pill-label { color: var(--slate-400); font-size: 0.8rem; }
.user-pill-name { color: #fff; font-size: 0.9rem; }
.user-pill-link {
  color: var(--slate-400);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  padding-right: 0.75rem;
  border-right: 1px solid var(--slate-800);
}
.user-pill-link:hover { color: var(--emerald); }
.logout-link {
  color: #f87171;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 700;
}
.logout-link:hover { color: #fca5a5; }

/* ---------- Navbar ---------- */
.navbar {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding: 0.75rem 0;
  position: sticky;
  top: 0;
  z-index: 2000;
  width: 100%;
}

.nav-wrapper {
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
}

.nav-links {
  display: flex;
  gap: 0.4rem;
  background: rgba(0, 0, 0, 0.28);
  padding: 6px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  -ms-overflow-style: none;
  max-width: 100%;
}
.nav-links::-webkit-scrollbar { display: none; }

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 12px;
  color: var(--slate-400);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  flex-shrink: 0;
}
.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}
.nav-item.active {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
}

/* ---------- Panels / Cards ---------- */
.panel {
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}
.panel.pad { padding: var(--space-5); }

.glass-panel {
  background: rgba(30, 41, 59, 0.45);
  backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 1rem;
  letter-spacing: 0.02em;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: #fff;
  background: var(--slate-800);
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.green {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
}
.btn.red { background: var(--danger); }
.btn.ghost {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text);
}
.btn.ghost:hover { background: rgba(255, 255, 255, 0.05); }

/* ---------- Tables (responsive scroll) ---------- */
.table-wrap,
.strict-scroll-container {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  border-radius: var(--radius-lg);
  border: 1px solid var(--panel-border);
}

.table-wrap .table,
.strict-scroll-container .table {
  display: table !important;
  width: 100% !important;
  min-width: 720px !important;
  border-collapse: collapse !important;
}

.table-wrap .table tr,
.strict-scroll-container .table tr {
  display: table-row !important;
}

.table-wrap .table th,
.table-wrap .table td,
.strict-scroll-container .table th,
.strict-scroll-container .table td {
  display: table-cell !important;
  white-space: nowrap !important;
  padding: 1rem 1.15rem !important;
  text-align: left !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.table thead th {
  background: rgba(15, 23, 42, 0.9);
  color: var(--slate-500);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.table tbody tr:hover { background: rgba(16, 185, 129, 0.06); }

/* ---------- Status chips ---------- */
.status,
.status-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status.upcoming,
.status-chip.available,
.status-chip.paid {
  background: var(--emerald-soft);
  color: #34d399;
  border: 1px solid var(--emerald-border);
}
.status.overdue,
.status-chip.unpaid {
  background: var(--danger-soft);
  color: #f87171;
  border: 1px solid var(--danger-border);
}
.status-chip.occupied {
  background: var(--amber-soft);
  color: var(--amber);
  border: 1px solid var(--amber-border);
}

.room-pill {
  display: inline-block;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid var(--emerald-border);
  color: #fff;
  padding: 5px 12px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 0.85rem;
}

/* ---------- Forms ---------- */
label,
.field-label {
  display: block;
  font-weight: 700;
  color: var(--slate-400);
  font-size: 0.78rem;
  margin-bottom: 0.45rem;
  letter-spacing: 0.03em;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="month"],
input[type="number"],
input[type="file"],
select,
textarea,
.field-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder, textarea::placeholder { color: var(--slate-500); }
input:focus, select:focus, textarea:focus, .field-input:focus {
  border-color: rgba(16, 185, 129, 0.55);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}

.form-row { display: grid; gap: var(--space-4); }
@media (min-width: 640px) {
  .form-row.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Alerts ---------- */
.alert {
  border-radius: var(--radius-md);
  padding: 0.9rem 1.1rem;
  border: 1px solid;
  margin-bottom: 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
}
.alert.error {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: #fca5a5;
}
.alert.success {
  background: var(--emerald-soft);
  border-color: var(--emerald-border);
  color: #6ee7b7;
}
.alert.warn {
  background: var(--amber-soft);
  border-color: var(--amber-border);
  color: #fde68a;
}

/* ---------- KPI grid ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}
.kpi-card {
  position: relative;
  padding: 1.75rem;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(12px);
  overflow: hidden;
  transition: transform 0.3s ease, border-color 0.3s ease;
}
.kpi-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--emerald);
  opacity: 0.7;
}
.kpi-card:nth-child(2)::before { background: var(--amber); }
.kpi-card:nth-child(3)::before { background: #38bdf8; }
.kpi-card:hover {
  transform: translateY(-6px);
  border-color: rgba(255, 255, 255, 0.18);
}
.kpi-card h3 {
  color: var(--slate-400);
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.kpi-card .value {
  font-size: 2.6rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.03em;
}

/* ---------- Utilities ---------- */
.muted { color: var(--slate-500); }
.flex { display: flex; }
.gap { gap: var(--space-4); }
.centered { display: flex; align-items: center; justify-content: center; }
.mobile-only { display: none !important; }
.desktop-only { display: block; }
.scroll-hint {
  display: none;
  font-size: 0.75rem;
  color: var(--slate-500);
  margin: 0 0 0.75rem;
}

/* Mobile card list (tenants, rooms, etc.) */
.mobile-card-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.mobile-card {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--panel-border);
  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: var(--slate-400);
  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;
}

/* =========================================================
   MOBILE / TABLET
   ========================================================= */
@media (max-width: 900px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: block !important; }
  .mobile-only.mobile-card-list { display: flex !important; }

  .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 { padding: 0.45rem 0; }
  .nav-wrapper { padding: 0; }
  .nav-links {
    border-radius: 0;
    background: rgba(0, 0, 0, 0.35);
    border: none;
    border-top: 1px solid rgba(255,255,255,0.04);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    padding: 6px 10px;
    gap: 0.35rem;
    justify-content: flex-start;
    max-width: 100vw;
  }
  .nav-item {
    padding: 8px 12px;
    font-size: 0.75rem;
    border-radius: 10px;
  }
  .nav-hint {
    display: block;
    text-align: center;
    font-size: 0.65rem;
    color: var(--slate-500);
    padding: 0.25rem 0 0.15rem;
  }

  .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    width: 100%;
    max-width: 100%;
  }
  .spacing-lg { padding: 1rem 0.75rem 1.5rem; }
  .glass-panel,
  .panel,
  .page-form,
  .payment-card,
  .table-card {
    border-radius: 16px !important;
    padding: 1rem !important;
    margin-left: 0;
    margin-right: 0;
  }
  .section-title { font-size: 1.05rem; }

  .kpi-grid { grid-template-columns: 1fr; gap: 0.85rem; }
  .kpi-card {
    padding: 1.15rem;
    border-radius: 16px;
  }
  .kpi-card:hover { transform: none; }
  .kpi-card .value { font-size: 2rem; }

  .form-row.two,
  .row.two,
  .payment-form {
    grid-template-columns: 1fr !important;
  }
  .field-group--wide,
  .payment-summary,
  .form-footer {
    grid-column: 1 / -1 !important;
  }

  .rooms-layout {
    display: flex !important;
    flex-direction: column !important;
    gap: 1rem !important;
    padding: 0.75rem 0 !important;
    max-width: 100% !important;
  }
  .rooms-form { order: -1; }

  .scroll-hint { display: block; }

  /* Tables: keep columns, scroll inside box only */
  .table-wrap,
  .strict-scroll-container {
    margin: 0;
    border-radius: 12px;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .table-wrap .table,
  .strict-scroll-container .table,
  .customers-table,
  .payments-grid {
    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;
  }

  input, select, textarea, .field-input {
    font-size: 16px !important; /* prevent iOS zoom */
    max-width: 100%;
  }

  .form-footer {
    flex-direction: column;
  }
  .form-footer .btn,
  .btn.green,
  .btn.ghost {
    width: 100%;
  }
  .mobile-card-actions .btn {
    width: auto;
  }

  .payment-header {
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start !important;
    padding-bottom: 1rem !important;
    margin-bottom: 1.25rem !important;
  }
  .payment-summary {
    flex-direction: column;
    gap: 1rem;
    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;
  }

  /* Kill desktop hover transforms that overflow on phones */
  .mid-section .table tbody tr:hover {
    transform: none;
  }
}

@media (max-width: 480px) {
  .header-left .title { font-size: 1.05rem; }
  .nav-item { padding: 7px 10px; font-size: 0.72rem; }
  .kpi-card .value { font-size: 1.75rem; }
  .mobile-card { padding: 0.85rem; }
}
