/* ============================================================
   RentEase - Global Stylesheet
   Design: Clean, professional, navy & teal theme
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Poppins:wght@600;700&display=swap');

:root {
  --navy:       #1A2B4A;
  --navy-light: #243660;
  --teal:       #0E9E8E;
  --teal-light: #12B5A3;
  --teal-pale:  #E6F7F5;
  --accent:     #F5A623;
  --danger:     #E53E3E;
  --success:    #38A169;
  --warning:    #D69E2E;
  --gray-50:    #F9FAFB;
  --gray-100:   #F3F4F6;
  --gray-200:   #E5E7EB;
  --gray-400:   #9CA3AF;
  --gray-600:   #4B5563;
  --gray-800:   #1F2937;
  --white:      #FFFFFF;
  --sidebar-w:  260px;
  --topbar-h:   64px;
  --radius:     10px;
  --shadow:     0 2px 12px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 24px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }

/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  height: 100vh;
  height: 100dvh;          /* phones: fits between the browser bars */
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .3s;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo .logo-text {
  font-family: 'Poppins', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -0.5px;
}

.sidebar-logo .logo-text span { color: var(--teal-light); }
.sidebar-logo .logo-text { display: flex; align-items: center; gap: 10px; }
.sidebar-logo-img { height: 34px; width: auto; flex-shrink: 0; }
.sidebar-logo .logo-text .logo-word { color: #fff; }

/* logo on the sign-in pages */
.login-logo { width: 260px; max-width: 80%; height: auto; display: block; margin: 0 auto; }
.login-logo-mobile { display: none; }

.sidebar-role {
  font-size: 11px;
  color: var(--gray-400);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-top: 4px;
}

.sidebar-nav {
  flex: 1;
  min-height: 0;           /* lets the menu shrink so it can scroll */
  overflow-y: auto;        /* scroll the menu when the screen is short */
  overscroll-behavior: contain;
  padding: 16px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.25) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 3px; }
.sidebar-logo, .sidebar-user { flex-shrink: 0; }   /* logo stays on top, your name stays at the bottom */

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gray-400);
  padding: 12px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  font-weight: 500;
  transition: all .2s;
  position: relative;
  cursor: pointer;
}

.nav-item:hover { color: var(--white); background: rgba(255,255,255,0.06); }

.nav-item.active {
  color: var(--white);
  background: rgba(14,158,142,0.2);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--teal-light);
  border-radius: 0 3px 3px 0;
}

.nav-item .nav-icon { font-size: 18px; width: 22px; text-align: center; }

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-avatar {
  width: 38px; height: 38px;
  background: var(--teal);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.sidebar-user-info .name {
  font-size: 13px;
  font-weight: 600;
  color: var(--white);
}

.sidebar-user-info .role-tag {
  font-size: 11px;
  color: var(--gray-400);
}

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-title {
  font-family: 'Poppins', sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--navy);
}

.topbar-actions { display: flex; align-items: center; gap: 16px; }

.topbar-btn {
  position: relative;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--gray-600);
  padding: 6px;
  border-radius: 8px;
  transition: background .2s;
}

.topbar-btn:hover { background: var(--gray-100); }

.notif-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid white;
}

.page-content { padding: 28px; flex: 1; }

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--navy);
}

