/* styles.css */

:root {
  --bg-primary: #faf9f8;
  --bg-secondary: #ffffff;
  --text-primary: #323130;
  --text-secondary: #605e5c;
  --accent-primary: #0078d4;
  --accent-primary-hover: #106ebe;
  --accent-secondary: #107c41;
  --accent-danger: #a80000;
  --border-card: #edebe9;
  --border-focus: #0078d4;
  --shadow-fluent: 0 1.6px 3.6px 0 rgba(0,0,0,0.06), 0 0.3px 0.9px 0 rgba(0,0,0,0.04);
  --shadow-hover: 0 8px 24px 0 rgba(0,0,0,0.08), 0 1.6px 3.6px 0 rgba(0,0,0,0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  color: var(--text-primary);
}

body {
  background-color: var(--bg-primary);
  overflow-y: auto;
  min-height: 100vh;
  transition: background-color 0.3s ease;
}

/* Custom modern scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: #c8c6c4;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #a19f9d;
}

.app-container {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Fluid responsive grid for setup and outcomes panels */
.flex-panel-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
  padding: 1.25rem;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  animation: fadeIn 0.3s cubic-bezier(0.1, 0.9, 0.2, 1);
}

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

/* Large displays will show two side-by-side equal columns */
@media (min-width: 992px) {
  .flex-panel-container {
    grid-template-columns: 1fr 1fr;
  }
}

.main-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-card);
  border-radius: 4px;
  padding: 1.5rem;
  box-shadow: var(--shadow-fluent);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  height: max-content;
  transition: transform 0.2s cubic-bezier(0.1, 0.9, 0.2, 1), box-shadow 0.2s cubic-bezier(0.1, 0.9, 0.2, 1);
}
.main-content:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

/* Glass Card styling mimicking Fluent design sheets */
.glass-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-card);
  border-radius: 4px;
  padding: 1.25rem;
  box-shadow: var(--shadow-fluent);
  transition: transform 0.2s cubic-bezier(0.1, 0.9, 0.2, 1), box-shadow 0.2s cubic-bezier(0.1, 0.9, 0.2, 1);
}
.glass-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

/* Form input styling */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.input-group label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
}

input[type="text"],
input[type="number"],
select {
  background-color: var(--bg-secondary);
  border: 1px solid #8a8886;
  border-radius: 2px;
  padding: 0.4rem 0.5rem;
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.15s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.2);
}

/* Fluent Pivot Buttons (Tabs) */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-card);
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.tab-btn {
  background: none;
  border: none;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.tab-btn:hover {
  color: var(--text-primary);
  background-color: rgba(0, 0, 0, 0.03);
}

.tab-btn.active {
  color: var(--accent-primary);
  font-weight: 600;
  border-bottom-color: var(--accent-primary);
}

/* Navigation tabs styling */
.nav-tab-btn {
  background: none;
  border: none;
  padding: 0.5rem 1.25rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-tab-btn:hover {
  color: var(--text-primary);
  background-color: rgba(0, 0, 0, 0.03);
}

.nav-tab-btn.active {
  color: var(--accent-primary);
  font-weight: 600;
  border-bottom-color: var(--accent-primary);
}

/* Standard KPI grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem;
}

.metric-title {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.metric-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-primary);
  transition: color 0.15s ease;
}

.metric-value.gni {
  color: var(--accent-secondary);
}

.metric-value.gdp {
  color: #8764b8;
}

/* Table styling */
.table-wrapper {
  overflow-x: auto;
  overflow-y: auto;
  max-width: 100%;
  max-height: 380px;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.75rem;
}

th {
  background-color: #f3f2f1;
  font-weight: 600;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border-card);
  position: sticky;
  top: 0;
  z-index: 1;
}

td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border-card);
  transition: background-color 0.1s ease;
}

tr:hover td {
  background-color: #faf9f8;
}

/* Fluent Action Buttons */
.btn-primary {
  background-color: var(--accent-primary);
  color: #ffffff;
  border: 1px solid transparent;
  border-radius: 2px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0.5rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.btn-primary:hover {
  background-color: var(--accent-primary-hover);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--text-primary);
  border: 1px solid #8a8886;
  border-radius: 2px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0.4rem 1rem;
}

.btn-secondary:hover {
  background-color: #f3f2f1;
  border-color: #605e5c;
}

.btn-secondary:active {
  transform: scale(0.98);
}

/* Input Fields inside Time Series and Cohorts Tables */
.historical-input-field {
  width: 100% !important;
  box-sizing: border-box !important;
  background: #ffffff !important;
  border: 1px solid #8a8886 !important;
  padding: 0.3rem 0.45rem !important;
  border-radius: 2px !important;
  color: #323130 !important;
  font-size: 0.75rem !important;
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.historical-input-field:focus {
  border-color: var(--border-focus) !important;
  box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.2) !important;
  outline: none !important;
}

/* Canvas chart bounds */
.chart-container {
  position: relative;
  height: 225px;
  width: 100%;
}
.chart-container canvas {
  cursor: zoom-in;
  transition: transform 0.2s ease;
}

/* Tooltip wrapper */
.tooltip-info {
  display: inline-block;
  margin-left: 5px;
  cursor: help;
  color: var(--accent-primary);
  font-size: 0.72rem;
  font-weight: bold;
  transition: opacity 0.15s ease;
}
.tooltip-info:hover {
  opacity: 1;
}

/* HIGH-FIDELITY RESPONSIVE LAYOUT MEDIA QUERIES */

/* Responsive adjustments for Tablets & smaller screens (< 992px) */
@media (max-width: 991px) {
  .flex-panel-container {
    grid-template-columns: 1fr;
    padding: 0.75rem;
    gap: 1rem;
  }
  .main-content, .glass-card {
    padding: 1rem;
  }
}

/* Responsive adjustments for Mobile Devices (< 600px) */
@media (max-width: 599px) {
  header {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
    padding: 1rem !important;
  }
  header div[style*="text-align: right"] {
    text-align: center !important;
    margin-top: 0.25rem;
  }
  .nav-container {
    padding: 0.5rem !important;
    justify-content: center;
  }
  .nav-tab-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
    flex: 1 1 auto;
    text-align: center;
  }
  .card-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  .metric-value {
    font-size: 1.1rem;
  }
  h1 {
    font-size: 1.25rem !important;
  }
  h2 {
    font-size: 1.05rem !important;
  }
  #section-home {
    padding: 0.75rem !important;
  }
  #section-home > div {
    gap: 1rem !important;
  }
  #section-home section {
    padding: 1rem !important;
  }
}

/* Responsive sizing for the Full-Resolution Chart Modal */
@media (max-width: 768px) {
  #chart-modal > div {
    width: 96vw !important;
    height: 80vh !important;
    padding: 1rem !important;
  }
  #modal-chart-title {
    font-size: 0.95rem !important;
  }
}
