/* =============================
   SOLAR MANAGER – FINAL CLEAN UI
   Apple-like Minimal Layout Fix
   ============================= */

/* RESET */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display",
    "Helvetica Neue", sans-serif;
  background: #f5f6f8;
  color: #111;
  -webkit-font-smoothing: antialiased;
}

/* TOKENS */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e6e8ec;

  --text-muted: #6b7280;
  --text-light: #9ca3af;

  --sun: #f59e0b;
  --sun-soft: #fbbf24;
  --sun-pale: #fff7ed;

  --green: #22c55e;
  --green-light: #ecfdf5;

  --red: #ef4444;
  --indigo: #6366f1;
  --indigo-light: #eef2ff;

  --radius: 22px;
  --radius-sm: 14px;

  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.06);
}

/* PAGE SYSTEM */
.page {
  display: none;
  min-height: 100vh;
  /* increase bottom padding so fixed bottom-nav doesn't overlap content */
  padding: 28px 22px 160px;
  animation: fadeIn .35s ease;
}

.page.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* CENTER AUTH PAGES */
#page-login.active,
#page-signup.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* WRAPPERS */
.page-content,
.page-header {
  max-width: 1180px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: center;
  margin-bottom: 22px;
}

/* TYPOGRAPHY */
h2 {
  font-size: 22px;
  font-weight: 700;
}

h3 {
  font-size: 20px;
  font-weight: 700;
}

.font-bold {
  font-weight: 700;
}

.negative {
  color: var(--red);
}

.mb-1 {
  margin-bottom: 4px;
}

.mb-3 {
  margin-bottom: 12px;
}

.mb-4 {
  margin-bottom: 16px;
}

.mt-4 {
  margin-top: 16px;
}

/* AUTH CARD */
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 30px;
  padding: 34px 28px;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.auth-logo {
  margin-bottom: 22px;
}

.sun-icon {
  font-size: 42px;
  display: block;
  margin-bottom: 6px;
}

.auth-logo h1 {
  font-size: 24px;
  font-weight: 700;
}

.auth-logo p {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.auth-link {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-link a {
  color: var(--sun);
  font-weight: 600;
  text-decoration: none;
}

.demo-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-light);
}

/* INPUTS */
.input-group {
  position: relative;
  margin-bottom: 12px;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
  color: var(--text-light);
}

.input-field {
  width: 100%;
  padding: 13px 14px 13px 40px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: #fafafa;
  font-size: 14px;
  outline: none;
  transition: .2s;
}

.input-field:focus {
  border-color: var(--sun-soft);
  background: white;
}

/* BUTTONS */
.btn {
  border: none;
  border-radius: 14px;
  padding: 13px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: .2s;
}

.btn-primary {
  background: var(--sun);
  color: white;
}

.btn-primary:hover {
  background: #e58e09;
}

.btn-danger {
  background: #fee2e2;
  color: var(--red);
}

.btn-ghost {
  background: #f3f4f6;
  color: var(--text-muted);
}

.btn-full {
  width: 100%;
  margin-top: 6px;
}

/* DASHBOARD */
.dashboard-greeting {
  margin-bottom: 16px;
}

.dashboard-greeting h2 {
  font-size: 24px;
  letter-spacing: -0.3px;
}

.dashboard-greeting p {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.live-dot {
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
}

/* METRICS */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: .2s;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.metric-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin-bottom: 6px;
}

.metric-label {
  font-size: 13px;
  color: var(--text-muted);
}

.metric-value {
  font-size: 20px;
  font-weight: 700;
  margin-top: 2px;
}

/* CARDS */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

/* SECTIONS */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
}

.section-badge {
  background: var(--sun-pale);
  color: var(--sun);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}

.chip {
  font-size: 12px;
  padding: 6px 10px;
  background: var(--sun-pale);
  border-radius: 999px;
  color: var(--sun);
}

/* PROGRESS */
.progress-bar {
  height: 8px;
  background: #eef0f3;
  border-radius: 99px;
  overflow: hidden;
  margin-top: 10px;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 99px;
  transition: width .4s ease;
}

