/* NCC Easy Condo — Dashboard Styles */

:root {
  --primary: #0a8fbf;        /* Ocean blue — logo wave */
  --primary-light: #17b8e8;
  --accent: #f08c1e;         /* Orange-gold — "EASY" in logo */
  --dark: #0f1922;           /* Dark navy — logo background */
  --dark-2: #162030;
  --dark-3: #1e2d3f;
  --text: #f0f4f8;
  --text-muted: #8b9ab0;
  --border: #253347;
  --sidebar-w: 240px;
  --header-h: 60px;
  --radius: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
body { background: var(--dark); color: var(--text); }

/* ── Auth Screen ── */
#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.auth-card {
  background: var(--dark-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
}
.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  margin-bottom: 2rem;
  font-weight: 700;
  font-size: 1.2rem;
}
.auth-logo img { height: 36px; object-fit: contain; }
.auth-card h1 { font-size: 1.35rem; font-weight: 700; text-align: center; margin-bottom: .5rem; }
.auth-card p  { color: var(--text-muted); text-align: center; font-size: .9rem; margin-bottom: 1.75rem; }
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .4rem; color: var(--text-muted); }
.form-group input {
  width: 100%; padding: .65rem .9rem;
  background: var(--dark-3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: .95rem;
  outline: none; transition: border-color .15s;
}
.form-group input:focus { border-color: var(--primary-light); }
.btn-full { width: 100%; padding: .75rem; background: var(--primary); color: #fff; border: none; border-radius: var(--radius); font-size: 1rem; font-weight: 600; cursor: pointer; transition: opacity .2s; }
.btn-full:hover { opacity: .85; }
.btn-full:disabled { opacity: .5; cursor: not-allowed; }
.auth-error { display: none; color: #f87171; font-size: .85rem; text-align: center; margin-top: .75rem; }
.auth-error.show { display: block; }
.auth-divider { display:flex;align-items:center;gap:.75rem;margin:.75rem 0;color:var(--text-muted);font-size:.8rem; }
.auth-divider::before,.auth-divider::after { content:'';flex:1;height:1px;background:var(--border); }
.btn-google { display:flex;align-items:center;justify-content:center;gap:.6rem;width:100%;padding:.65rem;background:#fff;color:#3c4043;border:1px solid #ddd;border-radius:var(--radius);font-size:.9rem;font-weight:500;text-decoration:none;transition:background .15s; }
.btn-google:hover { background:#f8f8f8; }

/* ── App Layout ── */
#app-screen { display: none; height: 100vh; overflow: hidden; }
#app-screen.show { display: flex; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--dark-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--border);
  gap: .75rem;
  font-weight: 700;
  font-size: .95rem;
}
.sidebar-header img { height: 28px; object-fit: contain; }
.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }
.nav-section { padding: .25rem 1rem .25rem; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin-top: .75rem; }
.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .55rem 1.25rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: .9rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all .15s;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.04); }
.nav-item.active { color: var(--text); border-left-color: var(--primary-light); background: rgba(45,153,103,.1); }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }
.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: .8rem;
  color: var(--text-muted);
}

.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--dark);
}
.topbar-title { font-weight: 600; font-size: 1rem; }
.topbar-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .85rem;
  color: var(--text-muted);
}
.topbar-user button { background: none; border: 1px solid var(--border); color: var(--text-muted); border-radius: 6px; padding: .3rem .7rem; font-size: .8rem; cursor: pointer; transition: all .15s; }
.topbar-user button:hover { border-color: var(--text-muted); color: var(--text); }

.content { flex: 1; overflow-y: auto; padding: 2rem 1.5rem; }

/* ── Placeholder view ── */
.placeholder-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  color: var(--text-muted);
}
.placeholder-view .ph-icon { font-size: 3.5rem; margin-bottom: 1rem; opacity: .6; }
.placeholder-view h2 { font-size: 1.3rem; font-weight: 700; color: var(--text); margin-bottom: .5rem; }
.placeholder-view p { font-size: .95rem; max-width: 360px; }

/* ── Hamburger button (mobile only) ── */
.hamburger-btn {
  display: none;
  position: fixed;
  top: 14px;
  left: 12px;
  z-index: 210;
  background: var(--dark-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 7px;
  cursor: pointer;
  flex-direction: column;
  gap: 4px;
}
.hamburger-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
.hamburger-btn.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ── Sidebar backdrop (mobile only) ── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 199;
}
.sidebar-backdrop.open { display: block; }

