/* GPS Altitude & Geoid Tool - Mobile-First CSS */

/* CSS Custom Properties */
:root {
  /* Colors */
  --primary-100: #A6FAFF;
  --primary-500: #00D1FF;
  --primary-700: #0096B3;
  
  --bg-page: #000000;
  --bg-surface: #141414;
  --border-default: #262626;
  --text-primary: #E4E4E7;
  --text-secondary: #A3A3A3;
  --text-disabled: #525252;
  
  --success: #22C55E;
  --warning: #FBBF24;
  --error: #F43F5E;
  
  --geoid-positive: #4299E1;
  --geoid-negative: #E53E3E;
  
  /* Spacing (8px base) */
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-xxl: 48px;
  --space-xxxl: 64px;
  
  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  
  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 209, 255, 0.1);
  --shadow-md: 0 4px 24px rgba(0, 209, 255, 0.15);
  --shadow-lg: 0 8px 32px rgba(0, 209, 255, 0.2);
}

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Icons */
.icon {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  fill: none;
  stroke: currentColor;
  flex-shrink: 0;
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg-page);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease-out;
}

.loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-content {
  text-align: center;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid var(--border-default);
  border-top: 3px solid var(--primary-500);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto var(--space-md);
}

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

/* Main Container */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.icon-large {
    width: 80px;
    height: 80px;
}

/* Header */
.app-header {
  padding: var(--space-lg) var(--space-md);
  text-align: center;
  border-bottom: 1px solid var(--border-default);
  background: rgba(20, 20, 20, 0.5);
  backdrop-filter: blur(10px);
}

.app-title {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: var(--space-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

.app-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  font-weight: 400;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: var(--space-lg) var(--space-md);
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Cards */
.card {
  background: rgba(20, 20, 20, 0.65);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(38, 38, 38, 0.75);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  overflow: hidden;
  max-width: 100%;
  box-sizing: border-box;
}

.section-title {
  font-size: 20px;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Input Components */
.input-group {
  margin-bottom: var(--space-md);
}

.input-group label {
  display: block;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.input-wrapper {
  position: relative;
}

.input-wrapper input {
  width: 100%;
  height: 52px;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-page);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  color: var(--text-primary);
  transition: all 200ms ease-out;
}

.input-wrapper input:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: var(--shadow-md);
}

.input-wrapper input.valid {
  border-color: var(--success);
}

.input-wrapper input.invalid {
  border-color: var(--error);
}

.validation-icon {
  position: absolute;
  right: var(--space-sm);
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
}

.validation-icon.valid::before {
  content: "✓";
  color: var(--success);
}

.validation-icon.invalid::before {
  content: "✗";
  color: var(--error);
}

/* Toggle Controls */
.input-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.format-toggle,
.unit-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.toggle-label {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.toggle-switch {
  position: relative;
  display: inline-block;
}

.toggle-input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  display: flex;
  background: var(--bg-page);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 200ms ease-out;
  overflow: hidden;
}

.toggle-input:checked + .toggle-slider {
  border-color: var(--primary-500);
  box-shadow: var(--shadow-sm);
}

.toggle-option {
  padding: var(--space-xs) var(--space-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all 200ms ease-out;
  min-width: 60px;
  text-align: center;
}

.toggle-option:first-child {
  background: transparent;
  color: var(--text-secondary);
}

.toggle-option:last-child {
  background: var(--primary-500);
  color: var(--bg-page);
}

/* Button Styles */
.calculate-btn {
  width: 100%;
  height: 52px;
  background: var(--primary-500);
  color: var(--bg-page);
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  transition: all 200ms ease-out;
  margin-top: var(--space-sm);
}

.calculate-btn:hover:not(:disabled) {
  background: var(--primary-100);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.calculate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.calculate-btn:active {
  transform: translateY(0);
}

/* Results */
.results-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
  overflow: hidden;
}

.result-item {
  text-align: center;
  padding: var(--space-md);
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  overflow: hidden;
  max-width: 100%;
  box-sizing: border-box;
}

.result-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
  font-weight: 400;
}

.result-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 24px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
  word-break: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  max-width: 100%;
}

.result-unit {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 400;
}

.additional-info {
  border-top: 1px solid var(--border-default);
  padding-top: var(--space-md);
}

.info-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.info-label {
  color: var(--text-secondary);
  font-size: 14px;
}

.info-value {
  color: var(--text-primary);
  font-weight: 500;
}

/* Examples */
.example-locations {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
}

/* Mobile (max-width: 480px) */
@media (max-width: 480px) {
  .example-locations {
    grid-template-columns: 1fr;
    gap: var(--space-xs);
  }
  
  .example-btn {
    font-size: 12px;
    padding: var(--space-xs);
    line-height: 1.2;
    min-height: 50px;
  }
  
  .result-value {
    font-size: 18px;
  }
  
  .chart-container {
    height: 200px;
  }
  
  .earth-container {
    height: 250px;
  }
}

.example-btn {
  padding: var(--space-sm);
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: all 200ms ease-out;
  text-align: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  white-space: normal;
}

.example-btn:hover {
  border-color: var(--primary-500);
  color: var(--primary-500);
}

/* Visualization Panel */
.earth-container {
  position: relative;
  height: 400px;
  background: radial-gradient(circle at center, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: grab;
}

.earth-container:active {
  cursor: grabbing;
}

.earth-controls {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  z-index: 10;
}

.control-btn {
  width: 40px;
  height: 40px;
  background: rgba(20, 20, 20, 0.8);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 200ms ease-out;
  backdrop-filter: blur(10px);
}

.control-btn:hover {
  color: var(--text-primary);
  border-color: var(--primary-500);
}

.earth-info {
  position: absolute;
  bottom: var(--space-sm);
  left: var(--space-sm);
  background: rgba(20, 20, 20, 0.8);
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  backdrop-filter: blur(10px);
  max-width: calc(100% - 2rem);
}

/* Chart */
.chart-container {
  height: 300px;
  margin-bottom: var(--space-md);
  overflow: hidden;
  position: relative;
}

.chart-controls {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
}

.profile-btn {
  padding: var(--space-sm) var(--space-md);
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all 200ms ease-out;
}

.profile-btn.active,
.profile-btn:hover {
  color: var(--text-primary);
  border-color: var(--primary-500);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px);
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 18px;
  font-weight: 500;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  transition: all 200ms ease-out;
}

.modal-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

.modal-body {
  padding: var(--space-lg);
}

/* Footer */
.app-footer {
  background: rgba(20, 20, 20, 0.5);
  border-top: 1px solid var(--border-default);
  padding: var(--space-xl) var(--space-md);
  margin-top: auto;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
  margin-bottom: var(--space-lg);
}

.footer-section h3 {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

.footer-section p,
.footer-section ul {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.footer-section ul {
  list-style: none;
  padding: 0;
}

.footer-section li {
  margin-bottom: var(--space-xs);
}

.footer-section li::before {
  content: "•";
  color: var(--primary-500);
  margin-right: var(--space-xs);
}

.footer-bottom {
  text-align: center;
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-default);
  color: var(--text-secondary);
  font-size: 14px;
}

/* Animations */
.fade-in {
  animation: fadeIn 0.3s ease-out;
}

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

.slide-up {
  animation: slideUp 0.3s ease-out;
}

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

/* Utility Classes */
.hidden {
  display: none !important;
}

.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;
}

/* Responsive Design - Mobile First */

/* Small phones (max-width: 480px) */
@media (max-width: 480px) {
  .app-title {
    font-size: 24px;
  }
  
  .section-title {
    font-size: 18px;
  }
  
  .input-controls {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
  }
  
  .example-locations {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }
  
  .example-btn {
    font-size: 13px;
    padding: var(--space-xs) var(--space-sm);
    line-height: 1.2;
  }
  
  .results-grid {
    gap: var(--space-md);
  }
  
  .result-value {
    font-size: 20px;
  }
  
  .earth-container {
    height: 300px;
  }
  
  .chart-container {
    height: 250px;
  }
  
  .modal-content {
    width: 95%;
  }
}

/* Large phones and small tablets (min-width: 768px) */
@media (min-width: 768px) {
  .main-content {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: var(--space-xl);
    align-items: start;
  }
  
  .control-panel {
    position: sticky;
    top: var(--space-lg);
  }
  
  .results-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .earth-container {
    height: 500px;
  }
  
  .chart-container {
    height: 350px;
  }
  
  .footer-content {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .example-locations {
    grid-template-columns: 1fr 1fr;
  }
  
  .example-btn {
    padding: var(--space-sm) var(--space-md);
    font-size: 14px;
    text-align: center;
    line-height: 1.2;
  }
}

/* Desktop (min-width: 1024px) */
@media (min-width: 1024px) {
  .main-content {
    gap: var(--space-xxl);
  }
  
  .control-panel {
    max-width: 450px;
  }
  
  .earth-container {
    height: 600px;
  }
  
  .chart-container {
    height: 400px;
  }
  
  .example-locations {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-sm);
  }
  
  .example-btn {
    padding: var(--space-sm);
    font-size: 13px;
    white-space: normal;
    line-height: 1.3;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  }
  
  .app-title {
    font-size: 32px;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .icon {
    stroke-width: 1.5;
  }
}

/* Print styles */
@media print {
  .app-header,
  .earth-container,
  .chart-container,
  .app-footer {
    display: none;
  }
  
  .main-content {
    display: block;
  }
  
  .card {
    break-inside: avoid;
  }
}