/* ============================================= */
/* GRAPH COMPONENTS - DESIGN SYSTEM */
/* ============================================= */

:root {
  /* ============ */
  /* COLOR SYSTEM */
  /* ============ */
  --graph-primary: #2c3e50;
  --graph-primary-light: rgba(44, 62, 80, 0.1);
  --graph-secondary: #3498db;
  --graph-secondary-light: rgba(52, 152, 219, 0.1);
  --graph-accent: #ff4d00;
  --graph-accent-light: rgba(255, 77, 0, 0.1);
  --graph-accent-rgb: 255, 77, 0;
  
  /* State Colors */
  --graph-success: #28a745;
  --graph-danger: #dc3545;
  --graph-warning: #ffc107;
  --graph-info: #17a2b8;
  
  /* Neutrals */
  --graph-light: #f8f9fa;
  --graph-lighter: rgba(248, 249, 250, 0.7);
  --graph-dark: #343a40;
  --graph-border: rgba(0, 0, 0, 0.1);
  
  /* ============= */
  /* SPACING SCALE */
  /* ============= */
  --graph-space-xxs: 0.25rem;   /* 4px */
  --graph-space-xs: 0.5rem;     /* 8px */
  --graph-space-sm: 0.75rem;    /* 12px */
  --graph-space-md: 1rem;       /* 16px */
  --graph-space-lg: 1.5rem;     /* 24px */
  --graph-space-xl: 2rem;       /* 32px */
  --graph-space-xxl: 3rem;      /* 48px */
  
  /* ================ */
  /* BORDER RADIUS */
  /* ================ */
  --graph-radius-sm: 0.25rem;   /* 4px */
  --graph-radius-md: 0.5rem;    /* 8px */
  --graph-radius-lg: 0.75rem;   /* 12px */
  --graph-radius-xl: 1rem;      /* 16px */
  --graph-radius-pill: 100vmax;
  
  /* ============ */
  /* SHADOWS */
  /* ============ */
  --graph-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --graph-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --graph-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --graph-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  --graph-shadow-accent: 0 4px 20px rgba(var(--graph-accent-rgb), 0.3);
  
  /* ============ */
  /* TRANSITIONS */
  /* ============ */
  --graph-transition-fast: 0.15s ease;
  --graph-transition-normal: 0.3s ease;
  --graph-transition-slow: 0.5s ease;
  --graph-transition-bounce: cubic-bezier(0.68, -0.6, 0.32, 1.6);
}

/* ============================================= */
/* BASE COMPONENT STYLES */
/* ============================================= */

/* ------------------------ */
/* CALCULATOR LAYOUT SYSTEM */
/* ------------------------ */

.calculator-grid {
  display: grid;
  gap: var(--graph-space-lg);
  width: 100%;
}

.calculator-column {
  display: flex;
  flex-direction: column;
  gap: var(--graph-space-lg);
}

/* Desktop layout */
@media (min-width: 992px) {
  .calculator-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
    align-items: start;
  }
}

/* ------------------------ */
/* INTERACTIVE CONTROLS */
/* ------------------------ */

.controls {
  display: flex;
  flex-direction: column;
  gap: var(--graph-space-md);
}

.slider-container {
  display: flex;
  flex-direction: column;
  gap: var(--graph-space-xs);
  background: var(--graph-lighter);
  padding: var(--graph-space-md);
  border-radius: var(--graph-radius-md);
  box-shadow: var(--graph-shadow-sm);
  border: 1px solid var(--graph-border);
  transition: all var(--graph-transition-normal);
}

.slider-container:hover {
  box-shadow: var(--graph-shadow-md);
  border-color: rgba(var(--graph-accent-rgb), 0.2);
}

.slider-container label {
  font-weight: 600;
  color: var(--graph-primary);
  font-size: 0.9rem;
}

.slider {
  width: 100%;
  margin: var(--graph-space-xs) 0;
  -webkit-appearance: none;
  height: 6px;
  border-radius: var(--graph-radius-pill);
  background: linear-gradient(90deg, var(--graph-accent), var(--graph-secondary));
  outline: none;
  cursor: pointer;
  transition: all var(--graph-transition-fast);
}

