/* =============================================================
   Costing Calculator – component-specific styles
   Everything else uses existing Webflow classes from popsim.css
   ============================================================= */

/* --- Layout: sidebar + main grid --- */
.cc-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  grid-column-gap: 2rem;
  grid-row-gap: 2rem;
  align-items: start;
}

.cc-sidebar {
  position: sticky;
  top: 7rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.cc-main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

/* --- Panel boxes (settings, scenarios, results) --- */
.cc-panel {
  border: 1px solid var(--stroke);
  background-color: var(--white);
  border-radius: 10px;
  padding: 1.5rem;
  width: 100%;
  box-sizing: border-box;
}

.cc-panel-title {
  font-family: "DM Serif Display", serif;
  font-size: 1.125rem;
  font-weight: 400;
  margin: 0 0 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--stroke);
}

/* --- Scenario panels side-by-side --- */
.cc-scenarios {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

/* --- Form field --- */
.cc-field {
  margin-bottom: 0.875rem;
}

.cc-field:last-child {
  margin-bottom: 0;
}

.cc-label {
  display: flex;
  align-items: center;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--unc-black);
  margin-bottom: 0.375rem;
}

.cc-select {
  display: block;
  width: 100%;
  border: 1px solid var(--stroke);
  border-radius: 6px;
  background-color: var(--white);
  color: var(--unc-black);
  padding: 0.625rem 2.25rem 0.625rem 0.75rem;
  font-size: 0.9375rem;
  line-height: 1.4;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 0.75rem;
  transition: border-color 0.15s;
}

.cc-select:focus {
  outline: none;
  border-color: var(--unc-blue);
  box-shadow: 0 0 0 2px rgba(123, 175, 212, 0.25);
}

.cc-select:disabled {
  background-color: #f3f4f6;
  color: #9ca3af;
  cursor: not-allowed;
}

/* --- Toggle checkbox --- */
.cc-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.625rem;
}

.cc-toggle:last-child {
  margin-bottom: 0;
}

.cc-toggle label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--unc-black);
}

.cc-toggle input[type="checkbox"] {
  width: 1.125rem;
  height: 1.125rem;
  accent-color: var(--unc-blue);
  cursor: pointer;
}

/* --- Tooltip --- */
.cc-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 0.375rem;
}

.cc-tip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--unc-blue);
  border: 1.5px solid var(--unc-blue);
  border-radius: 50%;
  cursor: help;
  line-height: 1;
}

.cc-tip-text {
  position: absolute;
  left: 1.75rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  background: var(--unc-black);
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0;
  text-transform: none;
  border-radius: 6px;
  padding: 0.5rem 0.625rem;
  width: 14rem;
  white-space: normal;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.cc-tip-portal {
  position: fixed;
  z-index: 9999;
}

.cc-tip-arrow {
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: var(--unc-black);
}

/* --- Summary cards --- */
.cc-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.cc-summary-card {
  border: 1px solid var(--stroke);
  background: var(--white);
  border-radius: 10px;
  padding: 1.25rem;
}

.cc-summary-card-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #6b7280;
  margin: 0 0 0.375rem;
}

.cc-summary-card-value {
  font-family: "DM Serif Display", serif;
  font-size: 1.75rem;
  font-weight: 400;
  line-height: 1;
  margin: 0 0 0.25rem;
}

.cc-summary-card-sub {
  font-size: 0.6875rem;
  color: #9ca3af;
  margin: 0;
}

/* --- Color utilities --- */
.cc-green { color: #15803d; }
.cc-red { color: #b91c1c; }

/* --- Interpretation sentence --- */
.cc-interpretation {
  border: 1px solid var(--stroke);
  background: var(--white);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  font-size: 0.9375rem;
  line-height: 1.65;
}

.cc-interpretation strong {
  font-weight: 600;
}

.cc-interpretation .cc-muted {
  color: #6b7280;
}

/* --- Results table --- */
.cc-table-wrapper {
  border: 1px solid var(--stroke);
  border-radius: 10px;
  overflow: hidden;
  background: var(--white);
}

.cc-table-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--stroke);
  background: rgba(123, 175, 212, 0.08);
}

.cc-table-header h3 {
  font-family: "DM Serif Display", serif;
  font-size: 1.0625rem;
  font-weight: 400;
  margin: 0;
}

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

.cc-table thead {
  background: rgba(123, 175, 212, 0.05);
}

.cc-table th {
  padding: 0.75rem 1.25rem;
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cc-table th.cc-align-right {
  text-align: right;
}

.cc-table td {
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  border-top: 1px solid var(--stroke);
  color: var(--unc-black);
}

.cc-table td.cc-align-right {
  text-align: right;
}

.cc-table td.cc-group-label {
  font-weight: 600;
}

.cc-table tbody tr:hover {
  background: rgba(123, 175, 212, 0.04);
}

.cc-table td.cc-green { color: #15803d; font-weight: 500; }
.cc-table td.cc-red { color: #b91c1c; font-weight: 500; }

/* --- Chart container --- */
.cc-chart-wrapper {
  border: 1px solid var(--stroke);
  background: var(--white);
  border-radius: 10px;
  padding: 1.5rem;
}

.cc-chart-inner {
  height: 22rem;
}

/* --- Warning note --- */
.cc-warning {
  border: 1px solid #fbbf24;
  background: #fffbeb;
  border-radius: 8px;
  padding: 0.875rem 1rem;
  font-size: 0.8125rem;
  line-height: 1.5;
}

/* --- Locked help text --- */
.cc-help-text {
  font-size: 0.75rem;
  font-style: italic;
  color: #6b7280;
  margin-top: 0.25rem;
}

/* --- Intro row (description + action links) --- */
.cc-intro-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 2rem;
}

.cc-intro-row .max-width-large {
  margin: 0;
}

.cc-header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
  white-space: nowrap;
}

/* --- Action links (export, share, about) --- */
.cc-action-link {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--unc-blue);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  text-decoration: none;
  transition: color 0.15s;
}

.cc-action-link:hover {
  color: var(--unc-navy);
  text-decoration: underline;
}

.cc-action-link:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Export dropdown --- */
.cc-export-wrapper {
  position: relative;
}

.cc-export-menu {
  position: absolute;
  right: 0;
  margin-top: 0.375rem;
  width: 10rem;
  background: var(--white);
  border: 1px solid var(--stroke);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 20;
  overflow: hidden;
}

.cc-export-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.625rem 1rem;
  font-size: 0.8125rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--unc-black);
  transition: background 0.1s;
}

.cc-export-menu button:hover {
  background: rgba(123, 175, 212, 0.1);
}

/* --- Modal --- */
.cc-modal-backdrop {
  position: fixed;
  top: var(--nav-height, 96px);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 1.5rem;
  box-sizing: border-box;
}

.cc-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.cc-modal {
  position: relative;
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  max-width: min(44rem, calc(100% - 3rem));
  width: 100%;
  min-width: 0;
  max-height: 80vh;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
}

.cc-modal-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--white);
  white-space: normal;
  border-bottom: 1px solid var(--stroke);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 12px 12px 0 0;
}

.cc-modal-header h2 {
  font-family: "DM Serif Display", serif;
  font-size: 1.25rem;
  font-weight: 400;
  margin: 0;
}

.cc-modal-close {
  color: #9ca3af;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0.25rem;
  transition: color 0.15s;
}

.cc-modal-close:hover {
  color: var(--unc-black);
}

.cc-modal-body {
  padding: 1.5rem;
  white-space: normal;
  overflow-wrap: break-word;
  word-wrap: break-word;
  box-sizing: border-box;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

.cc-modal-body h3 {
  font-family: "DM Serif Display", serif;
  font-size: 1.0625rem;
  font-weight: 400;
  margin: 0 0 0.75rem;
}

.cc-modal-body p {
  font-size: 0.875rem;
  color: #4b5563;
  line-height: 1.7;
  margin: 0 0 0.75rem;
}

.cc-modal-body section + section {
  border-top: 1px solid var(--stroke);
  padding-top: 1.25rem;
  margin-top: 1.5rem;
}

.cc-modal-body ol {
  font-size: 0.875rem;
  color: #4b5563;
  line-height: 1.7;
  list-style: decimal inside;
  padding: 0;
  margin: 0;
}

.cc-modal-body ol li {
  margin-bottom: 0.75rem;
}

.cc-modal-body a {
  color: var(--unc-hyperlink-blue);
}

.cc-modal-body a:hover {
  text-decoration: underline;
}

.cc-modal-body sup {
  color: var(--unc-hyperlink-blue);
}

/* --- Responsive --- */

/* Large tablets / narrow desktops: stack scenarios, keep sidebar */
@media (max-width: 1200px) {
  .cc-scenarios {
    grid-template-columns: 1fr;
  }

  .cc-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Tablets: collapse sidebar to top */
@media (max-width: 991px) {
  .cc-layout {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    align-items: stretch;
  }

  .cc-sidebar {
    position: static;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
  }

  .cc-main {
    width: 100%;
  }

  .cc-scenarios {
    grid-template-columns: 1fr 1fr;
  }

  .cc-summary-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .cc-intro-row {
    flex-direction: column;
    gap: 0.75rem;
  }
}

/* Small tablets */
@media (max-width: 767px) {
  .cc-sidebar {
    grid-template-columns: 1fr;
  }

  .cc-scenarios {
    grid-template-columns: 1fr;
  }

  .cc-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .cc-summary-card-value {
    font-size: 1.375rem;
  }

  .cc-chart-inner {
    height: 18rem;
  }

  .cc-table th,
  .cc-table td {
    padding: 0.625rem 0.75rem;
    font-size: 0.75rem;
  }
}

/* Mobile */
@media (max-width: 479px) {
  .cc-summary-grid {
    grid-template-columns: 1fr;
  }

  .cc-header-actions {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .cc-interpretation {
    padding: 1rem;
    font-size: 0.8125rem;
  }
}
