/* ═══════════════════════════════════════════════════
   telcostats.css
   Telecom Statistics page — extends main.css
   ═══════════════════════════════════════════════════ */

/* ── Stats Hero ── */
.stats-hero {
  position: relative;
  background: var(--navy);
  overflow: hidden;
  padding: 3.5rem 0 3rem;
}

.stats-hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 70% 50%, rgba(0,115,173,.35) 0%, transparent 70%),
    linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
  pointer-events: none;
}

.stats-hero-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 32px 32px;
}

.stats-hero .container { position: relative; z-index: 1; }

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .78rem;
  color: rgba(255,255,255,.5);
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.breadcrumb a {
  color: rgba(255,255,255,.6);
  transition: color .2s;
}

.breadcrumb a:hover { color: var(--yellow); }

.breadcrumb svg { color: rgba(255,255,255,.3); flex-shrink: 0; }

.breadcrumb [aria-current="page"] { color: rgba(255,255,255,.85); }

/* Hero Content */
.stats-hero-content { max-width: 720px; }

.stats-hero .section-label {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--yellow);
  margin-bottom: .75rem;
}

.stats-hero h1 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 400;
  color: var(--white);
  line-height: 1.15;
  margin-bottom: .85rem;
}

.stats-hero p {
  font-size: 1.05rem;
  color: rgba(255,255,255,.72);
  line-height: 1.7;
  margin-bottom: 1.5rem;
  max-width: 600px;
}

.stats-hero-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.stats-period-badge,
.stats-update-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .78rem;
  font-weight: 500;
  color: rgba(255,255,255,.65);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  padding: .35rem .85rem;
  border-radius: 99px;
}

.stats-download-report {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .8rem;
  font-weight: 700;
  color: var(--white);
  background: var(--azure-blue);
  padding: .4rem 1rem;
  border-radius: var(--radius);
  transition: background .2s, transform .15s;
  white-space: nowrap;
}

.stats-download-report:hover {
  background: var(--navy-light);
  transform: translateY(-1px);
}

/* ── KPI Strip ── */
.kpi-strip {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 2;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
}

.kpi-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.4rem 1.6rem;
  border-right: 1px solid var(--border);
  transition: background .2s;
  animation: kpiFadeIn .5s ease both;
}

.kpi-card:last-child { border-right: none; }

@keyframes kpiFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.kpi-card:nth-child(1) { animation-delay: .05s; }
.kpi-card:nth-child(2) { animation-delay: .1s; }
.kpi-card:nth-child(3) { animation-delay: .15s; }
.kpi-card:nth-child(4) { animation-delay: .2s; }
.kpi-card:nth-child(5) { animation-delay: .25s; }

.kpi-card:hover { background: var(--off-white); }

.kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-icon--blue   { background: #EFF6FF; color: #1D4ED8; }
.kpi-icon--green  { background: #ECFDF5; color: #065F46; }
.kpi-icon--yellow { background: #FFFBEB; color: #92400E; }
.kpi-icon--red    { background: #FEF2F2; color: #991B1B; }
.kpi-icon--teal   { background: #ECFEFF; color: #0E7490; }

.kpi-body {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  min-width: 0;
}

.kpi-value {
  font-family: 'DM Serif Display', serif;
  font-size: 1.55rem;
  font-weight: 400;
  color: var(--navy);
  line-height: 1;
  white-space: nowrap;
}

.kpi-label {
  font-size: .74rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  font-size: .72rem;
  font-weight: 700;
}

.kpi-trend--up   { color: var(--green); }
.kpi-trend--down { color: var(--red); }

/* ── Stats Controls ── */
.stats-controls {
  background: var(--off-white);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.stats-controls-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.stats-filter-group {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-shrink: 0;
}

.stats-filter-label {
  font-size: .76rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}

.stats-period-tabs,
.stats-sector-tabs {
  display: flex;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.stats-period-tab,
.stats-sector-tab {
  background: none;
  border: none;
  border-right: 1px solid var(--border);
  font-family: inherit;
  font-size: .78rem;
  font-weight: 500;
  color: var(--gray-600);
  padding: .35rem .8rem;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.stats-period-tab:last-child,
.stats-sector-tab:last-child { border-right: none; }

.stats-period-tab:hover:not(.active),
.stats-sector-tab:hover:not(.active) {
  background: var(--gray-100);
  color: var(--navy);
}

.stats-period-tab.active,
.stats-sector-tab.active {
  background: var(--navy);
  color: var(--white);
  font-weight: 700;
}

.stats-search-wrap {
  flex: 1;
  max-width: 260px;
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .35rem .75rem;
  color: var(--gray-400);
  transition: border-color .2s;
}

.stats-search-wrap:focus-within {
  border-color: var(--azure-blue);
  color: var(--navy);
}

#statsSearch {
  border: none;
  outline: none;
  font-family: inherit;
  font-size: .82rem;
  color: var(--navy);
  background: transparent;
  width: 100%;
}

#statsSearch::placeholder { color: var(--gray-400); }

.stats-export-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: inherit;
  font-size: .78rem;
  font-weight: 700;
  color: var(--navy);
  background: var(--white);
  border: 1px solid var(--border);
  padding: .4rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  margin-left: auto;
}

.stats-export-btn:hover {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}

/* ── Stats Body ── */
.stats-body {
  background: var(--off-white);
  padding: 2.5rem 0 3rem;
}

/* No Results */
.stats-no-results {
  text-align: center;
  padding: 4rem 1rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.stats-no-results[hidden] { display: none; }

.stats-no-results svg {
  margin: 0 auto 1rem;
  color: var(--gray-200);
}

.stats-no-results h3 {
  font-size: 1.2rem;
  color: var(--navy);
  margin-bottom: .4rem;
}

.stats-no-results p {
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.stats-reset-btn {
  background: var(--navy);
  color: var(--white);
  border: none;
  padding: .5rem 1.5rem;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}

.stats-reset-btn:hover { background: var(--azure-blue); }

/* ── Charts Grid ── */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.chart-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, transform .2s;
  animation: chartFadeIn .4s ease both;
}

@keyframes chartFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chart-card:nth-child(1) { animation-delay: .05s; }
.chart-card:nth-child(2) { animation-delay: .1s; }
.chart-card:nth-child(3) { animation-delay: .15s; }
.chart-card:nth-child(4) { animation-delay: .2s; }
.chart-card:nth-child(5) { animation-delay: .25s; }
.chart-card:nth-child(6) { animation-delay: .3s; }

.chart-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.chart-card[hidden] { display: none; }

.chart-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.chart-card-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--azure-blue);
  margin-bottom: .25rem;
}

.chart-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 .15rem;
  line-height: 1.3;
}

.chart-card-period {
  font-size: .76rem;
  color: var(--text-muted);
  margin: 0;
}

.chart-card-actions {
  display: flex;
  gap: .35rem;
  flex-shrink: 0;
}

.chart-type-btn,
.chart-download-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--gray-400);
  cursor: pointer;
  transition: all .15s;
}

.chart-type-btn:hover,
.chart-download-btn:hover {
  background: var(--gray-100);
  color: var(--navy);
  border-color: var(--gray-400);
}

.chart-type-btn.active {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}

.chart-wrap {
  position: relative;
  height: 260px;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ── Market Insight Panel ── */
.market-insight-panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

.market-insight-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.market-insight-header .section-label {
  display: block;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--azure-blue);
  margin-bottom: .2rem;
}

.market-insight-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--navy);
  margin: 0;
}

.market-insight-period {
  font-size: .78rem;
  color: var(--text-muted);
  padding: .3rem .75rem;
  background: var(--off-white);
  border-radius: 99px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.market-insight-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: center;
}

