/* ========================================
   New Structural Economics Visualization Styles
   Scoped with .nse- prefix to prevent pollution
   ======================================== */

/* CSS Variables for theming */
.nse-container {
  --nse-primary: #2c3e50;
  --nse-secondary: #34495e;
  --nse-accent: #2980b9;
  --nse-accent-light: #5dade2;
  --nse-success: #27ae60;
  --nse-warning: #f39c12;
  --nse-danger: #e74c3c;
  --nse-info: #3498db;
  --nse-light: #ecf0f1;
  --nse-dark: #1a252f;
  --nse-text: #333;
  --nse-text-light: #7f8c8d;
  --nse-bg: #ffffff;
  --nse-border: #bdc3c7;
  --nse-shadow: rgba(0, 0, 0, 0.1);
  --nse-shadow-lg: rgba(0, 0, 0, 0.15);
  --nse-radius: 8px;
  --nse-radius-lg: 12px;
  --nse-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Container */
.nse-container {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  line-height: 1.6;
  color: var(--nse-text);
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  background: var(--nse-bg);
}

/* Header */
.nse-header {
  text-align: center;
  margin-bottom: 30px;
  padding: 40px 20px;
  background: linear-gradient(135deg, var(--nse-accent) 0%, var(--nse-secondary) 100%);
  color: white;
  border-radius: var(--nse-radius-lg);
}

.nse-header h1 {
  margin: 0 0 10px 0;
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.nse-subtitle {
  margin: 10px 0;
  font-size: 1.2rem;
  opacity: 0.95;
  font-weight: 300;
}

.nse-author {
  font-size: 0.9rem;
  opacity: 0.85;
  margin-top: 10px;
}

/* Navigation Tabs */
.nse-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 30px;
  flex-wrap: wrap;
  justify-content: center;
}

.nse-tab {
  padding: 12px 20px;
  border: 2px solid var(--nse-border);
  background: var(--nse-bg);
  color: var(--nse-text);
  border-radius: var(--nse-radius);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: var(--nse-transition);
}

.nse-tab:hover {
  background: var(--nse-light);
  border-color: var(--nse-accent);
  transform: translateY(-2px);
}

.nse-tab.active {
  background: var(--nse-accent);
  color: white;
  border-color: var(--nse-accent);
}

/* Tab Content */
.nse-tab-content {
  display: none;
  animation: nseFadeIn 0.3s ease-in-out;
}

.nse-tab-content.active {
  display: block;
}

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

/* Cards */
.nse-card {
  background: white;
  padding: 25px;
  border-radius: var(--nse-radius-lg);
  margin-bottom: 25px;
  box-shadow: 0 2px 8px var(--nse-shadow);
  border-left: 4px solid var(--nse-accent);
}

.nse-card h2 {
  margin: 0 0 15px 0;
  color: var(--nse-primary);
  font-size: 1.8rem;
  font-weight: 600;
}

.nse-card p {
  margin-bottom: 15px;
  line-height: 1.7;
}

/* Tables */
.nse-table-container {
  overflow-x: auto;
  margin: 20px 0;
}

.nse-waves-table,
.nse-comparison-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: var(--nse-radius);
  overflow: hidden;
}

.nse-waves-table th,
.nse-comparison-table th {
  background: var(--nse-primary);
  color: white;
  padding: 15px;
  text-align: left;
  font-weight: 600;
}

.nse-waves-table td,
.nse-comparison-table td {
  padding: 15px;
  border-bottom: 1px solid var(--nse-light);
}

.nse-waves-table tr:last-child td,
.nse-comparison-table tr:last-child td {
  border-bottom: none;
}

.nse-waves-table tr:nth-child(even),
.nse-comparison-table tr:nth-child(even) {
  background: var(--nse-light);
}

.nse-highlight-row {
  background: linear-gradient(135deg, var(--nse-accent-light) 0%, var(--nse-accent) 100%) !important;
  color: white;
}

/* Framework */
.nse-framework {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin: 20px 0;
}

.nse-formula {
  background: var(--nse-light);
  padding: 20px;
  border-radius: var(--nse-radius);
  text-align: center;
}

.nse-formula h3 {
  margin: 0 0 15px 0;
  color: var(--nse-primary);
  font-size: 1.2rem;
}

.nse-math {
  font-family: 'Times New Roman', serif;
  font-size: 1.8rem;
  font-weight: bold;
  color: var(--nse-accent);
  margin: 15px 0;
}

.nse-math-large {
  font-family: 'Times New Roman', serif;
  font-size: 2.2rem;
  font-weight: bold;
  color: var(--nse-accent);
  text-align: center;
  margin: 20px 0;
}

.nse-formula-note {
  font-size: 0.9rem;
  color: var(--nse-text-light);
  margin: 10px 0 0 0;
}

/* Principles */
.nse-principles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin: 20px 0;
}

.nse-principle {
  background: white;
  padding: 20px;
  border-radius: var(--nse-radius);
  border: 2px solid var(--nse-light);
  text-align: center;
  transition: var(--nse-transition);
}