/* ── Stat Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.teal   { background: var(--teal-pale); }
.stat-icon.navy   { background: rgba(26,43,74,0.08); }
.stat-icon.green  { background: rgba(56,161,105,0.1); }
.stat-icon.orange { background: rgba(245,166,35,0.12); }
.stat-icon.red    { background: rgba(229,62,62,0.1); }

.stat-value {
  font-family: 'Poppins', sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}

.stat-label {
  font-size: 13px;
  color: var(--gray-400);
  margin-top: 4px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .2s;
  font-family: 'Inter', sans-serif;
}

.btn-primary   { background: var(--teal); color: white; }
.btn-primary:hover { background: var(--teal-light); }
.btn-navy      { background: var(--navy); color: white; }
.btn-navy:hover { background: var(--navy-light); }
.btn-danger    { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-outline   { background: transparent; border: 1.5px solid var(--gray-200); color: var(--gray-600); }
.btn-outline:hover { border-color: var(--teal); color: var(--teal); }
.btn-sm        { padding: 6px 12px; font-size: 13px; }
.btn-success   { background: var(--success); color: white; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th {
  background: var(--gray-50);
  padding: 11px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--gray-400);
  border-bottom: 1px solid var(--gray-200);
}

td {
  padding: 14px 16px;
  font-size: 14px;
  color: var(--gray-800);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-success  { background: rgba(56,161,105,0.12); color: var(--success); }
.badge-danger   { background: rgba(229,62,62,0.12); color: var(--danger); }
.badge-warning  { background: rgba(214,158,46,0.15); color: var(--warning); }
.badge-info     { background: var(--teal-pale); color: var(--teal); }
.badge-gray     { background: var(--gray-100); color: var(--gray-600); }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: var(--gray-800);
  background: var(--white);
  transition: border-color .2s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14,158,142,0.1);
}

textarea { resize: vertical; min-height: 90px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Alerts / Flash ── */
.flash {
  padding: 14px 18px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.flash-success { background: rgba(56,161,105,0.1); color: var(--success); border: 1px solid rgba(56,161,105,0.2); }
.flash-info    { background: rgba(14,158,142,0.08); color: var(--navy); border: 1px solid rgba(14,158,142,0.25); }
.flash-error   { background: rgba(229,62,62,0.1); color: var(--danger); border: 1px solid rgba(229,62,62,0.2); }
.flash-warning { background: rgba(214,158,46,0.1); color: var(--warning); border: 1px solid rgba(214,158,46,0.2); }

/* ── Appliance Grid ── */
.appliance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.appliance-card {
  background: var(--white);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all .25s;
}

.appliance-card:hover { border-color: var(--teal); box-shadow: var(--shadow); }

.appliance-card.on {
  border-color: var(--teal);
  background: var(--teal-pale);
}

.appliance-icon { font-size: 32px; margin-bottom: 10px; }
.appliance-name { font-size: 13px; font-weight: 600; color: var(--navy); }

.toggle-switch {
  position: relative;
  width: 44px; height: 24px;
  margin: 10px auto 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--gray-200);
  border-radius: 24px;
  transition: .3s;
  cursor: pointer;
}

.toggle-slider:before {
  content: '';
  position: absolute;
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: .3s;
}

input:checked + .toggle-slider { background: var(--teal); }
input:checked + .toggle-slider:before { transform: translateX(20px); }

/* ── Charts area ── */
.chart-container { position: relative; height: 260px; }

/* ── Empty states ── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray-400);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
  background: white;
  border-radius: 14px;
  padding: 28px;
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title { font-family: 'Poppins', sans-serif; font-size: 18px; font-weight: 600; color: var(--navy); }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--gray-400); }

/* ── Progress bars ── */
.progress { background: var(--gray-100); border-radius: 20px; height: 8px; }
.progress-bar { height: 8px; border-radius: 20px; background: var(--teal); transition: width .5s; }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger  { background: var(--danger); }

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  background: var(--navy);
}

.login-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 48px;
  background: linear-gradient(135deg, var(--navy) 60%, var(--navy-light));
}

.login-brand { text-align: center; margin-bottom: 48px; }
.login-brand h1 { font-family: 'Poppins', sans-serif; font-size: 42px; font-weight: 700; color: white; }
.login-brand h1 span { color: var(--teal-light); }
.login-brand p { color: rgba(255,255,255,0.5); font-size: 15px; margin-top: 8px; }

.login-features { list-style: none; }
.login-features li {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,0.75);
  font-size: 14px;
  padding: 8px 0;
}
.login-features li span { font-size: 20px; }

.login-right {
  width: 440px;
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
}