.slider:focus-visible {
  box-shadow: 0 0 0 3px rgba(var(--graph-accent-rgb), 0.3);
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--graph-accent);
  cursor: pointer;
  box-shadow: var(--graph-shadow-md);
  transition: all var(--graph-transition-bounce);
  transform: scale(1);
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.slider::-webkit-slider-thumb:active {
  transform: scale(1.1);
}

.value-display {
  font-size: 0.85rem;
  color: var(--graph-dark);
  font-weight: 500;
  display: flex;
  justify-content: space-between;
}

/* ============================================= */
/* ENHANCED CALCULATOR LAYOUT */
/* ============================================= */

.calculator-section {
    background: var(--graph-light);
    padding: var(--graph-space-xl);
    border-radius: var(--graph-radius-lg);
    box-shadow: var(--graph-shadow-md);
    margin: var(--graph-space-xl) auto;
    max-width: 1400px;
    border: 1px solid var(--graph-border);
}

.section-title {
    text-align: center;
    margin-bottom: var(--graph-space-lg);
    color: var(--graph-primary);
    font-size: 1.75rem;
    position: relative;
    padding-bottom: var(--graph-space-xs);
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background: var(--graph-accent);
    border-radius: var(--graph-radius-pill);
}

.calculator-wrapper {
    display: flex;
    flex-direction: column;
    gap: var(--graph-space-lg);
}

.calculator-group {
    display: flex;
    gap: var(--graph-space-lg);
    background: white;
    padding: var(--graph-space-lg);
    border-radius: var(--graph-radius-lg);
    box-shadow: var(--graph-shadow-sm);
    transition: all var(--graph-transition-normal);
}

.calculator-group:hover {
    box-shadow: var(--graph-shadow-md);
}

.upper-group {
    background: linear-gradient(135deg, var(--graph-lighter) 0%, white 100%);
}

.lower-group {
    background: linear-gradient(135deg, white 0%, var(--graph-lighter) 100%);
}

/* Grid item containers */
.controls-container {
    flex: 1;
    background: rgba(var(--graph-accent-rgb), 0.03);
    border: 1px solid rgba(var(--graph-accent-rgb), 0.1);
}

.equation-container {
    flex: 1.5;
    background: rgba(var(--graph-secondary-rgb), 0.03);
    border: 1px solid rgba(var(--graph-secondary-rgb), 0.1);
}

.classification-container {
    flex: 1;
    background: rgba(var(--graph-primary-rgb), 0.03);
    border: 1px solid rgba(var(--graph-primary-rgb), 0.1);
}

.graph-container {
    flex: 1.5;
    /* Your existing graph container styles remain */
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .calculator-group {
        flex-direction: column;
    }
    
    .calculator-section {
        padding: var(--graph-space-lg);
    }
    
    .section-title {
        font-size: 1.5rem;
    }
}

@media (max-width: 768px) {
    .calculator-section {
        padding: var(--graph-space-md);
        margin: var(--graph-space-md) auto;
    }
    
    .calculator-group {
        padding: var(--graph-space-md);
    }
}

/* ------------------------ */
/* EQUATION DISPLAY */
/* ------------------------ */

.equation-section {
  background: var(--graph-lighter);
  border-radius: var(--graph-radius-lg);
  padding: var(--graph-space-lg);
  box-shadow: var(--graph-shadow-sm);
  transition: all var(--graph-transition-normal);
}

.equation-section:hover {
  box-shadow: var(--graph-shadow-md);
}

.equation-container {
  text-align: center;
}

.equation-container p {
  margin: 0 0 var(--graph-space-sm) 0;
}

.current-values {
  margin: var(--graph-space-md) 0;
  padding: var(--graph-space-sm);
  background: white;
  border-left: 4px solid var(--graph-secondary);
  border-radius: var(--graph-radius-sm);
}

.final-result {
  margin: var(--graph-space-md) 0;
  padding: var(--graph-space-md);
  background: var(--graph-light);
  border-radius: var(--graph-radius-md);
  font-size: 1.1rem;
}