.market-insight-chart-wrap {
  position: relative;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.market-insight-chart-wrap canvas {
  max-width: 100%;
  max-height: 100%;
}

.market-insight-legend {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.market-legend-item {
  display: flex;
  align-items: center;
  gap: .85rem;
}

.market-legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

.market-legend-item > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex: 1;
  gap: .5rem;
}

.market-legend-item strong {
  font-size: .9rem;
  color: var(--navy);
  font-weight: 600;
}

.market-legend-pct {
  font-size: .82rem;
  font-weight: 700;
  color: var(--azure-blue);
}

/* ── Data Table ── */
.stats-table-section {
  background: var(--white);
  padding: 3rem 0;
  border-top: 1px solid var(--border);
}

.stats-table-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.stats-table-header .section-label {
  display: block;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--azure-blue);
  margin-bottom: .25rem;
}

.stats-table-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 .25rem;
  font-family: 'DM Serif Display', serif;
  font-weight: 400;
}

.stats-table-header p {
  font-size: .88rem;
  color: var(--text-muted);
  margin: 0;
}

.stats-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .84rem;
}

.stats-table thead {
  background: var(--navy);
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 1;
}

.stats-table th {
  padding: .85rem 1.1rem;
  text-align: left;
  font-weight: 600;
  font-size: .78rem;
  letter-spacing: .04em;
  white-space: nowrap;
}

.stats-table th:first-child { border-radius: var(--radius-lg) 0 0 0; }
.stats-table th:last-child  { border-radius: 0 var(--radius-lg) 0 0; }

.stats-table td {
  padding: .75rem 1.1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}

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

.stats-table tbody tr:nth-child(odd) { background: var(--off-white); }

.stats-table tbody tr:hover { background: rgba(0,115,173,.05); }

.stats-table td:first-child {
  font-weight: 600;
  color: var(--navy);
}

.td-highlight {
  color: var(--azure-blue);
  font-weight: 600;
}

/* ── Download Resources ── */
.stats-resources {
  background: var(--off-white);
  padding: 3rem 0;
  border-top: 1px solid var(--border);
}

.stats-resources .section-header {
  margin-bottom: 1.75rem;
}

.stats-resources .section-label {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--azure-blue);
  margin-bottom: .35rem;
}

.stats-resources h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.6rem;
  font-weight: 400;
  color: var(--navy);
  margin: 0 0 .4rem;
}

.stats-resources p {
  font-size: .92rem;
  color: var(--text-muted);
  margin: 0;
}

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

.resource-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  text-decoration: none;
  color: var(--navy);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, border-color .2s, transform .15s;
}

.resource-card:hover {
  box-shadow: var(--shadow-md);
  border-color: rgba(0,115,173,.3);
  transform: translateY(-2px);
}

.resource-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .06em;
}

.resource-card-icon--pdf { background: #FEE2E2; color: #B91C1C; }
.resource-card-icon--xls { background: #D1FAE5; color: #065F46; }

.resource-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}

.resource-card-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resource-card-meta {
  font-size: .75rem;
  color: var(--text-muted);
}

.resource-card-arrow {
  flex-shrink: 0;
  color: var(--gray-400);
  transition: color .2s, transform .2s;
}

.resource-card:hover .resource-card-arrow {
  color: var(--azure-blue);
  transform: translateY(2px);
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .kpi-card:nth-child(4) { border-right: 1px solid var(--border); }
  .kpi-card:nth-child(3) { border-right: none; }
}

@media (max-width: 900px) {
  .charts-grid { grid-template-columns: 1fr; }
  .market-insight-grid { grid-template-columns: 1fr; }
  .market-insight-chart-wrap { height: 200px; }
}

@media (max-width: 768px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-card:nth-child(odd) { border-right: 1px solid var(--border); }
  .kpi-card:nth-child(even) { border-right: none; }
  .kpi-card:nth-child(5) { grid-column: span 2; border-right: none; }

  .stats-controls-inner { gap: .75rem; }
  .stats-filter-group { flex-wrap: wrap; }
  .stats-search-wrap { max-width: 100%; flex: none; width: 100%; }
  .stats-export-btn { margin-left: 0; }

  .resources-grid { grid-template-columns: 1fr; }

  .stats-table-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-card:nth-child(5) { grid-column: span 2; }
  .stats-hero-meta { flex-direction: column; align-items: flex-start; }
  .stats-period-tabs, .stats-sector-tabs { flex-wrap: wrap; }
}