.nse-principle:hover {
  border-color: var(--nse-accent);
  transform: translateY(-5px);
  box-shadow: 0 8px 16px var(--nse-shadow-lg);
}

.nse-principle-icon {
  width: 50px;
  height: 50px;
  background: var(--nse-accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
  margin: 0 auto 15px;
}

.nse-principle h3 {
  margin: 0 0 10px 0;
  color: var(--nse-primary);
  font-size: 1.1rem;
}

.nse-principle p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--nse-text-light);
}

/* Interactive Layout */
.nse-interactive-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-bottom: 20px;
}

@media (max-width: 968px) {
  .nse-interactive-layout {
    grid-template-columns: 1fr;
  }
}

/* Canvas Container */
.nse-canvas-container {
  background: var(--nse-light);
  border-radius: var(--nse-radius);
  padding: 20px;
  margin-bottom: 20px;
}

.nse-canvas-container canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--nse-radius);
  background: white;
}

/* Controls */
.nse-controls {
  background: var(--nse-light);
  padding: 25px;
  border-radius: var(--nse-radius-lg);
}

.nse-control-group {
  margin-bottom: 20px;
}

.nse-control-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--nse-primary);
}

.nse-control-group input[type="range"] {
  width: 100%;
  height: 6px;
  background: var(--nse-border);
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
}

.nse-control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--nse-accent);
  border-radius: 50%;
  cursor: pointer;
}

.nse-control-group input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--nse-accent);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* Result Box */
.nse-result-box {
  background: white;
  padding: 20px;
  border-radius: var(--nse-radius);
  margin-top: 20px;
  border-left: 4px solid var(--nse-success);
}

.nse-result-box h3 {
  margin: 0 0 10px 0;
  color: var(--nse-primary);
  font-size: 1.1rem;
}

.nse-ratio-value,
.nse-growth-value {
  font-size: 2.5rem;
  font-weight: bold;
  color: var(--nse-accent);
  text-align: center;
  margin: 15px 0;
}

.nse-industry-type {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--nse-success);
  text-align: center;
  margin: 10px 0;
}

.nse-industry-examples {
  font-size: 0.95rem;
  color: var(--nse-text-light);
  text-align: center;
  font-style: italic;
}

/* Industry Table */
.nse-industry-table {
  margin-top: 20px;
}

.nse-industry-table table {
  width: 100%;
  border-collapse: collapse;
}

.nse-industry-table th {
  background: var(--nse-primary);
  color: white;
  padding: 12px;
  text-align: left;
}

.nse-industry-table td {
  padding: 12px;
  border-bottom: 1px solid var(--nse-light);
}

.nse-industry-table tr:nth-child(even) {
  background: var(--nse-light);
}

/* Chain Steps */
.nse-chain-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
  margin: 20px 0;
}

.nse-step {
  background: white;
  padding: 15px;
  border-radius: var(--nse-radius);
  border: 2px solid var(--nse-light);
  text-align: center;
  transition: var(--nse-transition);
}

.nse-step:hover {
  border-color: var(--nse-accent);
  transform: scale(1.05);
}

.nse-step-number {
  display: inline-block;
  width: 30px;
  height: 30px;
  background: var(--nse-accent);
  color: white;
  border-radius: 50%;
  line-height: 30px;
  font-weight: bold;
  margin-bottom: 10px;
}

.nse-step strong {
  display: block;
  color: var(--nse-primary);
  margin-bottom: 5px;
}

.nse-step span {
  font-size: 0.85rem;
  color: var(--nse-text-light);
}

/* Animation Controls */
.nse-animation-controls {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin: 20px 0;
}

.nse-btn {
  padding: 12px 30px;
  border: 2px solid var(--nse-accent);
  background: white;
  color: var(--nse-accent);
  border-radius: var(--nse-radius);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: var(--nse-transition);
}

.nse-btn:hover {
  background: var(--nse-accent);
  color: white;
}

.nse-btn-primary {
  background: var(--nse-accent);
  color: white;
}

.nse-btn-primary:hover {
  background: var(--nse-secondary);
}

/* Contribution Bars */
.nse-contribution-bars {
  margin-top: 20px;
}

.nse-contribution-bars h3 {
  margin: 0 0 15px 0;
  color: var(--nse-primary);
}

.nse-bar-container {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}

.nse-bar-label {
  width: 120px;
  font-weight: 500;
  color: var(--nse-text);
}

.nse-bar-wrapper {
  flex: 1;
  height: 30px;
  background: var(--nse-light);
  border-radius: 15px;
  overflow: hidden;
}

.nse-bar {
  height: 100%;
  transition: width 0.5s ease-out;
  border-radius: 15px;
}

