/* ============================================================
   Carbon-Aware Code Auditor — page-specific styles
   Reuses design tokens from style.css
   ============================================================ */

/* ---- Hero ---- */
.ca-hero {
  padding: 64px 0 48px;
  border-bottom: 1px solid var(--border);
}

.ca-hero__badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-dark);
  background: var(--accent-light);
  padding: 6px 14px;
  border-radius: 20px;
  margin-bottom: 24px;
}

.ca-hero__badge svg { color: var(--accent); }

.ca-hero__title {
  font-size: clamp(28px, 3.5vw, 44px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.ca-hero__sub {
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-mid);
  max-width: 56ch;
  margin-bottom: 32px;
}

.ca-hero__actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.ca-hero__note {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-light);
}

/* ---- App section ---- */
.ca-app { padding: 0 0 96px; }

/* ---- Tabs ---- */
.ca-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ca-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 16px 24px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-mid);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.ca-tab:hover { color: var(--text); }
.ca-tab--active { color: var(--accent); border-bottom-color: var(--accent); }
.ca-tab svg { flex-shrink: 0; }

/* ---- Panels ---- */
.ca-panel { display: none; }
.ca-panel--active { display: block; }

.ca-panel__header { margin-bottom: 32px; }

.ca-panel__title {
  font-size: clamp(22px, 2.5vw, 30px);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.ca-panel__desc {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-mid);
  max-width: 60ch;
}

/* ---- Divider ---- */
.ca-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 28px 0;
}

.ca-divider::before,
.ca-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.ca-divider span {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---- Field styles ---- */
.ca-field__label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.ca-field__input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg-alt);
  transition: border-color 0.15s;
}

.ca-field__input:focus { outline: none; border-color: var(--accent); }
.ca-field__input::placeholder { color: var(--text-light); }

/* ============================================================
   ENERGY REPORT PANEL
   ============================================================ */

/* URL form */
.ca-url-form__row {
  display: flex;
  gap: 12px;
}

.ca-url-form__input {
  flex: 1;
  height: 48px;
  padding: 0 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 15px;
  color: var(--text);
  background: var(--bg-alt);
  transition: border-color 0.15s;
}

.ca-url-form__input:focus { outline: none; border-color: var(--accent); }
.ca-url-form__input::placeholder { color: var(--text-light); }

.ca-url-form__hint {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 8px;
}

/* Manual form */
.ca-manual-form__grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

/* ---- Report results ---- */
.ca-report {
  margin-top: 40px;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-alt);
}

.ca-report__heading {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}

.ca-report__url {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 24px;
  word-break: break-all;
}

/* Grade */
.ca-grade-row {
  display: flex;
  gap: 24px;
  align-items: center;
  margin-bottom: 28px;
}

.ca-grade {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ca-grade__letter {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
}

.ca-grade__label {
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.8);
  margin-top: 4px;
}