/* PROFILE */
.profile-hero {
  text-align: center;
  margin-bottom: 18px;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--sun-pale);
  color: var(--sun);
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 6px;
}

.profile-name {
  font-size: 18px;
  font-weight: 700;
}

.profile-email {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* LISTS */
.info-list,
.menu-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Make the profile info use available width (two columns on larger screens) */
#page-profile .info-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 720px) {
  #page-profile .info-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Slightly more compact cards on profile to reduce empty space */
#page-profile .card {
  padding: 14px;
  border-radius: 18px;
}

.profile-edit {
  padding: 8px 12px;
  border-radius: 12px;
  font-weight: 700;
}

/* Back button used in headers */
.back-btn {
  background: transparent;
  border: none;
  padding: 8px;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 36px;
  margin-right: 12px;
}

.back-btn:hover {
  background: #f3f4f6;
  color: #111;
}

.back-btn:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.06);
}

/* ML tooltip */
.ml-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(17,24,39,0.95);
  color: #fff;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.16);
  transform: translate(-50%, -120%);
  white-space: nowrap;
  z-index: 2500;
}

/* ML legend (interactive) */
.ml-legend { display:flex; gap:10px; align-items:center; }
.ml-legend-item { display:flex; gap:8px; align-items:center; padding:6px 8px; border-radius:8px; background:#fff; border:1px solid var(--border); cursor:pointer; font-weight:700; font-size:13px; }
.ml-legend-dot { width:12px; height:8px; border-radius:3px; display:inline-block; }
.ml-legend-item.hidden { opacity:0.45; }

.info-item,
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.info-icon,
.menu-icon {
  font-size: 18px;
}

.info-label {
  font-size: 12px;
  color: var(--text-light);
}

.info-value {
  font-size: 14px;
  font-weight: 500;
}

.menu-label {
  font-size: 14px;
  font-weight: 500;
}

.menu-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.menu-arrow {
  margin-left: auto;
  color: var(--text-light);
}

/* FAB */
.fab {
  position: fixed;
  bottom: 96px;
  right: 26px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  background: var(--sun);
  color: white;
  font-size: 26px;
  box-shadow: var(--shadow-md);
  cursor: pointer;
}

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

.modal {
  width: 100%;
  max-width: 420px;
  background: white;
  border-radius: 26px;
  padding: 22px;
  box-shadow: var(--shadow-md);
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}

.modal-handle {
  width: 38px;
  height: 4px;
  background: #d1d5db;
  border-radius: 999px;
  margin: 0 auto 10px;
}

/* TOAST */
#toast-container {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
}

/* =============================
   PERFECT BOTTOM NAV BAR
   ============================= */

.bottom-nav {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translate(-50%, 0) scale(1);
  width: calc(100% - 36px);
  max-width: 820px;
  height: 70px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(18px);
  border-radius: 28px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 6px 10px;
  z-index: 999;
  transition: transform .34s cubic-bezier(.2, .9, .3, 1), opacity .28s ease, box-shadow .28s ease;
  will-change: transform, opacity;
}

.nav-btn {
  flex: 1;
  height: 56px;
  border: none;
  background: transparent;
  border-radius: 18px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: .2s;
}

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

.nav-btn.active {
  background: white;
  color: var(--sun);
  box-shadow: var(--shadow-sm);
}

/* Hide nav on auth pages */
#page-login.active~.bottom-nav,
#page-signup.active~.bottom-nav {
  display: none;
}

/* RESPONSIVE */
@media (max-width: 900px) {
  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 520px) {
  .metric-value {
    font-size: 18px;
  }

  .bottom-nav {
    height: 64px;
  }
}

/* Canvas sizing - allow JS to control height to prevent drawing distortion */
canvas {
  width: 100% !important;
  height: auto !important;
  max-height: 420px;
  image-rendering: optimizeQuality;
}

/* Utility to hide elements via JS */
.hidden {
  display: none !important;
}

/* Show modal when open */
.modal-overlay.open {
  display: flex;
}

/* Basic toast styles so messages are visible */
#toast-container .toast {
  background: rgba(17, 24, 39, 0.98);
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  margin-top: 8px;
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