.login-form-wrap { width: 100%; }
.login-form-wrap h2 { font-family: 'Poppins', sans-serif; font-size: 24px; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.login-form-wrap p { color: var(--gray-400); font-size: 14px; margin-bottom: 28px; }

/* ── Notification panel ── */
.notif-panel {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  width: 360px;
  height: calc(100vh - var(--topbar-h));
  background: white;
  border-left: 1px solid var(--gray-200);
  z-index: 150;
  transform: translateX(100%);
  transition: transform .3s;
  display: flex;
  flex-direction: column;
}

.notif-panel.open { transform: translateX(0); }

.notif-panel-header {
  padding: 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notif-panel-title { font-weight: 600; font-size: 16px; color: var(--navy); }

.notif-list { flex: 1; overflow-y: auto; }

.notif-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: background .15s;
}

.notif-item:hover { background: var(--gray-50); }
.notif-item.unread { border-left: 3px solid var(--teal); }

.notif-item-title { font-size: 14px; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.notif-item-msg   { font-size: 13px; color: var(--gray-400); margin-bottom: 6px; }
.notif-item-time  { font-size: 11px; color: var(--gray-400); }

/* ── Usage meter ── */
.usage-meter { margin-bottom: 16px; }
.usage-header { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.usage-label  { font-weight: 500; color: var(--gray-600); }
.usage-value  { color: var(--navy); font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ── Phone menu button (hidden on computers) ── */
.menu-toggle { display: none; }
.sidebar-backdrop { display: none; }

/* ── Responsive: tablets and phones ── */
@media (max-width: 1024px) {
  /* sidebar slides in from the left when ☰ is tapped */
  .sidebar { transform: translateX(-100%); z-index: 130; }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.25); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 125; }
  .menu-toggle {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: calc((var(--topbar-h) - 40px) / 2); left: 12px; z-index: 140;
    width: 40px; height: 40px; border: none; border-radius: 10px;
    background: var(--navy); color: #fff; font-size: 20px; cursor: pointer;
  }
  .main-content { margin-left: 0; min-width: 0; }

  /* top bar: room for the ☰ button, shorter title */
  .topbar { height: auto; min-height: var(--topbar-h); padding: 10px 12px 10px 64px; gap: 8px; flex-wrap: wrap; }
  .topbar-title { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1 1 120px; }
  .topbar-actions { gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
  .topbar .btn { padding: 7px 10px; font-size: 13px; }

  /* tighter spacing */
  .page-content { padding: 16px 12px; }
  .card { padding: 16px; overflow-x: auto; }
  .card-header { flex-wrap: wrap; gap: 8px; }

  /* everything in one column */
  .form-row, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
  .stat-card { padding: 14px; }

  /* appliance cards: two per row on a phone */
  .appliance-grid { grid-template-columns: 1fr 1fr !important; gap: 12px; }

  /* keep the logo clear of the ✕ button when the menu is open */
  .sidebar-logo { padding-left: 64px; }

  /* wide tables scroll sideways inside their card instead of squashing */
  .card table, .table-wrap table { min-width: 560px; }

  /* pop-up forms fit the screen */
  .modal { width: 95vw !important; max-width: 95vw !important; max-height: 90vh; overflow-y: auto; }

  /* inputs at 16px so iPhones don't zoom in when typing */
  input, select, textarea { font-size: 16px !important; }

  .login-left { display: none; }
  .login-right { width: 100%; }
  .login-logo-mobile { display: block; width: 180px; height: auto; margin: 0 auto 20px; }
}

@media (max-width: 640px) {
  /* phones: side-by-side sections become one column */
  .page-content [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-form-wrap { padding: 0 8px; }
}
.mb-20  { margin-bottom: 20px; }
.mb-28  { margin-bottom: 28px; }
.mt-16  { margin-top: 16px; }
.text-right { text-align: right; }
.flex-center { display: flex; align-items: center; gap: 10px; }

/* long links/emails inside messages wrap instead of widening the page */
.flash { overflow-wrap: break-word; word-break: break-word; }
@media (max-width: 1024px) {
  .flash { display: block; }
}

/* all screen sizes: wide tables scroll inside their box instead of widening the page */
.main-content { min-width: 0; }
.table-wrap { overflow-x: auto; }
.card { max-width: 100%; }
