/* =========================================================
   TAQINOR Solar Quote Simulator — Main Stylesheet
   ========================================================= */

:root {
  --blue-main: #0A5275;
  --blue-dark: #073d57;
  --blue-light: #E6F1F7;
  --blue-mid: #1a7aad;
  --orange-accent: #F28E2B;
  --orange-dark: #d4751a;
  --text-dark: #222222;
  --text-medium: #555555;
  --text-light: #888888;
  --grey-neutral: #555555;
  --grey-bg: #f5f7fa;
  --grey-border: #dde3ea;
  --white: #ffffff;
  --danger: #dc3545;
  --danger-dark: #b02a37;
  --success: #198754;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--grey-bg);
  color: var(--text-dark);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--blue-main); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout ---- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.page-wrapper { display: flex; flex-direction: column; min-height: 100vh; }
.main-content { flex: 1; padding: 1.5rem 0 2rem; }

/* ---- Header / Navbar ---- */
.navbar {
  background: var(--blue-main);
  color: var(--white);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 1000;
}
.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--white);
  text-decoration: none;
}
.navbar-brand .brand-icon {
  font-size: 1.5rem;
}
.navbar-brand .brand-sub {
  font-size: 0.8rem;
  font-weight: 400;
  opacity: 0.8;
  display: block;
  line-height: 1;
}
.navbar-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
}
.navbar-nav .nav-link {
  color: rgba(255,255,255,0.85);
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border: none;
  background: none;
}
.navbar-nav .nav-link:hover,
.navbar-nav .nav-link.active {
  background: rgba(255,255,255,0.15);
  color: var(--white);
  text-decoration: none;
}
.navbar-nav .nav-link.active {
  background: rgba(255,255,255,0.2);
}
.navbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}
.user-badge {
  background: rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
}
.user-badge .role {
  color: var(--orange-accent);
  font-weight: 600;
  margin-left: 0.25rem;
}

/* ---- Tab Content ---- */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---- Cards ---- */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--grey-border);
  overflow: hidden;
}
.card-header {
  background: var(--blue-light);
  border-bottom: 1px solid var(--grey-border);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.card-header h2, .card-header h3 {
  color: var(--blue-main);
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}
.card-body { padding: 1.25rem; }
.card + .card { margin-top: 1.25rem; }

/* ---- Section header ---- */
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--blue-main);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--blue-light);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ---- Forms ---- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-medium);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.form-group.full-width { grid-column: 1 / -1; }

.form-control {
  border: 1.5px solid var(--grey-border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  color: var(--text-dark);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.form-control:focus {
  outline: none;
  border-color: var(--blue-main);
  box-shadow: 0 0 0 3px rgba(10, 82, 117, 0.12);
}
.form-control:disabled { background: var(--grey-bg); cursor: not-allowed; }

select.form-control { cursor: pointer; }

/* ---- Slider ---- */
.slider-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
input[type="range"] {
  flex: 1;
  accent-color: var(--blue-main);
  cursor: pointer;
}
.slider-value {
  background: var(--blue-main);
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 3rem;
  text-align: center;
}

/* ---- Radio Group ---- */
.radio-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.radio-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.875rem;
  border: 1.5px solid var(--grey-border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: border-color 0.15s, background 0.15s;
}
.radio-option:hover { border-color: var(--blue-main); background: var(--blue-light); }
.radio-option input[type="radio"] { accent-color: var(--blue-main); }
.radio-option.selected {
  border-color: var(--blue-main);
  background: var(--blue-light);
  color: var(--blue-main);
  font-weight: 600;
}

/* ---- Monthly Grid ---- */
.monthly-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
}
.month-input-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}
.month-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-medium);
  text-align: center;
}
.month-input {
  text-align: center;
  padding: 0.35rem 0.25rem;
  font-size: 0.82rem;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--blue-main);
  color: var(--white);
  box-shadow: 0 2px 6px rgba(10,82,117,0.25);
}
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); }

.btn-orange {
  background: var(--orange-accent);
  color: var(--white);
  box-shadow: 0 2px 6px rgba(242,142,43,0.3);
}
.btn-orange:hover:not(:disabled) { background: var(--orange-dark); }

.btn-secondary {
  background: var(--grey-bg);
  color: var(--text-dark);
  border: 1.5px solid var(--grey-border);
}
.btn-secondary:hover:not(:disabled) { background: #e8ecf0; border-color: #bcc5cf; }

.btn-danger {
  background: var(--danger);
  color: var(--white);
}
.btn-danger:hover:not(:disabled) { background: var(--danger-dark); }

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

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}
.btn-lg {
  padding: 0.75rem 1.75rem;
  font-size: 1rem;
}