#toast-container .toast.success {
  background: var(--green);
}

#toast-container .toast.error {
  background: var(--red);
}

/* Panels: compass and angle display */
.compass-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.compass-wrap canvas {
  width: 220px;
  max-width: 100%;
  height: auto;
  display: block;
}

.angle-display {
  font-weight: 800;
  font-size: 20px;
  background: var(--surface);
  padding: 8px 12px;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

/* Maintenance: grid of task tiles */
#upcoming-tasks,
#completed-tasks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.task-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}

.task-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.task-check {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.task-check.checked {
  background: var(--green);
  color: white;
}

.task-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-title {
  font-weight: 700;
  font-size: 14px;
}

.task-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.task-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--text-light);
}

.badge {
  padding: 6px 8px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 12px;
}

.badge-high {
  background: #fee2e2;
  color: var(--red);
}

.badge-medium {
  background: #fff7ed;
  color: var(--sun);
}

.badge-low {
  background: #ecfdf5;
  color: var(--green);
}

@media (max-width: 640px) {
  .compass-wrap canvas {
    width: 180px;
  }

  .task-card {
    padding: 10px;
  }
}

/* Reminders list improvements */
.reminder-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--surface);
  padding: 12px;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 10px;
}

.reminder-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.reminder-icon-wrap.maintenance {
  background: linear-gradient(180deg, #fff7ed, #fff);
}

.reminder-icon-wrap.alert {
  background: linear-gradient(180deg, #fff1f2, #fff);
}

.reminder-icon-wrap.info {
  background: linear-gradient(180deg, #eef2ff, #fff);
}

.reminder-icon-wrap.success {
  background: linear-gradient(180deg, #ecfdf5, #fff);
}

.reminder-body {
  flex: 1;
}

.reminder-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
}

.reminder-msg {
  color: var(--text-muted);
  margin-bottom: 8px;
}

.reminder-meta {
  font-size: 13px;
  color: var(--text-light);
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Toggle switch */
.toggle {
  display: inline-block;
}

.toggle input {
  display: none;
}

.toggle .toggle-track {
  width: 44px;
  height: 24px;
  background: #e6e8ec;
  border-radius: 99px;
  position: relative;
  display: inline-block;
  vertical-align: middle;
}

.toggle .toggle-track::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: left .18s ease, background .18s ease;
}

.toggle input:checked+.toggle-track {
  background: var(--green);
}

.toggle input:checked+.toggle-track::after {
  left: 23px;
  background: white;
}

/* Mode buttons */
.mode-selector {
  display: flex;
  gap: 10px;
}

.mode-btn {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  cursor: pointer;
  min-width: 130px;
}

.mode-btn .mode-icon {
  font-size: 18px;
}

.mode-btn .mode-name {
  font-weight: 700;
}

.mode-btn.active {
  background: white;
  box-shadow: var(--shadow-sm);
  border-color: #e2e8f0;
}

/* Legend styling for pie charts */
.pie-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--text-muted);
  margin-left: 18px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.legend-label {
  font-weight: 800;
  color: #111;
  font-size: 15px;
}

.legend-val {
  margin-left: auto;
  color: var(--text-muted);
  font-weight: 700;
}

@media (max-width: 720px) {
  .card>div {
    display: flex;
    flex-direction: column;
  }

  .pie-legend {
    margin-left: 0;
    margin-top: 12px;
    align-items: flex-start;
  }
}

/* Prevent bottom nav from covering charts by adding safe spacing to chart containers */
.chart-container {
  padding-bottom: 22px;
}

/* Task card action buttons */
.task-actions {
  display: flex;
  gap: 8px;
  margin-left: 8px;
  align-items: center;
}

.task-action-btn {
  background: #f3f4f6;
  border: 1px solid var(--border);
  padding: 6px 8px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

.task-action-btn:hover {
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.task-action-btn.danger {
  background: #fff7f7;
  border-color: #f7d7d7;
  color: var(--red);
}

/* Bottom nav collapsible */
.bottom-nav.collapsed {
  transform: translate(-50%, 120%) scale(0.96);
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}