/* ── Mobile floating controls (lang + logout) ── */
.mobile-floating-controls {
  display: none;
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 150;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.mobile-floating-controls .lang-switcher {
  margin-right: 0;
  background: var(--dark-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 6px;
}
.mobile-floating-controls .mobile-logout-btn {
  background: var(--dark-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: .78rem;
  cursor: pointer;
  transition: all .15s;
}
.mobile-floating-controls .mobile-logout-btn:hover { color: var(--text); border-color: var(--text-muted); }

/* ── Responsive sidebar ── */
@media (max-width: 700px) {
  .hamburger-btn { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .topbar { padding-left: 52px; }
  .topbar-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50vw; font-size: .9rem; }
  #topbar-condo, #topbar-condo-select { display: none !important; }
  #mobile-condo-select { max-width: 140px; }
  .topbar-user .lang-switcher,
  .topbar-user #logout-btn { display: none; }
  .view-header { flex-wrap: wrap; gap: .5rem; }
  .view-header h2 { font-size: 1rem; }

  .mobile-floating-controls { display: flex; }

  .content { padding: 1.25rem 1rem; }

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

  /* ── Tables → Tile cards on mobile ── */
  .card > table > thead { display: none; }
  .card > table { display: block; width: 100%; }
  .card > table > tbody { display: block; }
  .card > table > tbody > tr {
    display: flex;
    flex-wrap: wrap;
    gap: .2rem .75rem;
    align-items: center;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
  }
  .card > table > tbody > tr:last-child { border-bottom: none; }
  .card > table > tbody > tr:hover { background: rgba(255,255,255,.03); }
  .card > table > tbody > td {
    display: inline;
    padding: 0;
    border: none;
    font-size: .85rem;
  }
  /* First cell = title row, full width */
  .card > table > tbody > td:first-child {
    flex-basis: 100%;
    padding-bottom: .15rem;
  }
  /* Actions cell = full width at bottom */
  .card > table > tbody > td:last-child {
    flex-basis: 100%;
    padding-top: .35rem;
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
  }
  /* Ensure badges stay inline */
  .card > table > tbody > td .badge { vertical-align: middle; }

  /* ── Modal responsive ── */
  .modal { max-width: 95vw; padding: 1.25rem; }
  .modal .form-row { grid-template-columns: 1fr; }

  /* ── Form rows stack on mobile ── */
  .form-row { grid-template-columns: 1fr !important; }

  /* ── Filter tabs wrap ── */
  .filter-tabs { flex-wrap: wrap; }
}

/* ── Views ── */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.view-header h2 { font-size: 1.2rem; font-weight: 700; }

/* ── Stats grid ── */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--dark-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}
.stat-label { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: .5rem; }
.stat-value { font-size: 2rem; font-weight: 800; }
.stat-value.orange { color: var(--accent); }

/* ── Cards / Panels ── */
.card {
  background: var(--dark-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.main-area .card {
  margin-top: 1rem;
  margin-bottom: 1rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: .9rem;
}
.card-header a { font-size: .8rem; color: var(--primary-light); text-decoration: none; }
.card-header a:hover { opacity: .8; }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  text-align: left; padding: .6rem 1rem;
  font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.03); }
tbody td { padding: .75rem 1rem; color: var(--text); vertical-align: middle; }
.table-empty { padding: 2rem 1rem; text-align: center; color: var(--text-muted); font-size: .875rem; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.badge-open     { background: rgba(59,130,246,.15); color: #60a5fa; }
.badge-progress { background: rgba(251,191,36,.15);  color: #fbbf24; }
.badge-resolved { background: rgba(34,197,94,.15);   color: #4ade80; }
.badge-archived { background: rgba(100,116,139,.15); color: #94a3b8; }
.badge-low      { background: rgba(100,116,139,.15); color: #94a3b8; }
.badge-normal   { background: rgba(59,130,246,.15);  color: #60a5fa; }
.badge-high     { background: rgba(251,146,60,.15);  color: #fb923c; }
.badge-urgent   { background: rgba(239,68,68,.15);   color: #f87171; }
.badge-resident { background: rgba(139,92,246,.15);  color: #a78bfa; }
.badge-board    { background: rgba(16,185,129,.15);  color: #34d399; }
.badge-admin    { background: rgba(244,63,94,.15);   color: #fb7185; }
.badge-employee { background: rgba(251,191,36,.15);  color: #fbbf24; }

/* ── Buttons ── */
.btn { padding: .45rem .9rem; border-radius: var(--radius); font-size: .85rem; font-weight: 600; cursor: pointer; border: none; transition: opacity .15s; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-light); }
.btn-secondary { background: var(--dark-3); border: 1px solid var(--border); color: var(--text-muted); }
.btn-secondary:hover:not(:disabled) { color: var(--text); border-color: var(--text-muted); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: .3rem .65rem; font-size: .78rem; }

/* ── Inline forms (slide-down add form) ── */
.add-form {
  display: none;
  padding: 1.25rem;
  background: var(--dark-3);
  border-top: 1px solid var(--border);
}
.add-form.open { display: block; }
.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .75rem; margin-bottom: .75rem; }
.form-row label { display: block; font-size: .75rem; font-weight: 600; color: var(--text-muted); margin-bottom: .3rem; }
.form-row input,
.form-row select {
  width: 100%; padding: .5rem .7rem;
  background: var(--dark-2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: .875rem; outline: none;
}
.form-row input:focus,
.form-row select:focus { border-color: var(--primary-light); }
.form-row select option { background: var(--dark-2); }
.form-actions { display: flex; gap: .5rem; margin-top: .5rem; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--dark-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.modal--wide { max-width: 640px; }
.modal h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 1.25rem; }
.modal-close { position: absolute; top: 1rem; right: 1rem; background: none; border: none; color: var(--text-muted); font-size: 1.25rem; cursor: pointer; }
.modal .form-row { grid-template-columns: 1fr; }
.modal .form-actions { justify-content: flex-end; }

/* ── Invite link result ── */
.invite-result {
  display: none;
  margin-top: 1rem;
  padding: .75rem 1rem;
  background: rgba(16,185,129,.1);
  border: 1px solid rgba(16,185,129,.3);
  border-radius: var(--radius);
  font-size: .8rem;
}
.invite-result.open { display: block; }
.invite-link { word-break: break-all; color: var(--primary-light); margin: .4rem 0; }
.invite-copy-btn { font-size: .75rem; }

/* ── Status filter tabs ── */
.filter-tabs { display: flex; gap: .25rem; margin-bottom: 1rem; }
.filter-tab {
  padding: .3rem .75rem; border-radius: 6px; font-size: .8rem; font-weight: 600;
  cursor: pointer; border: none;
  background: var(--dark-3); color: var(--text-muted); transition: all .15s;
}
.filter-tab.active { background: var(--primary); color: #fff; }
.filter-tab:hover:not(.active) { color: var(--text); }

/* ── Clickable rows ── */
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { color: var(--primary-light); }

/* ── Tag pills (document labels) ── */
.tag-pill {
  display: inline-block;
  padding: .15rem .45rem;
  background: rgba(23,184,232,.12);
  color: var(--primary-light);
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 600;
  margin: .1rem .1rem .1rem 0;
  white-space: nowrap;
}

/* ── Announcement cards ── */
.ann-card {
  background: var(--dark-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: .75rem;
}
.ann-card-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .6rem;
}
.ann-card h3 { font-size: .95rem; font-weight: 700; flex: 1; }
.ann-card-meta { font-size: .75rem; color: var(--text-muted); margin-top: .5rem; }
.ann-card p { font-size: .875rem; color: var(--text-muted); line-height: 1.6; white-space: pre-wrap; }

/* ── Mode toggle (upload / link) ── */
.mode-tabs { display: flex; gap: .25rem; margin-bottom: .75rem; }
.mode-tab {
  padding: .3rem .75rem; border-radius: 6px; font-size: .8rem; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border);
  background: var(--dark-3); color: var(--text-muted); transition: all .15s;
}
.mode-tab.active { background: var(--dark); color: var(--text); border-color: var(--primary); }

/* ── Language switcher ── */
.lang-switcher { display: flex; gap: .25rem; align-items: center; margin-right: .5rem; }
.lang-btn { background: none; border: 1px solid transparent; border-radius: 6px; padding: .2rem .4rem; font-size: 1rem; cursor: pointer; opacity: .45; transition: all .15s; }
.lang-btn:hover { opacity: .75; }
.lang-btn.active { opacity: 1; border-color: var(--border); background: var(--dark-3); }

/* ── Toast notification ── */
.ec-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(2rem);
  background: var(--dark-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1.5rem;
  font-size: .875rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
}
.ec-toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.ec-toast-success { border-color: #22c55e; color: #22c55e; }

/* ── Sensors (LoRaWAN mock panel) ── */
.sensors-promo {
  margin: 0 1rem 1rem;
  background: linear-gradient(135deg, var(--dark-2) 0%, #1a2535 100%);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}
.sensors-promo-inner {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  flex-wrap: wrap;
}
.sensors-promo-left { flex: 1; min-width: 220px; }
.sensors-promo-cta {
  display: flex;
  align-items: center;
  padding-top: .25rem;
  min-width: 180px;
}
.sensors-badge {
  display: inline-block;
  background: var(--accent);
  color: var(--dark);
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: .08em;
  padding: .2rem .55rem;
  border-radius: 4px;
  text-transform: uppercase;
  vertical-align: middle;
}
.sensor-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  padding: 0 1rem 1rem;
}
@media (max-width: 900px) { .sensor-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .sensor-grid { grid-template-columns: 1fr; } }

.sensor-card {
  background: var(--dark-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.sensor-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  flex-wrap: wrap;
}
.sensor-name {
  font-size: .8rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .01em;
}
.sensor-status {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .03em;
}
.sensor-status--online  { color: #4ade80; }
.sensor-status--standby { color: var(--text-muted); }

.sensor-reading {
  display: flex;
  align-items: baseline;
  gap: .4rem;
  flex-wrap: wrap;
}
.sensor-value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}
.sensor-unit {
  font-size: .75rem;
  color: var(--text-muted);
  font-weight: 500;
}
.sensor-trend {
  font-size: .8rem;
  font-weight: 700;
  margin-left: auto;
}
.sensor-sparkline {
  display: block;
  width: 100%;
  height: 52px;
  border-radius: 4px;
  overflow: hidden;
}
.sensor-footer {
  display: flex;
  justify-content: space-between;
  font-size: .7rem;
  color: var(--text-muted);
}
.ec-toast-error   { border-color: #ef4444; color: #ef4444; }
