/* ========================================
   DCR – Design Coordination Rate
   Tabbed Layout Stylesheet
======================================== */

/* ---------- Variables ---------- */
:root {
  --clr-bg: #f4f6f8;
  --clr-surface: #ffffff;
  --clr-text: #2d3436;
  --clr-muted: #636e72;
  --clr-accent: #0984e3;
  --clr-border: #dfe6e9;
  
  /* Grade colors */
  --grade-a: #27ae60;
  --grade-b: #2ecc71;
  --grade-c: #f1c40f;
  --grade-d: #e67e22;
  --grade-e: #e74c3c;
  --grade-f: #c0392b;
  --grade-g: #8e44ad;
  --grade-default: #95a5a6;
  
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* ---------- 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(--clr-bg);
  color: var(--clr-text);
  line-height: 1.5;
  min-height: 100vh;
}

.app {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Header with Tabs ---------- */
.header {
  background: var(--clr-surface);
  box-shadow: var(--shadow);
  padding: 0.6rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.logo {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--clr-accent);
  background: linear-gradient(135deg, var(--clr-accent), #00b894);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-title {
  font-size: 0.85rem;
  color: var(--clr-muted);
  font-weight: 500;
}

.tab-nav {
  display: flex;
  gap: 0.3rem;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--clr-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  background: var(--clr-bg);
  color: var(--clr-text);
}

.tab-btn.active {
  background: var(--clr-accent);
  color: white;
}

/* ---------- Tab Content ---------- */
.tab-content {
  display: none;
  padding: 1.5rem;
  flex: 1;
}

.tab-content.active {
  display: block;
}

/* ---------- Hero Section (Report Tab) ---------- */
.hero-section {
  background: var(--clr-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.grade-badge {
  width: 90px;
  height: 90px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.grade-badge span {
  font-size: 3rem;
  font-weight: 800;
  color: white;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Grade badge colors */
.grade-default { background: linear-gradient(135deg, var(--grade-default), #7f8c8d); }
.grade-a { background: linear-gradient(135deg, var(--grade-a), #2ecc71); }
.grade-b { background: linear-gradient(135deg, var(--grade-b), #58d68d); }
.grade-c { background: linear-gradient(135deg, var(--grade-c), #f39c12); }
.grade-d { background: linear-gradient(135deg, var(--grade-d), #d35400); }
.grade-e { background: linear-gradient(135deg, var(--grade-e), #c0392b); }
.grade-f { background: linear-gradient(135deg, var(--grade-f), #a93226); }
.grade-g { background: linear-gradient(135deg, var(--grade-g), #9b59b6); }

.hero-summary {
  flex: 1;
}

.meaning-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--clr-text);
  margin-bottom: 0.3rem;
}

.risk-text {
  font-size: 0.9rem;
  color: var(--clr-muted);
}

/* ---------- Cards ---------- */
.card {
  background: var(--clr-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem 1.5rem;
}

.card h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--clr-muted);
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--clr-border);
  padding-bottom: 0.5rem;
}

/* Main Content Grid */
.main-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
}

/* DCR Scale - BER Style */
.scale-card {
  padding-left: 2rem; /* Room for arrow indicator */
}

.dcr-scale {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: flex-start;
}

.scale-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 0.75rem;
  opacity: 0.4;
  transition: all 0.3s ease;
  min-width: 40%;
  position: relative;
}

.scale-bar.active {
  opacity: 1;
  transform: scale(1.05);
  box-shadow: 0 3px 12px rgba(0,0,0,0.35);
  z-index: 1;
  border: 2px solid #2d3436;
}

.scale-bar.active::before {
  content: '▶';
  position: absolute;
  left: -18px;
  font-size: 0.9rem;
  color: #2d3436;
}

.scale-letter { font-weight: 700; font-size: 0.9rem; min-width: 16px; }
.scale-desc { font-weight: 500; flex: 1; }
.scale-range { font-size: 0.7rem; opacity: 0.9; margin-left: auto; }

.scale-a { background: var(--grade-a); }
.scale-b { background: var(--grade-b); }
.scale-c { background: var(--grade-c); color: var(--clr-text); }
.scale-d { background: var(--grade-d); }
.scale-e { background: var(--grade-e); }
.scale-f { background: var(--grade-f); }
.scale-g { background: var(--grade-g); }

/* Metrics Card */
.metrics-content {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.building-illustration {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.building-svg {
  width: 100%;
  height: 100%;
  transition: transform 0.3s ease;
}

/* Building size scale classes */
.building-svg.size-small { transform: scale(0.7); }
.building-svg.size-medium { transform: scale(0.85); }
.building-svg.size-large { transform: scale(1.0); }

.metrics-details {
  flex: 1;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
  font-size: 0.85rem;
}

.metric-label { color: var(--clr-muted); }
.metric-value { font-weight: 600; color: var(--clr-text); }

.metric-divider {
  border: none;
  border-top: 1px dashed var(--clr-border);
  margin: 0.5rem 0;
}

.metric-row-highlight {
  background: var(--clr-bg);
  margin: 0.3rem -0.5rem 0;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
}

.metric-row-highlight .metric-value {
  color: var(--clr-accent);
  font-size: 1rem;
}

/* ---------- Inline Inputs Section ---------- */
.inputs-inline {
  margin-top: 1.2rem;
}

.inputs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
  border-bottom: 1px solid var(--clr-border);
  padding-bottom: 0.5rem;
}

.inputs-header h3 {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.form-row {
  display: flex;
  gap: 1rem;
  align-items: stretch;
}

.fieldset-inline {
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  flex: 1;
  min-width: 200px;
}

/* Give Building Setup more space */
.fieldset-building {
  flex: 1.2;
}

.fieldset-inline legend {
  font-weight: 600;
  color: var(--clr-accent);
  padding: 0 0.4rem;
  font-size: 0.8rem;
}

.inline-fields {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.inline-fields .form-group {
  flex: 1;
  min-width: 70px;
  margin-bottom: 0;
}

.inline-fields .form-group label {
  font-size: 0.75rem;
  margin-bottom: 0.2rem;
}

.inline-fields .form-group input,
.inline-fields .form-group select {
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
}

.btn-calculate {
  padding: 0.5rem 1.2rem;
  background: linear-gradient(135deg, var(--clr-accent), #00b894);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}

.btn-calculate:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(9, 132, 227, 0.3);
}

.btn-calculate:active {
  transform: translateY(0);
}

/* Legacy form styles (keep for fieldsets) */
fieldset {
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 1.2rem;
}

legend {
  font-weight: 600;
  color: var(--clr-accent);
  padding: 0 0.5rem;
  font-size: 0.9rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--clr-muted);
  margin-bottom: 0.3rem;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--clr-text);
  background: var(--clr-surface);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--clr-accent);
  box-shadow: 0 0 0 3px rgba(9, 132, 227, 0.15);
}

.form-group input[readonly] {
  background: var(--clr-bg);
  color: var(--clr-muted);
}

.field-hint {
  font-size: 0.8rem;
  color: var(--clr-muted);
  margin-bottom: 1rem;
  font-style: italic;
}

.clash-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.btn-primary {
  width: 100%;
  padding: 0.9rem 1.5rem;
  background: linear-gradient(135deg, var(--clr-accent), #00b894);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(9, 132, 227, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

/* ---------- About Tab ---------- */
.about-section {
  background: var(--clr-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

/* About Internal Tabs */
.about-tab-nav {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--clr-border);
  padding-bottom: 0;
}

.about-tab {
  background: transparent;
  border: none;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--clr-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s ease;
}

.about-tab:hover {
  color: var(--clr-text);
  background: var(--clr-bg);
}

.about-tab.active {
  color: var(--clr-accent);
  border-bottom-color: var(--clr-accent);
  font-weight: 600;
}

/* About Panels */
.about-panel {
  display: none;
}

.about-panel.active {
  display: block;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.2rem;
}

.about-item {
  padding: 1rem;
  background: var(--clr-bg);
  border-radius: var(--radius-sm);
}

.about-item h4 {
  font-size: 0.9rem;
  color: var(--clr-accent);
  margin-bottom: 0.4rem;
}

.about-item p {
  font-size: 0.85rem;
  color: var(--clr-muted);
  line-height: 1.5;
}

/* Tutorial Panel */
.tutorial-card {
  background: var(--clr-bg);
}

.tutorial-card h4 {
  font-size: 1.1rem;
  color: var(--clr-text);
  margin-bottom: 0.8rem;
}

.tutorial-card > p {
  color: var(--clr-muted);
  margin-bottom: 1rem;
}

.tutorial-steps {
  margin: 0 0 1.2rem 1.2rem;
  padding: 0;
}

.tutorial-steps li {
  font-size: 0.9rem;
  color: var(--clr-text);
  margin-bottom: 0.6rem;
  line-height: 1.5;
}

.tutorial-tip {
  background: #fff9e6;
  border-left: 3px solid #f1c40f;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--clr-text);
  margin-bottom: 1.2rem;
}

.btn-try-calculator {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  background: var(--clr-accent);
  color: white;
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.2s, transform 0.2s;
}

.btn-try-calculator:hover {
  background: #0073d1;
  transform: translateY(-2px);
}

/* Method Panel */
.method-card {
  background: var(--clr-bg);
}

.method-card > h4 {
  font-size: 1.1rem;
  color: var(--clr-text);
  margin-bottom: 0.6rem;
}

.method-card > p {
  color: var(--clr-muted);
  margin-bottom: 1.2rem;
}

.formula-block {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.formula-block h5 {
  font-size: 0.85rem;
  color: var(--clr-accent);
  margin-bottom: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.formula-block code {
  display: block;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.85rem;
  color: var(--clr-text);
  line-height: 1.8;
}

/* Community Panel */
.community-card {
  background: var(--clr-bg);
  margin-bottom: 1rem;
}

.community-card:last-child {
  margin-bottom: 0;
}

.community-card h4 {
  font-size: 1rem;
  color: var(--clr-text);
  margin-bottom: 0.6rem;
}

.community-card p {
  font-size: 0.9rem;
  color: var(--clr-muted);
  line-height: 1.6;
  margin-bottom: 0.8rem;
}

.community-card p:last-child {
  margin-bottom: 0;
}

.community-cta {
  text-align: center;
  padding: 1.5rem;
}

.community-cta p {
  max-width: 450px;
  margin-left: auto;
  margin-right: auto;
}

/* Reference Tables */
.reference-details {
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.reference-details summary {
  padding: 0.8rem 1rem;
  background: var(--clr-bg);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
}

.reference-details summary:hover {
  background: var(--clr-border);
}

.tables-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  padding: 1rem;
}

.table-card {
  background: var(--clr-bg);
  border-radius: var(--radius-sm);
  padding: 0.8rem;
}

.table-card-wide {
  grid-column: span 3;
}

.table-card h4 {
  font-size: 0.8rem;
  color: var(--clr-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.table-card table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.table-card th,
.table-card td {
  padding: 0.3rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--clr-border);
}

.table-card th {
  font-weight: 600;
  color: var(--clr-muted);
}

.table-card tr:last-child td {
  border-bottom: none;
}

.priority-badge {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.priority-badge.high { background: #e74c3c; color: white; }
.priority-badge.medium { background: #f39c12; color: white; }
.priority-badge.low { background: #3498db; color: white; }

.grade-a { color: var(--grade-a); }
.grade-b { color: var(--grade-b); }
.grade-c { color: var(--grade-c); }
.grade-d { color: var(--grade-d); }
.grade-e { color: var(--grade-e); }
.grade-f { color: var(--grade-f); }
.grade-g { color: var(--grade-g); }

/* Contributors Card */
.contributors-card {
  margin-top: 1.2rem;
}

.contributors-card h4 {
  font-size: 1rem;
  color: var(--clr-text);
  margin-bottom: 0.8rem;
}

.contributors-card > p {
  font-size: 0.9rem;
  color: var(--clr-muted);
  margin-bottom: 0.6rem;
}

.contributors-card > .linkedin-links {
  margin-bottom: 0.8rem;
}

.contributors-details {
  margin-top: 1rem;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.contributors-details summary {
  padding: 0.6rem 1rem;
  background: var(--clr-bg);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--clr-text);
}

.contributors-details summary:hover {
  background: var(--clr-border);
}

.contributors-content {
  padding: 1rem;
}

.contributors-content p {
  font-size: 0.85rem;
  color: var(--clr-muted);
  margin-bottom: 0.6rem;
  line-height: 1.6;
}

.contributors-content p:last-child {
  margin-bottom: 0;
}

/* LinkedIn Links */
.linkedin-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.linkedin-links li {
  margin-bottom: 0.4rem;
}

.linkedin-links a {
  color: var(--clr-accent);
  text-decoration: none;
  font-size: 0.85rem;
}

.linkedin-links a:hover {
  text-decoration: underline;
}

/* Contact Card */
.contact-card {
  margin-top: 1.2rem;
  text-align: center;
}

.contact-card h4 {
  font-size: 1rem;
  color: var(--clr-text);
  margin-bottom: 0.6rem;
}

.contact-card p {
  font-size: 0.9rem;
  color: var(--clr-muted);
  margin-bottom: 1rem;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.btn-linkedin {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  background: #0077b5;
  color: white;
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.2s, transform 0.2s;
}

.btn-linkedin:hover {
  background: #005f8d;
  transform: translateY(-2px);
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.75rem;
  color: var(--clr-muted);
  border-top: 1px solid var(--clr-border);
  margin-top: auto;
}

.footer a {
  color: var(--clr-accent);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    padding: 0.8rem;
    gap: 0.5rem;
  }
  
  .tab-nav {
    width: 100%;
    justify-content: center;
  }
  
  .tab-btn {
    flex: 1;
    text-align: center;
    padding: 0.5rem 0.5rem;
    font-size: 0.8rem;
  }
  
  .hero-section {
    flex-direction: column;
    text-align: center;
    padding: 1.2rem;
  }
  
  .main-content {
    grid-template-columns: 1fr;
  }
  
  .about-grid {
    grid-template-columns: 1fr;
  }
  
  /* About internal tabs responsive */
  .about-tab-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  
  .about-tab-nav::-webkit-scrollbar {
    display: none;
  }
  
  .about-tab {
    padding: 0.5rem 0.8rem;
    font-size: 0.8rem;
    white-space: nowrap;
  }
  
  .tables-grid {
    grid-template-columns: 1fr;
  }
  
  .table-card-wide {
    grid-column: span 1;
  }
  
  .metrics-content {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  
  .metric-row {
    justify-content: center;
    gap: 1rem;
  }
  
  /* Inline inputs responsive */
  .form-row {
    flex-direction: column;
  }
  
  .fieldset-inline {
    width: 100%;
  }
  
  .inline-fields {
    flex-direction: column;
  }
  
  .inline-fields .form-group {
    min-width: 100%;
  }
  
  .btn-calculate {
    width: 100%;
    margin-top: 0.5rem;
  }
  
  /* Scale bars full width on mobile */
  .scale-bar {
    width: 100% !important;
  }
}