.final-result p {
  margin: var(--graph-space-xs) 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ------------------------ */
/* CLASSIFICATION SYSTEM */
/* ------------------------ */

.classification-logic {
  background-color: var(--graph-light);
  border-radius: var(--graph-radius-lg);
  padding: var(--graph-space-lg);
  box-shadow: var(--graph-shadow-sm);
  transition: all var(--graph-transition-normal);
}

.classification-logic:hover {
  box-shadow: var(--graph-shadow-md);
}

.classification-logic h3 {
  color: var(--graph-primary);
  margin-bottom: var(--graph-space-md);
  padding-bottom: var(--graph-space-xs);
  border-bottom: 2px solid var(--graph-border);
}

.logic-steps {
  display: flex;
  flex-direction: column;
  gap: var(--graph-space-md);
}

.logic-step {
  background-color: white;
  padding: var(--graph-space-md);
  border-radius: var(--graph-radius-sm);
  box-shadow: var(--graph-shadow-sm);
  border-left: 4px solid var(--graph-border);
  transition: all var(--graph-transition-fast);
}

.logic-step:hover {
  transform: translateX(2px);
  border-left-color: var(--graph-accent);
}

.logic-step strong {
  color: var(--graph-primary);
  display: block;
  margin-bottom: var(--graph-space-xs);
}

/* State Indicators */
.result-label {
  font-weight: bold;
  padding: var(--graph-space-xxs) var(--graph-space-sm);
  border-radius: var(--graph-radius-sm);
  display: inline-flex;
  align-items: center;
  gap: var(--graph-space-xxs);
}

.result-label::before {
  content: '';
  display: inline-block;
  width: 0.5em;
  height: 0.5em;
  border-radius: 50%;
  background: currentColor;
}

.result-normal {
  background-color: var(--graph-primary-light);
  color: var(--graph-success);
}

.result-acidosis {
  background-color: var(--graph-accent-light);
  color: var(--graph-danger);
}

.result-alkalosis {
  background-color: var(--graph-secondary-light);
  color: var(--graph-info);
}

/* ------------------------ */
/* GRAPH VISUALIZATION */
/* ------------------------ */

.graph-section {
  background: var(--graph-lighter);
  border-radius: var(--graph-radius-lg);
  padding: var(--graph-space-lg);
  box-shadow: var(--graph-shadow-md);
  border: 1px solid var(--graph-border);
  transition: all var(--graph-transition-slow);
}

.graph-section:hover {
  box-shadow: var(--graph-shadow-xl);
}

.graph-heading {
  color: var(--graph-accent);
  font-size: 1.25rem;
  margin-top: 0;
  margin-bottom: var(--graph-space-md);
  padding-bottom: var(--graph-space-xs);
  border-bottom: 2px solid rgba(var(--graph-accent-rgb), 0.2);
  text-align: center;
  position: relative;
}

.graph-heading::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 3rem;
  height: 2px;
  background: var(--graph-accent);
}

.graph-container {
  width: 100%;
  height: 400px;
  border: 2px solid var(--graph-accent);
  border-radius: var(--graph-radius-lg);
  background: white;
  box-shadow: var(--graph-shadow-accent);
  transition: all var(--graph-transition-normal);
  position: relative;
  overflow: hidden;
  margin-top: var(--graph-space-md);
}

.graph-container::before {
  content: '';
  position: absolute;
  inset: -10px;
  background: linear-gradient(
    45deg,
    var(--graph-accent) 0%,
    var(--graph-warning) 50%,
    var(--graph-accent) 100%
  );
  z-index: -1;
  filter: blur(20px);
  opacity: 0.3;
  animation: graphPulse 3s infinite alternate;
}

@keyframes graphPulse {
  0% { opacity: 0.2; }
  100% { opacity: 0.4; }
}

/* Plotly-specific overrides */
.js-plotly-plot .plot-container.plotly,
.js-plotly-plot .main-svg,
.js-plotly-plot .bg {
  background: transparent !important;
}

.js-plotly-plot .bg {
  fill: transparent !important;
}

/* ============================================= */
/* RESPONSIVE ADJUSTMENTS */
/* ============================================= */

@media (min-width: 768px) {
  .graph-container {
    height: 500px;
  }
  
  .graph-heading {
    font-size: 1.5rem;
  }
}

@media (min-width: 1200px) {
  .graph-container {
    height: 600px;
  }
}

@media (max-width: 480px) {
  .equation-section,
  .classification-logic,
  .graph-section {
    padding: var(--graph-space-md);
  }
  
  .graph-container {
    height: 350px;
  }
}
