/* ==========================================================================
   TAF Dashboard — Ag Market Briefing Tab Styles
   ========================================================================== */

/* --- Market Overview Cards --- */
.market-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.market-date {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-weight: 500;
}

.market-bottom-line {
  background: var(--color-primary-surface);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-2);
}

.market-bottom-line-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.market-bottom-line p {
  font-size: var(--text-sm);
  color: var(--color-text);
  line-height: 1.65;
}

/* --- Price Dashboard Grid --- */
.market-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}

.market-price-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.market-price-card-name {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.market-price-card-value {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.02em;
}

.market-price-card-change {
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.market-price-card-change.up { color: var(--color-success); }
.market-price-card-change.down { color: var(--color-danger); }
.market-price-card-change.flat { color: var(--color-text-faint); }

.market-price-card-trend {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  line-height: 1.4;
  margin-top: var(--space-1);
}

/* --- Sell Signal Cards --- */
.crop-signals-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}

@media (max-width: 899px) {
  .crop-signals-grid { grid-template-columns: 1fr; }
}

.crop-signal-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.crop-signal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-divider);
}

.crop-signal-name {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.crop-signal-name .crop-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.signal-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: 100px;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.signal-badge--sell-now {
  background: var(--color-success-surface);
  color: var(--color-success);
  border: 1px solid var(--color-success);
}

.signal-badge--sell-rally {
  background: rgba(90, 154, 58, 0.12);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}

.signal-badge--hold {
  background: var(--color-warning-surface);
  color: var(--color-warning);
  border: 1px solid var(--color-warning);
}

.signal-badge--wait {
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.signal-badge--accumulate {
  background: var(--color-danger-surface);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}

.crop-signal-body {
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Score gauge (horizontal bar) */
.score-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.score-bar-labels {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.score-bar-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.score-bar-value {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.score-bar {
  height: 8px;
  background: var(--color-surface-offset);
  border-radius: 100px;
  overflow: hidden;
  position: relative;
}

.score-bar-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.score-bar-fill.score-low { background: var(--color-text-faint); }
.score-bar-fill.score-mid { background: var(--color-warning); }
.score-bar-fill.score-high { background: var(--color-primary); }
.score-bar-fill.score-hot { background: var(--color-success); }

/* Score zone markers */
.score-bar-zones {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--color-text-faint);
  margin-top: var(--space-1);
  padding: 0 2px;
}

/* Meta row */
.crop-meta {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.crop-meta-item {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.crop-meta-item strong {
  color: var(--color-text);
  font-weight: 600;
}

/* Factor table inside card */
.crop-factors {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
}

.crop-factors th {
  text-align: left;
  font-weight: 600;
  color: var(--color-text-muted);
  padding: var(--space-2) var(--space-2);
  border-bottom: 1px solid var(--color-divider);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
}

.crop-factors td {
  padding: var(--space-2);
  border-bottom: 1px solid var(--color-divider);
  color: var(--color-text);
  vertical-align: top;
  line-height: 1.4;
}

.crop-factors td:last-child {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
  font-weight: 600;
}

.crop-factors tbody tr:last-child td {
  border-bottom: none;
}

/* Targets */
.crop-targets {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.crop-targets li {
  font-size: var(--text-xs);
  color: var(--color-text);
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  line-height: 1.4;
}

.crop-targets li::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-primary);
  flex-shrink: 0;
  margin-top: 5px;
}

/* Action / Why text */
.crop-why,
.crop-action-text {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.6;
  padding: var(--space-3);
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
}

.crop-why strong,
.crop-action-text strong {
  color: var(--color-text);
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* --- Price-Taker Cards (wider, full-width) --- */
.price-taker-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

@media (max-width: 899px) {
  .price-taker-grid { grid-template-columns: 1fr; }
}

.price-taker-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.price-taker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-divider);
}

.price-taker-name {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.tone-badge {
  display: inline-flex;
  padding: var(--space-1) var(--space-3);
  border-radius: 100px;
  font-size: var(--text-xs);
  font-weight: 600;
}

.tone-badge--strengthening {
  background: var(--color-success-surface);
  color: var(--color-success);
}

.tone-badge--steady {
  background: var(--color-warning-surface);
  color: var(--color-warning);
}

.tone-badge--weakening, .tone-badge--distressed, .tone-badge--pressured {
  background: var(--color-danger-surface);
  color: var(--color-danger);
}

.tone-badge--neutral, .tone-badge--supportive {
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
}

.price-taker-body {
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Price table */
.price-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.price-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums lining-nums;
}

.price-table th {
  text-align: left;
  font-weight: 600;
  color: var(--color-text-muted);
  padding: var(--space-2);
  border-bottom: 1px solid var(--color-divider);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
  white-space: nowrap;
}

.price-table td {
  padding: var(--space-2);
  border-bottom: 1px solid var(--color-divider);
  color: var(--color-text);
}

.price-table td.num {
  text-align: right;
  font-weight: 500;
}

.price-table .yr-down {
  color: var(--color-danger);
}

.price-table .yr-up {
  color: var(--color-success);
}

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

/* Intel bullets */
.intel-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.intel-list li {
  font-size: var(--text-xs);
  color: var(--color-text);
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  line-height: 1.5;
}

.intel-list li::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-text-muted);
  flex-shrink: 0;
  margin-top: 6px;
}

.price-taker-meaning {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.6;
  padding: var(--space-3);
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
}

.price-taker-meaning strong {
  color: var(--color-text);
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* --- Weather & Geo Cards --- */
.market-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

@media (max-width: 899px) {
  .market-info-grid { grid-template-columns: 1fr; }
}

.market-info-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.market-info-card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-divider);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.market-info-card-header h3 {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
}

.market-info-card-body {
  padding: var(--space-4) var(--space-5);
}

.market-info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
}

.market-info-table th {
  text-align: left;
  font-weight: 600;
  color: var(--color-text-muted);
  padding: var(--space-2);
  border-bottom: 1px solid var(--color-divider);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
}

.market-info-table td {
  padding: var(--space-2);
  border-bottom: 1px solid var(--color-divider);
  color: var(--color-text);
  vertical-align: top;
  line-height: 1.4;
}

.market-info-table tbody tr:last-child td {
  border-bottom: none;
}

.water-supply-note {
  margin-top: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
  padding: var(--space-3);
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
}

.water-supply-note strong {
  color: var(--color-warning);
}

/* Calendar row */
.calendar-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-divider);
}

.calendar-row:last-child {
  border-bottom: none;
}

.calendar-date-badge {
  background: var(--color-primary-surface);
  color: var(--color-primary);
  font-size: var(--text-xs);
  font-weight: 700;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex-shrink: 0;
}

.calendar-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.calendar-event {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text);
}

.calendar-action {
  font-size: 11px;
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* --- Section labels --- */
.market-section-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.market-section-label svg {
  opacity: 0.7;
}

/* Disclaimer */
.market-disclaimer {
  font-size: 11px;
  color: var(--color-text-faint);
  font-style: italic;
  line-height: 1.5;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-divider);
}

/* Loading state */
.market-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) 0;
  gap: var(--space-4);
  color: var(--color-text-muted);
}

.market-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-divider);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Expand/collapse for factor details */
.crop-details-toggle {
  font-size: var(--text-xs);
  color: var(--color-primary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  cursor: pointer;
  padding: var(--space-1) 0;
}

.crop-details-toggle:hover {
  color: var(--color-primary-hover);
}

.crop-details-toggle svg {
  transition: transform 0.2s ease;
}

.crop-details-toggle.open svg {
  transform: rotate(180deg);
}

.crop-details-body {
  display: none;
}

.crop-details-body.open {
  display: block;
}