.btn-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ---- Tables ---- */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--grey-border); }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead { background: var(--blue-main); color: var(--white); }
thead th {
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--grey-border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:nth-child(even) { background: var(--grey-bg); }
tbody tr:hover { background: var(--blue-light); }
tbody td { padding: 0.55rem 0.75rem; vertical-align: middle; }

/* Editable table inputs */
.table-input {
  border: 1px solid var(--grey-border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.4rem;
  font-size: 0.82rem;
  width: 100%;
  min-width: 60px;
  background: var(--white);
}
.table-input:focus {
  outline: none;
  border-color: var(--blue-main);
}
.table-input-wide { min-width: 120px; }
.table-input-num { min-width: 70px; text-align: right; }
.onduleur-power-select { font-size: 0.78rem; min-width: 140px; }

/* ---- ROI Metrics ---- */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.metric-card {
  background: var(--white);
  border: 1.5px solid var(--grey-border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  text-align: center;
}
.metric-card.highlight { border-color: var(--blue-main); background: var(--blue-light); }
.metric-card.highlight-orange { border-color: var(--orange-accent); background: #fff8f0; }
.metric-label {
  font-size: 0.75rem;
  color: var(--text-medium);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  margin-bottom: 0.3rem;
}
.metric-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--blue-main);
}
.metric-card.highlight-orange .metric-value { color: var(--orange-dark); }
.metric-unit {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 0.1rem;
}

/* ---- Chart container ---- */
.chart-container {
  position: relative;
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--grey-border);
  padding: 1rem;
  margin-top: 1rem;
}
.chart-container canvas { max-height: 300px; }

/* ---- Download banner ---- */
.download-banner {
  background: #d4edda;
  border: 1px solid #b7dfbf;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}
.download-banner .download-icon { font-size: 1.5rem; }
.download-banner strong { color: var(--success); }

/* ---- Alerts ---- */
.alert {
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}
.alert-info { background: #d1ecf1; border: 1px solid #bee5eb; color: #0c5460; }
.alert-danger { background: #f8d7da; border: 1px solid #f5c6cb; color: #721c24; }
.alert-success { background: #d4edda; border: 1px solid #c3e6cb; color: #155724; }
.alert-warning { background: #fff3cd; border: 1px solid #ffeeba; color: #856404; }

/* ---- Loading spinner ---- */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
.spinner-dark {
  border-color: rgba(10,82,117,0.25);
  border-top-color: var(--blue-main);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Toast notifications ---- */
#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 360px;
}
.toast {
  background: var(--white);
  border-left: 4px solid var(--blue-main);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  animation: slideIn 0.25s ease;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-danger { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--orange-accent); }
.toast-close {
  margin-left: auto;
  cursor: pointer;
  opacity: 0.6;
  font-size: 1rem;
  line-height: 1;
  border: none;
  background: none;
  padding: 0 0.25rem;
}
.toast-close:hover { opacity: 1; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---- Login page ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue-main) 50%, var(--blue-mid) 100%);
}
.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
}
.login-logo {
  text-align: center;
  margin-bottom: 1.75rem;
}
.login-logo .logo-text {
  font-size: 2rem;
  font-weight: 800;
  color: var(--blue-main);
  letter-spacing: 0.05em;
}
.login-logo .logo-sun {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.25rem;
}
.login-logo .logo-sub {
  font-size: 0.85rem;
  color: var(--text-medium);
  margin-top: 0.25rem;
}
.login-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 1.5rem;
  text-align: center;
}
.login-card .form-group { margin-bottom: 1rem; }
.login-card .form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-medium);
  margin-bottom: 0.3rem;
  display: block;
  text-transform: none;
}
.login-card .form-control { padding: 0.65rem 0.875rem; font-size: 0.95rem; }
.login-btn { width: 100%; padding: 0.75rem; font-size: 1rem; margin-top: 0.5rem; }
#login-error {
  background: #f8d7da;
  color: #721c24;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.875rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  display: none;
}

/* ---- Admin badge ---- */
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-admin { background: var(--orange-accent); color: white; }
.badge-user { background: var(--blue-light); color: var(--blue-main); }

/* ---- Divider ---- */
.divider {
  border: none;
  border-top: 1px solid var(--grey-border);
  margin: 1.25rem 0;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #bcc5cf; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #99a8b3; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .navbar-nav { display: none; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .monthly-grid { grid-template-columns: repeat(3, 1fr); }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .card-body { padding: 1rem; }
}
@media (max-width: 480px) {
  html { font-size: 14px; }
  .monthly-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Custom line table ---- */
.custom-lines-section { margin-top: 0.75rem; }
.custom-lines-section h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--blue-main);
  margin-bottom: 0.5rem;
}

/* ---- Notes ---- */
.notes-section { margin-top: 0.75rem; }
.notes-section h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--blue-main);
  margin-bottom: 0.5rem;
}
.note-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  align-items: center;
}
.note-row textarea {
  flex: 1;
  border: 1.5px solid var(--grey-border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  resize: none;
  height: 2.2rem;
}
.note-row textarea:focus {
  outline: none;
  border-color: var(--blue-main);
}

/* ---- Totals row ---- */
.totals-row {
  background: var(--blue-light);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}
.total-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.total-label { font-size: 0.75rem; color: var(--text-medium); font-weight: 600; text-transform: uppercase; }
.total-value { font-size: 1.1rem; font-weight: 700; color: var(--blue-main); }
.total-value.orange { color: var(--orange-dark); }

/* ---- Page header ---- */
.page-header {
  background: var(--white);
  border-bottom: 1px solid var(--grey-border);
  padding: 1rem 0;
  margin-bottom: 1.5rem;
}
.page-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.page-header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--blue-main);
}

/* ---- Toggle Switch (pill-style, amber when active) ---- */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #ccc;
  border-radius: 24px;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--orange-accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }
