/* Calculator Design System - That One.App */
/* Island Breeze aesthetic with That One Touch interactions */

/* ===== ROOT VARIABLES ===== */
:root {
  /* Brand Colors - Island Breeze */
  --sand: #F5E6D3;
  --ocean: #5B9EBF;
  --palm: #8B7355;
  --cloud: #FAFAFA;
  --daffodil: #FFE4A1;
  --breeze: #E8F4F8;
  
  /* Text Colors */
  --text-primary: #2C3E50;
  --text-secondary: #5A6C7D;
  --text-muted: #8A9BAD;
  
  /* Functional Colors */
  --success: #52C41A;
  --warning: #FAAD14;
  --error: #F5222D;
  
  /* Calculator Specific Colors */
  --positive: var(--success);      /* Green for gains, savings, income */
  --negative: var(--error);        /* Red for costs, debt, expenses */
  --neutral: var(--ocean);         /* Blue for time, quantities */
  --brand: #8B5CF6;                /* Purple for actions */
  
  /* Spacing Scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  
  /* Typography Scale */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  
  /* Borders */
  --border-radius: 0.5rem;
  --border-radius-lg: 0.75rem;
  --border-width: 1px;
  
  /* Touch Targets */
  --touch-target: 44px;
  
  /* Transitions */
  --transition-fast: 150ms ease-in-out;
  --transition-normal: 250ms ease-in-out;
  --transition-slow: 350ms ease-in-out;
}

/* ===== BASE CALCULATOR STYLES ===== */
.calculator {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-md);
  background: var(--cloud);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  line-height: 1.6;
}

.calculator__title {
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--space-lg) 0;
  text-align: center;
}

.calculator__subtitle {
  font-size: var(--text-base);
  color: var(--text-secondary);
  margin: 0 0 var(--space-xl) 0;
  text-align: center;
}

/* ===== SECTION COMPONENTS ===== */
.calc-section {
  background: white;
  border-radius: var(--border-radius);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-sm);
  border: var(--border-width) solid rgba(91, 158, 191, 0.1);
}

.calc-section:last-child {
  margin-bottom: 0;
}

.calc-section__title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--space-md) 0;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.calc-section__subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin: 0 0 var(--space-lg) 0;
}

/* ===== INPUT COMPONENTS ===== */
.calc-input-group {
  margin-bottom: var(--space-lg);
}

.calc-input-group:last-child {
  margin-bottom: 0;
}

.calc-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

/* Base Input Styles */
.calc-input {
  width: 100%;
  min-height: var(--touch-target);
  padding: var(--space-sm) var(--space-md);
  border: 2px solid var(--breeze);
  border-radius: var(--border-radius);
  background: white;
  color: var(--text-primary);
  font-size: var(--text-base);
  font-family: inherit;
  transition: all var(--transition-fast);
  box-sizing: border-box;
}

.calc-input:focus {
  outline: none;
  border-color: var(--ocean);
  box-shadow: 0 0 0 3px rgba(91, 158, 191, 0.1);
}

.calc-input:hover {
  border-color: var(--ocean);
}

.calc-input::placeholder {
  color: var(--text-muted);
}

/* Currency Input */
.calc-input--currency {
  text-align: right;
  font-weight: 600;
  font-size: var(--text-lg);
}

.calc-input--currency::before {
  content: '$';
  color: var(--text-secondary);
}

/* Percentage Input */
.calc-input--percentage {
  text-align: right;
  position: relative;
}

.calc-input--percentage::after {
  content: '%';
  position: absolute;
  right: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}

/* Year Input */
.calc-input--years {
  text-align: center;
  font-weight: 600;
}

/* ===== SLIDER COMPONENTS ===== */
.calc-slider {
  width: 100%;
  margin: var(--space-md) 0;
}

.calc-slider__container {
  position: relative;
  margin-bottom: var(--space-sm);
}

.calc-slider__input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--breeze);
  border-radius: 3px;
  outline: none;
  transition: background var(--transition-fast);
}

.calc-slider__input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  background: var(--ocean);
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.calc-slider__input::-webkit-slider-thumb:hover {
  background: var(--palm);
  transform: scale(1.1);
}

.calc-slider__input::-moz-range-thumb {
  width: 24px;
  height: 24px;
  background: var(--ocean);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.calc-slider__input::-moz-range-thumb:hover {
  background: var(--palm);
  transform: scale(1.1);
}

.calc-slider__labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

/* ===== DROPDOWN COMPONENTS ===== */
.calc-select {
  width: 100%;
  min-height: var(--touch-target);
  padding: var(--space-sm) var(--space-md);
  border: 2px solid var(--breeze);
  border-radius: var(--border-radius);
  background: white;
  color: var(--text-primary);
  font-size: var(--text-base);
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%235A6C7D' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right var(--space-sm) center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: calc(var(--space-md) + 1.5em + var(--space-sm));
}

.calc-select:focus {
  outline: none;
  border-color: var(--ocean);
  box-shadow: 0 0 0 3px rgba(91, 158, 191, 0.1);
}

.calc-select:hover {
  border-color: var(--ocean);
}

/* ===== BUTTON COMPONENTS ===== */
.calc-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: var(--touch-target);
  padding: var(--space-sm) var(--space-lg);
  border: none;
  border-radius: var(--border-radius);
  font-size: var(--text-base);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  box-sizing: border-box;
}

/* Primary Button (Calculate) */
.calc-button--primary {
  background: var(--brand);
  color: white;
  box-shadow: var(--shadow-md);
}

