/* iBuilder Realty Developer — Front-end styles */
:root {
  --ibrwd-primary: #2563eb;
  --ibrwd-primary-dark: #1e4fd0;
  --ibrwd-green: #16a34a;
  --ibrwd-red: #dc2626;
  --ibrwd-yellow: #ca8a04;
  --ibrwd-border: #e5e7eb;
  --ibrwd-bg: #f9fafb;
  --ibrwd-radius: 8px;
}

.ibrwd-proforma, .ibrwd-flip, .ibrwd-reno, .ibrwd-deal-score, .ibrwd-my-proformas {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Section */
.ibrwd-section-title { font-size: 22px; font-weight: 700; margin-bottom: 20px; border-bottom: 2px solid var(--ibrwd-border); padding-bottom: 10px; }
.ibrwd-sub-title { font-size: 16px; font-weight: 600; margin: 20px 0 10px; }

/* Layout */
.ibrwd-proforma-layout, .ibrwd-flip-layout, .ibrwd-reno-layout { display: grid; gap: 24px; }
@media (min-width: 900px) {
  .ibrwd-proforma-layout { grid-template-columns: 460px 1fr; }
  .ibrwd-flip-layout     { grid-template-columns: 400px 1fr; }
  .ibrwd-reno-layout     { grid-template-columns: 380px 1fr; }
}

/* Fieldsets */
.ibrwd-fieldset { border: 1px solid var(--ibrwd-border); border-radius: var(--ibrwd-radius); padding: 16px; margin-bottom: 16px; }
.ibrwd-fieldset legend { font-weight: 700; color: var(--ibrwd-primary); padding: 0 6px; }
.ibrwd-field-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.ibrwd-field label { display: block; font-size: 12px; font-weight: 600; color: #6b7280; margin-bottom: 4px; }

/* Inputs */
.ibrwd-input, .ibrwd-select {
  width: 100%; box-sizing: border-box;
  padding: 8px 10px; border: 1px solid var(--ibrwd-border); border-radius: 6px; font-size: 14px;
}
.ibrwd-input:focus, .ibrwd-select:focus { outline: none; border-color: var(--ibrwd-primary); box-shadow: 0 0 0 3px rgba(124,58,237,.15); }

/* Buttons */
.ibrwd-btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px; border-radius: 6px; border: none; cursor: pointer; font-size: 14px; font-weight: 600; transition: background .15s; }
.ibrwd-btn--primary { background: var(--ibrwd-primary); color: #fff; }
.ibrwd-btn--primary:hover { background: var(--ibrwd-primary-dark); }
.ibrwd-btn--outline { background: transparent; color: var(--ibrwd-primary); border: 1px solid var(--ibrwd-primary); }
.ibrwd-btn--sm { padding: 4px 10px; font-size: 12px; }
.ibrwd-btn--danger { background: var(--ibrwd-red); color: #fff; }

/* Actions row */
.ibrwd-proforma-actions { display: flex; gap: 10px; margin-top: 8px; }

/* Metrics grid */
.ibrwd-metrics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px; }
.ibrwd-metric-card { background: #fff; border: 1px solid var(--ibrwd-border); border-radius: var(--ibrwd-radius); padding: 16px; text-align: center; }
.ibrwd-metric-card__value { font-size: 28px; font-weight: 800; }
.ibrwd-metric-card__label { font-size: 11px; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: .5px; margin-top: 4px; }
.ibrwd-metric--positive .ibrwd-metric-card__value { color: var(--ibrwd-green); }
.ibrwd-metric--negative .ibrwd-metric-card__value { color: var(--ibrwd-red); }
.ibrwd-metric--neutral  .ibrwd-metric-card__value { color: var(--ibrwd-primary); }

/* Annual table */
.ibrwd-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 12px; }
.ibrwd-table th { background: var(--ibrwd-bg); padding: 8px 10px; text-align: right; font-size: 11px; text-transform: uppercase; }
.ibrwd-table th:first-child, .ibrwd-table td:first-child { text-align: left; }
.ibrwd-table td { padding: 8px 10px; border-bottom: 1px solid var(--ibrwd-border); text-align: right; }
.ibrwd-table tr.negative td { color: var(--ibrwd-red); }

/* Deal Score */
.ibrwd-deal-score { display: grid; gap: 20px; }
@media (min-width: 600px) { .ibrwd-deal-score { grid-template-columns: 200px 1fr; align-items: center; } }
.ibrwd-deal-score__dial { position: relative; width: 160px; margin: 0 auto; }
.ibrwd-score-arc { width: 160px; }
.ibrwd-deal-score__num { position: absolute; bottom: 18px; left: 0; right: 0; text-align: center; font-size: 36px; font-weight: 800; }
.ibrwd-deal-score__grade { position: absolute; bottom: 2px; left: 0; right: 0; text-align: center; font-size: 14px; font-weight: 700; color: #6b7280; }
.ibrwd-deal-score__reco { font-size: 14px; line-height: 1.6; background: var(--ibrwd-bg); padding: 12px 16px; border-radius: var(--ibrwd-radius); }
.ibrwd-score-comp { display: grid; grid-template-columns: 130px 1fr 36px; gap: 8px; align-items: center; margin-bottom: 8px; }
.ibrwd-score-comp__label { font-size: 12px; font-weight: 600; color: #6b7280; }
.ibrwd-score-comp__bar { height: 8px; background: var(--ibrwd-border); border-radius: 99px; overflow: hidden; }
.ibrwd-score-comp__fill { height: 100%; background: var(--ibrwd-primary); border-radius: 99px; transition: width .4s; }
.ibrwd-score-comp__val { font-size: 12px; font-weight: 700; text-align: right; }

/* Chart */
.ibrwd-chart { max-width: 100%; height: 260px !important; }

/* Renovation */
.ibrwd-reno-scope { margin-bottom: 16px; }
.ibrwd-reno-scope__header { font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: .5px; color: #6b7280; padding: 6px 0; border-bottom: 1px solid var(--ibrwd-border); margin-bottom: 8px; }
.ibrwd-reno-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 13px; cursor: pointer; flex-wrap: wrap; }
.ibrwd-reno-item:hover { background: var(--ibrwd-bg); }
.ibrwd-reno-item__name { flex: 1; }
.ibrwd-reno-item__range { font-size: 11px; color: #6b7280; }
.ibrwd-reno-item__qty-wrap { display: flex; gap: 6px; margin-left: auto; }
.ibrwd-reno-qty, .ibrwd-reno-tier { width: 80px; }
.ibrwd-reno-totals { margin-top: 16px; background: var(--ibrwd-bg); padding: 16px; border-radius: var(--ibrwd-radius); font-size: 14px; }

/* Comps */
.ibrwd-comps { margin-top: 28px; }
.ibrwd-comps-source { font-size: 13px; font-weight: 400; color: #6b7280; }
.ibrwd-comps-stats { display: flex; gap: 20px; flex-wrap: wrap; background: var(--ibrwd-bg); padding: 12px 16px; border-radius: var(--ibrwd-radius); margin-bottom: 12px; font-size: 14px; }
.ibrwd-comps-arv { color: var(--ibrwd-primary); }
.ibrwd-comps-link { background: none; border: none; color: var(--ibrwd-primary); cursor: pointer; font-size: 12px; font-weight: 600; padding: 4px 0 0; }
.ibrwd-comps-link:hover { text-decoration: underline; }

/* Notices */
.ibrwd-notice, .ibrwd-error { padding: 12px 16px; border-radius: var(--ibrwd-radius); background: var(--ibrwd-bg); color: #6b7280; font-size: 14px; }

/* Print / PDF */
@media print {
  body * { visibility: hidden; }
  #ibrwd-proforma-app, #ibrwd-proforma-app * { visibility: visible; }
  #ibrwd-proforma-app { position: absolute; left: 0; top: 0; width: 100%; }
  .ibrwd-proforma-actions, #ibrwd-print-btn, #ibrwd-save-btn, #ibrwd-run-btn { display: none !important; }
  .ibrwd-inputs-panel { break-inside: avoid; }
  .ibrwd-results-panel { display: block !important; }
  .ibrwd-metrics-grid { grid-template-columns: repeat(4, 1fr); }
  .ibrwd-chart { max-height: 220px !important; }
  .ibrwd-table { font-size: 11px; }
  .ibrwd-fieldset { border: 1px solid #ccc; margin-bottom: 12px; }
  a[href]:after { content: none !important; }
  @page { margin: 1.5cm; size: A4 portrait; }
}
