/* ============================================================
   Home Redevelopment Tracker — Shared Styles
   ============================================================ */

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:   #22c55e;
  --blue:    #3b82f6;
  --grey:    #94a3b8;
  --red:     #ef4444;
  --orange:  #f97316;
  --yellow:  #eab308;
  --bg:      #f1f5f9;
  --surface: #ffffff;
  --nav-bg:  #1e3a5f;
  --text:    #1e293b;
  --muted:   #64748b;
  --border:  #e2e8f0;
  --radius:  10px;
  --shadow:  0 1px 4px rgba(0,0,0,.08);
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

/* ── Top nav ──────────────────────────────────────────────── */
.nav {
  background: var(--nav-bg);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.nav-brand {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .3px;
  margin-right: auto;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  gap: 2px;
  list-style: none;
}

.nav-links a {
  display: block;
  padding: 8px 14px;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  border-radius: 6px;
  font-size: 14px;
  transition: background .15s, color .15s;
}

.nav-links a:hover,
.nav-links a.active {
  background: rgba(255,255,255,.15);
  color: #fff;
}

/* ── Budget edit button ───────────────────────────────────── */
.btn-edit-budget {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: var(--muted);
  padding: 0 2px;
  vertical-align: middle;
  opacity: .6;
}
.btn-edit-budget:hover { opacity: 1; }

/* ── Project picker (nav) ─────────────────────────────────── */
.project-picker {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-left: 16px;
  width: auto;
}

.project-picker option {
  background: var(--nav-bg);
  color: #fff;
}

/* ── Page layout ──────────────────────────────────────────── */
.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.page-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 20px;
}

/* ── Stat cards (dashboard numbers) ──────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.stat-value.green  { color: var(--green); }
.stat-value.blue   { color: var(--blue); }
.stat-value.red    { color: var(--red); }
.stat-value.orange { color: var(--orange); }

/* ── Status badges ────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-done,
.badge-paid,
.badge-delivered  { background: #dcfce7; color: #166534; }

.badge-active,
.badge-in-progress,
.badge-ordered    { background: #dbeafe; color: #1e40af; }

.badge-pending    { background: #f1f5f9; color: #475569; }
.badge-overdue    { background: #fee2e2; color: #991b1b; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: opacity .15s, box-shadow .15s;
  text-decoration: none;
}

.btn:hover { opacity: .88; }

.btn-primary { background: var(--blue); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-danger  { background: var(--red); color: #fff; }
.btn-ghost   { background: transparent; color: var(--muted); border: 1px solid var(--border); }

.btn-sm { padding: 4px 10px; font-size: 12px; }

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

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

th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* ── Progress bar ─────────────────────────────────────────── */
.progress-bar {
  height: 10px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 8px;
}

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

.progress-fill.green { background: var(--green); }

/* ── Stage timeline ───────────────────────────────────────── */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 19px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
  z-index: 0;
}

.stage-item {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  position: relative;
  z-index: 1;
  padding: 4px 0;
}

.stage-dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}

.stage-dot.done    { border-color: var(--green); background: #dcfce7; }
.stage-dot.active  { border-color: var(--blue);  background: #dbeafe; box-shadow: 0 0 0 4px #bfdbfe; }
.stage-dot.pending { border-color: var(--border); }

.stage-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.stage-card.done    { border-left: 4px solid var(--green); }
.stage-card.active  { border-left: 4px solid var(--blue); box-shadow: 0 0 0 2px #bfdbfe, var(--shadow); }
.stage-card.pending { border-left: 4px solid var(--border); opacity: .85; }

.stage-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.stage-meta {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
}

.stage-notes {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
  font-style: italic;
}

/* ── Filter tabs ──────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  transition: all .15s;
}

.filter-tab.active,
.filter-tab:hover {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

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

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

.modal {
  background: var(--surface);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

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

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

input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border .15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px #dbeafe;
}

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

/* ── Furniture room groups ────────────────────────────────── */
.room-group {
  margin-bottom: 24px;
}

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

.room-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.room-total {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.furniture-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.furniture-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.furniture-item-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}

.furniture-item-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  line-height: 1.6;
}

.furniture-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

/* ── Document cards ───────────────────────────────────────── */
.doc-category {
  margin-bottom: 24px;
}

.doc-category-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--nav-bg);
  border-bottom: 2px solid var(--border);
  padding-bottom: 6px;
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.doc-card-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}

.doc-card-notes {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
  white-space: pre-wrap;
}

.doc-card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Loading & empty states ───────────────────────────────── */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.empty-state p { margin-top: 8px; font-size: 14px; }

/* ── Top bar with button ──────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.section-title {
  font-size: 17px;
  font-weight: 700;
}

/* ── Summary strip ────────────────────────────────────────── */
.summary-strip {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.summary-item {
  display: flex;
  flex-direction: column;
  min-width: 100px;
}

.summary-item-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
}

.summary-item-value {
  font-size: 18px;
  font-weight: 700;
  margin-top: 2px;
}

.summary-item-value.green  { color: var(--green); }
.summary-item-value.red    { color: var(--red); }
.summary-item-value.blue   { color: var(--blue); }

/* ── Toast notifications ──────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  opacity: 0;
  transform: translateY(10px);
  transition: all .2s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }

/* ── Toggle switch ────────────────────────────────────────── */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0 !important;
  height: 0 !important;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  transition: background .2s;
  cursor: pointer;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

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

/* ── EMI calculator ───────────────────────────────────────── */
.emi-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0 20px;
}

.emi-balance-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--muted);
  margin-top: 10px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 640px) {
  .nav { padding: 0 12px; height: auto; flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
  .nav-brand { font-size: 15px; }
  .nav-links a { padding: 6px 10px; font-size: 13px; }
  .page { padding: 16px 12px 40px; }
  .stat-value { font-size: 22px; }
  .modal { margin: 12px; }
}
