/* dashboard.css */

/* ── Wrapper ─────────────────────────────────────────────── */
.dashboard-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #111827;
  color: #f3f4f6;
  overflow: hidden;
}

/* ── Control bar ─────────────────────────────────────────── */
.dashboard-control-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #e8eaed;
  padding: 8px 16px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.dashboard-control-bar .control-label {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
}

.dashboard-control-bar select {
  height: 30px;
  padding: 2px 6px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 3px;
}

.dashboard-control-bar .search-btn {
  background-color: #4a7c59 !important;
  border-color: #4a7c59 !important;
  color: white !important;
  height: 30px;
  padding: 0 14px;
  font-size: 13px;
  border-radius: 3px;
}

/* ── Main area ───────────────────────────────────────────── */
.dashboard-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 16px;
  overflow-y: auto;
  min-height: 0;
}

/* ── Rows ────────────────────────────────────────────────── */
.dashboard-row {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

.row-1 {
  height: 130px;
}

.row-2 {
  flex: 1;
  min-height: 0;
}

/* ── KPI cards ───────────────────────────────────────────── */
.kpi-card {
  flex: 0 0 220px;
  background: #1f2937;
  border-radius: 10px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.kpi-title {
  font-size: 13px;
  color: #9ca3af;
  margin: 0;
}

.kpi-title p { margin: 0; }

.kpi-badge {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 1px;
}

.kpi-gray   { background: #888; color: white; }
.kpi-yellow { background: #FFAA00; color: #1a1a1a; }
.kpi-orange { background: #E60000; color: white; }
.kpi-red    { background: #730000; color: white; }
.kpi-green  { background: #BFDFFF; color: #1a1a1a; }
.kpi-teal   { background: #6B99FF; color: white; }
.kpi-blue   { background: #000080; color: white; }

.kpi-card .kpi-value {
  text-align: center;
  width: 100%;
}

.kpi-subtitle p {
  font-size: 12px;
  color: #9ca3af;
  margin: 0;
}

/* ── Bubble / badge card ─────────────────────────────────── */
.bubble-card {
  flex: 1;
  background: #1f2937;
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}

.bubble-label {
  font-size: 13px;
  color: #9ca3af;
}

.bubble-area {
  display: flex;
  align-items: center;
}

.badge-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.drought-badge {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.b-blue   { background: #2563eb; }
.b-gray   { background: #4b5563; }
.b-yellow { background: #d97706; }
.b-orange { background: #ea580c; }
.b-red    { background: #dc2626; }

.bubble-meta {
  position: absolute;
  top: 14px;
  right: 18px;
  text-align: right;
}

.bubble-meta p {
  font-size: 12px;
  color: #9ca3af;
  margin: 0;
}

/* ── Chart cards ─────────────────────────────────────────── */
.chart-card {
  flex: 1;
  background: #1f2937;
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.chart-title {
  font-size: 13px;
  font-weight: 600;
  color: #9ca3af;
  margin-bottom: 8px;
}

.chart-card .shiny-plot-output {
  flex: 1;
}

.chart-card > .shiny-html-output {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
/* ── Commune list ─────────────────────────────── */
.commune-list-wrapper {
  height: 240px;
  overflow-y: auto;
  padding: 4px 8px;
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}

.commune-list-wrapper::-webkit-scrollbar {
  width: 5px;
}
.commune-list-wrapper::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

.commune-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #aaa;
  font-style: italic;
  font-size: 13px;
  gap: 6px;
  padding-top: 40px;
}

.commune-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s;
}

.commune-row:hover {
  background: #f7f7f7;
  border-radius: 4px;
}

.commune-rank {
  min-width: 28px;
  font-size: 11px;
  font-weight: 700;
  color: #aaa;
  text-align: right;
}

.commune-info {
  flex: 1;
  min-width: 0;
}

.commune-name {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
  background-color: #e8eaed;
}

.commune-bar-track {
  height: 5px;
  background: #ececec;
  border-radius: 3px;
  overflow: hidden;
}

.commune-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.commune-pct {
  min-width: 44px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  white-space: nowrap;
}


/* ── CSS Donut chart ─────────────────────────────────────── */
.donut-wrapper {
  display: flex;
  flex-direction: column;
  /*align-items: center;*/
  gap: 16px;
  padding: 8px 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.donut-container {
  position: relative;
  width: 180px;
  height: 180px;
  flex-shrink: 0;
  align-self: center;
}

.donut-ring {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.donut-hole {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100px;
  height: 100px;
  background: #1f2937;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  padding: 8px;
}

.donut-center-province {
  font-size: 11px;
  font-weight: 700;
  color: #f3f4f6;
  line-height: 1.2;
  word-break: break-word;
}

.donut-center-meta {
  font-size: 9px;
  color: #9ca3af;
  line-height: 1.2;
}

/* ── Legend ──────────────────────────────────────────────── */
.donut-legend {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  /*justify-content: center;*/
  gap: 6px 10px;
  width: 100%;
  padding: 0 8px;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.donut-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.donut-legend-text {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.donut-legend-label {
  font-size: 11px;
  font-weight: 600;
  color: #d1d5db;
  white-space: nowrap;
}

.donut-legend-pct {
  font-size: 11px;
  color: #9ca3af;
  white-space: nowrap;
}

.donut-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: #9ca3af;
  font-style: italic;
  font-size: 13px;
}


/* ── Evolution stacked bar chart ─────────────────────────── */
.evolution-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.evolution-card > .shiny-html-output {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.evol-wrapper {
  display: flex;
  flex-direction: row;
  flex: 1;
  gap: 6px;
  min-height: 0;
  padding: 4px 0 0 0;
  height: 100%; 
}

.evol-yaxis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-bottom: 22px;
  min-width: 30px;
}

.evol-ytick {
  font-size: 9px;
  color: #6b7280;
  text-align: right;
  line-height: 1;
}

.evol-bars {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 10px;
  flex: 1;
  min-height: 0;
  height: 100%; 
}

.evol-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  height: 100%;
  gap: 4px;
  min-height: 0;
}

.evol-bar-stack {
  flex: 1;
  width: 50%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end; 
  border-radius: 4px 4px 0 0;
  overflow: hidden;
  background: #374151;
  min-height: 0; 
}

.evol-bar-label {
  font-size: 10px;
  color: #9ca3af;
  text-align: center;
  white-space: nowrap;
  padding-bottom: 2px;
  flex-shrink: 0;  
}

/* gridlines */
.evol-bars {
  background-image: repeating-linear-gradient(
    to top,
    transparent,
    transparent calc(25% - 1px),
    #374151 calc(25% - 1px),
    #374151 25%
  );
}