.ca-grade--a { background: #059669; }
.ca-grade--b { background: #10b981; }
.ca-grade--c { background: #f59e0b; }
.ca-grade--d { background: #f97316; }
.ca-grade--e { background: #ef4444; }
.ca-grade--f { background: #dc2626; }

.ca-grade-summary p {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-mid);
}

/* Stat cards */
.ca-report__cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.ca-stat {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  text-align: center;
}

.ca-stat__value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 4px;
}

.ca-stat__label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Breakdown bars */
.ca-breakdown {
  margin-bottom: 24px;
}

.ca-breakdown__title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
}

.ca-breakdown__bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ca-bbar {
  display: grid;
  grid-template-columns: 100px 1fr 60px;
  align-items: center;
  gap: 12px;
}

.ca-bbar__label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mid);
}

.ca-bbar__track {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.ca-bbar__fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.ca-bbar__fill--images { background: #3b82f6; }
.ca-bbar__fill--js { background: #f59e0b; }
.ca-bbar__fill--css { background: #8b5cf6; }
.ca-bbar__fill--fonts { background: #ec4899; }
.ca-bbar__fill--other { background: #6b7280; }

.ca-bbar__size {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-light);
  text-align: right;
}

/* Comparison box */
.ca-comparison {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e40af;
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 24px;
}

.ca-comparison svg { flex-shrink: 0; margin-top: 2px; }

.ca-report__actions { display: flex; gap: 12px; }

/* ============================================================
   OPTIMISATION PANEL
   ============================================================ */

.ca-suggestions {
  margin-bottom: 32px;
}

.ca-suggestions__heading {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--accent-dark);
}

.ca-suggestions__list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ca-suggestion {
  display: flex;
  gap: 14px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-alt);
}

.ca-suggestion__icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ca-suggestion__icon--high { background: #fee2e2; color: #dc2626; }
.ca-suggestion__icon--medium { background: #fef3c7; color: #d97706; }
.ca-suggestion__icon--low { background: var(--accent-light); color: var(--accent-dark); }

.ca-suggestion__title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.ca-suggestion__text {
  font-size: 13px;
  color: var(--text-mid);
  line-height: 1.5;
}

.ca-suggestion__saving {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  margin-top: 6px;
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--accent-light);
  color: var(--accent-dark);
}

/* Practices */
.ca-practices__heading {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.ca-practices {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.ca-practice {
  display: flex;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.ca-practice:last-child { border-bottom: none; }

.ca-practice__icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #f5f5f4;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-mid);
}

.ca-practice__body h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.ca-practice__body p {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-mid);
  margin-bottom: 8px;
}

.ca-practice__body code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--accent-light);
  color: var(--accent-dark);
  padding: 2px 6px;
  border-radius: 4px;
}

.ca-practice__body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ca-practice__impact {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 4px;
}

.ca-practice__impact--high { background: #fee2e2; color: #991b1b; }
.ca-practice__impact--medium { background: #fef3c7; color: #92400e; }
.ca-practice__impact--low { background: #f0fdf4; color: #166534; }

/* ============================================================
   SCHEDULING PANEL
   ============================================================ */

/* Current grid */
.ca-grid-now {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  background: var(--bg-alt);
  margin-bottom: 28px;
}

.ca-grid-now__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.ca-grid-now__header h3 {
  font-size: 15px;
  font-weight: 600;
}

.ca-grid-now__live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
}

.ca-grid-now__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.ca-grid-now__body {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 8px;
}

.ca-grid-now__intensity {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.ca-grid-now__value {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.ca-grid-now__unit {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-light);
}

.ca-grid-now__level {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 6px;
}

.ca-grid-now__level--vlow { background: #d1fae5; color: #065f46; }
.ca-grid-now__level--low { background: #d1fae5; color: #065f46; }
.ca-grid-now__level--mod { background: #fef3c7; color: #92400e; }
.ca-grid-now__level--high { background: #fed7aa; color: #9a3412; }
.ca-grid-now__level--vhigh { background: #fee2e2; color: #991b1b; }

.ca-grid-now__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ca-grid-now__updated {
  font-size: 12px;
  color: var(--text-light);
}

.ca-grid-now__refresh {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 6px;
  cursor: pointer;
  color: var(--text-light);
  transition: color 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.ca-grid-now__refresh:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.ca-grid-now__refresh.spinning svg {
  animation: spin 0.8s linear;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Forecast */
.ca-forecast {
  margin-bottom: 28px;
}

.ca-forecast__title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.ca-forecast__desc {
  font-size: 13px;
  color: var(--text-mid);
  margin-bottom: 16px;
}

.ca-forecast__chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 120px;
  padding: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.ca-fbar {
  flex: 1;
  border-radius: 3px 3px 0 0;
  min-width: 4px;
  transition: height 0.4s ease;
  cursor: default;
  position: relative;
}

.ca-fbar:hover { opacity: 0.8; }

.ca-fbar--vlow { background: #059669; }
.ca-fbar--low { background: #34d399; }
.ca-fbar--mod { background: #fbbf24; }
.ca-fbar--high { background: #f97316; }
.ca-fbar--vhigh { background: #ef4444; }

.ca-fbar[title] { cursor: help; }

.ca-forecast__legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-mid);
}

.ca-fdot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
}

.ca-fdot--vlow { background: #059669; }
.ca-fdot--low { background: #34d399; }
.ca-fdot--mod { background: #fbbf24; }
.ca-fdot--high { background: #f97316; }
.ca-fdot--vhigh { background: #ef4444; }

/* Recommendation */
.ca-schedule-rec {
  display: flex;
  gap: 14px;
  padding: 20px;
  border-radius: 10px;
  background: var(--accent-light);
  margin-bottom: 28px;
}

.ca-schedule-rec svg {
  flex-shrink: 0;
  color: var(--accent-dark);
  margin-top: 2px;
}

.ca-schedule-rec h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-dark);
  margin-bottom: 4px;
}

.ca-schedule-rec p {
  font-size: 13px;
  line-height: 1.55;
  color: var(--accent-dark);
}

/* Tips */
.ca-schedule-tips {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.ca-schedule-tips h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

.ca-schedule-tips ul {
  list-style: disc;
  padding-left: 20px;
}

.ca-schedule-tips li {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-mid);
  margin-bottom: 6px;
}

.ca-schedule-tips li:last-child { margin-bottom: 0; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 840px) {
  .ca-report__cards { grid-template-columns: 1fr 1fr; }
  .ca-manual-form__grid { grid-template-columns: 1fr 1fr; }
  .ca-grade-row { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 540px) {
  .ca-hero { padding: 40px 0 32px; }
  .ca-hero__actions { flex-direction: column; align-items: flex-start; gap: 12px; }
  .ca-tab { padding: 12px 16px; font-size: 13px; }
  .ca-tab svg { display: none; }
  .ca-report__cards { grid-template-columns: 1fr; }
  .ca-manual-form__grid { grid-template-columns: 1fr; }
  .ca-url-form__row { flex-direction: column; }
  .ca-report { padding: 20px; }
  .ca-bbar { grid-template-columns: 80px 1fr 50px; }
  .ca-forecast__legend { gap: 10px; }
}