.calc-button--primary:hover {
  background: #7C3AED;
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.calc-button--primary:active {
  transform: translateY(0);
}

/* Secondary Button (Reset/Clear) */
.calc-button--secondary {
  background: var(--breeze);
  color: var(--text-primary);
  border: 1px solid var(--ocean);
}

.calc-button--secondary:hover {
  background: var(--sand);
  border-color: var(--palm);
}

/* Full Width Button */
.calc-button--full {
  width: 100%;
}

/* Button Group */
.calc-button-group {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

.calc-button-group .calc-button {
  flex: 1;
}

/* ===== RESULTS COMPONENTS ===== */
.calc-results {
  background: linear-gradient(135deg, var(--breeze) 0%, var(--cloud) 100%);
  border-radius: var(--border-radius);
  padding: var(--space-lg);
  margin-top: var(--space-lg);
  border: 1px solid rgba(91, 158, 191, 0.2);
}

/* Primary Result (Large, Prominent) */
.calc-result--primary {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.calc-result--primary .calc-result__label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.calc-result--primary .calc-result__value {
  font-size: var(--text-4xl);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

/* Secondary Results Grid */
.calc-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

.calc-result--secondary {
  background: white;
  padding: var(--space-md);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.calc-result--secondary .calc-result__label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.calc-result--secondary .calc-result__value {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

/* Color Coding for Values */
.calc-result__value--positive {
  color: var(--positive);
}

.calc-result__value--negative {
  color: var(--negative);
}

.calc-result__value--neutral {
  color: var(--neutral);
}

/* ===== STATE COMPONENTS ===== */
/* Loading State */
.calc-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
  color: var(--text-secondary);
}

.calc-loading__spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--breeze);
  border-top: 2px solid var(--ocean);
  border-radius: 50%;
  animation: calc-spin 1s linear infinite;
}

@keyframes calc-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Error State */
.calc-error {
  background: rgba(245, 34, 45, 0.1);
  border: 1px solid var(--error);
  border-radius: var(--border-radius);
  padding: var(--space-md);
  color: var(--error);
  font-size: var(--text-sm);
  margin-top: var(--space-sm);
}

/* ===== UTILITY CLASSES ===== */
.calc-hidden {
  display: none;
}

.calc-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.calc-text-center {
  text-align: center;
}

.calc-text-right {
  text-align: right;
}

.calc-text-left {
  text-align: left;
}

.calc-mb-0 { margin-bottom: 0; }
.calc-mb-sm { margin-bottom: var(--space-sm); }
.calc-mb-md { margin-bottom: var(--space-md); }
.calc-mb-lg { margin-bottom: var(--space-lg); }

.calc-mt-0 { margin-top: 0; }
.calc-mt-sm { margin-top: var(--space-sm); }
.calc-mt-md { margin-top: var(--space-md); }
.calc-mt-lg { margin-top: var(--space-lg); }

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 640px) {
  .calculator {
    margin: var(--space-sm);
    padding: var(--space-sm);
  }
  
  .calc-section {
    padding: var(--space-md);
  }
  
  .calc-results-grid {
    grid-template-columns: 1fr;
  }
  
  .calc-button-group {
    flex-direction: column;
  }
  
  .calc-result--primary .calc-result__value {
    font-size: var(--text-3xl);
  }
}

@media (max-width: 480px) {
  .calculator__title {
    font-size: var(--text-xl);
  }
  
  .calc-result--primary .calc-result__value {
    font-size: var(--text-2xl);
  }
  
  .calc-input, .calc-select, .calc-button {
    font-size: var(--text-sm);
  }
}

/* ===== ACCESSIBILITY ENHANCEMENTS ===== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: high) {
  .calc-input {
    border-width: 3px;
  }
  
  .calc-button {
    border: 2px solid currentColor;
  }
}

/* Focus indicators for keyboard navigation */
.calc-input:focus,
.calc-select:focus,
.calc-button:focus {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

/* ===== PRINT STYLES ===== */
@media print {
  .calculator {
    box-shadow: none;
    border: 1px solid #ddd;
  }
  
  .calc-button {
    display: none;
  }
  
  .calc-results {
    background: none;
    border: 1px solid #ddd;
  }
}

/* ===== MICRO-INTERACTIONS ===== */
.calc-input:not(:placeholder-shown) {
  border-color: var(--ocean);
  background: rgba(91, 158, 191, 0.02);
}

.calc-section:hover {
  box-shadow: var(--shadow-md);
  transition: box-shadow var(--transition-normal);
}

.calc-result--primary .calc-result__value {
  transition: color var(--transition-normal);
}

/* Smooth value changes */
.calc-result__value {
  transition: all var(--transition-normal);
}

/* ===== COMPONENT VARIATIONS ===== */
/* Compact Calculator for smaller screens */
.calculator--compact {
  padding: var(--space-sm);
}

.calculator--compact .calc-section {
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.calculator--compact .calc-result--primary .calc-result__value {
  font-size: var(--text-2xl);
}

/* Full-screen calculator for complex apps */
.calculator--fullscreen {
  max-width: none;
  min-height: 100vh;
  border-radius: 0;
  margin: 0;
}

/* Two-column layout for larger screens */
@media (min-width: 768px) {
  .calculator--two-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
    max-width: 1000px;
  }
  
  .calculator--two-column .calc-results {
    grid-column: 1 / -1;
  }
}