.nse-bar-tfp {
  background: linear-gradient(90deg, #9b59b6, #8e44ad);
}

.nse-bar-capital {
  background: linear-gradient(90deg, var(--nse-accent-light), var(--nse-accent));
}

.nse-bar-labor {
  background: linear-gradient(90deg, var(--nse-success), #1e8449);
}

.nse-bar-value {
  width: 70px;
  text-align: right;
  font-weight: bold;
  color: var(--nse-primary);
}

/* Functions Grid */
.nse-functions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin: 20px 0;
}

.nse-function-card {
  background: white;
  padding: 20px;
  border-radius: var(--nse-radius);
  border: 2px solid var(--nse-light);
  text-align: center;
  transition: var(--nse-transition);
}

.nse-function-card:hover {
  border-color: var(--nse-accent);
  transform: translateY(-5px);
  box-shadow: 0 8px 16px var(--nse-shadow-lg);
}

.nse-function-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.nse-function-card h3 {
  margin: 0 0 8px 0;
  color: var(--nse-primary);
  font-size: 1rem;
}

.nse-function-card p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--nse-text-light);
}

/* GIFF Steps */
.nse-giff-steps {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin: 20px 0;
}

.nse-giff-step {
  display: flex;
  align-items: center;
  gap: 15px;
  background: white;
  padding: 15px 20px;
  border-radius: var(--nse-radius);
  border-left: 4px solid var(--nse-accent);
}

.nse-giff-number {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: var(--nse-accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.2rem;
}

.nse-giff-step h3 {
  margin: 0 0 5px 0;
  color: var(--nse-primary);
  font-size: 1rem;
}

.nse-giff-step p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--nse-text-light);
}

/* Country Selector */
.nse-country-selector {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.nse-country-btn {
  padding: 10px 25px;
  border: 2px solid var(--nse-border);
  background: white;
  color: var(--nse-text);
  border-radius: var(--nse-radius);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: var(--nse-transition);
}

.nse-country-btn:hover {
  border-color: var(--nse-accent);
}

.nse-country-btn.active {
  background: var(--nse-accent);
  color: white;
  border-color: var(--nse-accent);
}

/* Case Details */
.nse-case-details {
  margin-top: 20px;
}

.nse-case-content {
  display: none;
}

.nse-case-content.active {
  display: block;
}

.nse-case-content h3 {
  margin: 0 0 20px 0;
  color: var(--nse-primary);
  font-size: 1.3rem;
}

/* Timeline */
.nse-timeline {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.nse-timeline-item {
  display: flex;
  gap: 20px;
  background: var(--nse-light);
  padding: 20px;
  border-radius: var(--nse-radius);
  position: relative;
}

.nse-timeline-item::before {
  content: '';
  position: absolute;
  left: 65px;
  top: 20px;
  bottom: 20px;
  width: 2px;
  background: var(--nse-accent);
}

.nse-timeline-item:last-child::before {
  display: none;
}

.nse-timeline-period {
  flex-shrink: 0;
  width: 50px;
  height: 50px;
  background: var(--nse-accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.85rem;
  z-index: 1;
}

.nse-timeline-item strong {
  display: block;
  color: var(--nse-primary);
  margin-bottom: 5px;
}

.nse-timeline-item p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--nse-text-light);
}

/* Growth Formula */
.nse-growth-formula {
  background: white;
  padding: 25px;
  border-radius: var(--nse-radius);
  margin: 20px 0;
  text-align: center;
}

/* Footer */
.nse-footer {
  text-align: center;
  padding: 30px 20px;
  margin-top: 40px;
  border-top: 2px solid var(--nse-light);
  color: var(--nse-text-light);
}

.nse-footer p {
  margin: 5px 0;
}

.nse-footer-links a {
  color: var(--nse-accent);
  text-decoration: none;
  margin: 0 10px;
}

.nse-footer-links a:hover {
  text-decoration: underline;
}

/* Comparison Table Container */
.nse-comparison-table-container {
  overflow-x: auto;
  margin: 20px 0;
}

/* Responsive Design */
@media (max-width: 768px) {
  .nse-container {
    padding: 15px;
  }

  .nse-header h1 {
    font-size: 1.8rem;
  }

  .nse-subtitle {
    font-size: 1rem;
  }

  .nse-tabs {
    flex-direction: column;
  }

  .nse-tab {
    width: 100%;
  }

  .nse-framework,
  .nse-principles,
  .nse-functions-grid {
    grid-template-columns: 1fr;
  }

  .nse-chain-steps {
    grid-template-columns: 1fr;
  }

  .nse-interactive-layout {
    grid-template-columns: 1fr;
  }

  .nse-controls,
  .nse-canvas-container {
    padding: 15px;
  }

  .nse-timeline-item {
    flex-direction: column;
    gap: 10px;
  }

  .nse-timeline-item::before {
    display: none;
  }

  .nse-country-selector {
    flex-direction: column;
  }

  .nse-country-btn {
    width: 100%;
  }
}

/* Accessibility */
.nse-tab:focus,
.nse-btn:focus,
.nse-country-btn:focus,
.nse-function-card:focus {
  outline: 2px solid var(--nse-info);
  outline-offset: 2px;
}

/* Print Styles */
@media print {
  .nse-tabs,
  .nse-country-selector {
    display: none;
  }

  .nse-container {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}
