/* ============================================
   INVESTMENT CALCULATOR STYLES
   ============================================ */

:root {
  --primary-gradient: linear-gradient(135deg, #C9A84C 0%, #b89636 100%);
  --secondary-gradient: linear-gradient(135deg, #8B0000 0%, #ca3131 100%);
  --success-gradient: linear-gradient(135deg, #1A4A1A 0%, #2f992f 100%);
  --warning-gradient: linear-gradient(135deg, #E5C97A 0%, #E5C97A 100%);
  --dark-bg:  #1A4A1A;
  --dark-card:  #1A4A1A;
  --dark-text: #f1f5f9;
  --light-bg:  #C9A84C;
  --light-card:  #E5C97A;;
  --light-text:  #1A4A1A;
  --border-color:  #E5C97A;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.16);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 6px;
}

/* Tab Navigation */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin: 4px 0 3px;
  background: white;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

body.dark-mode .tabs {
  background: var(--dark-card);
}

.tab-btn {
  flex: 1;
  max-width: 250px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--light-text);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  white-space: nowrap;
}

body.dark-mode .tab-btn {
  color: var(--dark-text);
}

.tab-btn:hover {
  background: #f1f5f9;
  transform: translateY(-2px);
}

body.dark-mode .tab-btn:hover {
  background: #334155;
}

.tab-btn.active {
  background: var(--primary-gradient);
  color: white;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Calculator Sections */
.calculator-section {
  display: none;
  animation: fadeIn 0.5s ease;
  width: 100%;
}

.calculator-section.active {
  display: block;
  width: 100%;
}

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

/* Main Grid Layout */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 2px;
  width: 100%;
  align-content: start;
}

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

@media (min-width: 1200px) {
  .calc-grid {
    gap: 14px;
  }
}

/* Card Styles */
.card {
  background: white;
  padding: 10px;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  width: 100%;
}

body.dark-mode .card {
  background: var(--dark-card);
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border-color);
  flex-shrink: 0;
}

.card-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: white;
  flex-shrink: 0;
}

.card-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--light-text);
  line-height: 1.2;
}

body.dark-mode .card-title {
  color: var(--dark-text);
}

/* Input Groups */
.input-group {
  margin-bottom: 8px;
  flex-shrink: 0;
}

label {
  display: block;
  margin-bottom: 2px;
  font-weight: 600;
  color: var(--light-text);
  font-size: 0.7rem;
  line-height: 1.3;
}

body.dark-mode label {
  color: var(--dark-text);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix,
.input-suffix {
  position: absolute;
  font-weight: 600;
  color: #64748b;
  font-size: 0.75rem;
  pointer-events: none;
}

.input-prefix {
  left: 12px;
}

.input-suffix {
  right: 12px;
}

input[type="number"],
input[type="range"] {
  width: 100%;
  padding: 6px 22px;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.75rem;
  transition: all 0.3s ease;
  background: white;
  color: var(--light-text);
}

body.dark-mode input[type="number"] {
  background: var(--dark-bg);
  border-color: #475569;
  color: var(--dark-text);
}

input[type="number"]:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

input[type="range"] {
  padding: 0;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

input[type="range"]::-webkit-slider-track {
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  height: 5px;
  border-radius: 5px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary-gradient);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  margin-top: -6px;
}

input[type="range"]::-moz-range-track {
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  height: 5px;
  border-radius: 5px;
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary-gradient);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  border: none;
}

/* Buttons */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
  flex-shrink: 0;
}

.btn {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  align-items: center;
  gap: 4px;
}

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

.btn-secondary {
  background: #e2e8f0;
  color: var(--light-text);
}

body.dark-mode .btn-secondary {
  background: #475569;
  color: var(--dark-text);
}

.btn-success {
  background: var(--success-gradient);
  color: white;
}

.btn-warning {
  background: var(--warning-gradient);
  color: white;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

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

/* Result Cards */
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 6px;
  margin-top: 8px;
  flex-shrink: 0;
}

.result-card {
  background: white;
  padding: 8px;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  text-align: center;
  transition: all 0.3s ease;
  border-left: 4px solid #667eea;
}

body.dark-mode .result-card {
  background: var(--dark-card);
}

.result-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.result-card.primary {
  border-left-color: #667eea;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

.result-card.success {
  border-left-color: #4facfe;
  background: linear-gradient(135deg, rgba(79, 172, 254, 0.1) 0%, rgba(0, 242, 254, 0.1) 100%);
}

.result-card.warning {
  border-left-color: var(--light-text);
}

.result-label {
  font-size: 0.65rem;
  color: #64748b;
  margin-bottom: 2px;
  font-weight: 600;
}

.result-value {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--light-text);
  word-wrap: break-word;
  line-height: 1.2;
}

body.dark-mode .result-value {
  color: var(--dark-text);
}

/* Charts */
.chart-container {
  background: white;
  padding: 10px;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  margin-top: 8px;
  flex-shrink: 0;
}

body.dark-mode .chart-container {
  background: var(--dark-card);
}

.chart-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

@media (max-width: 768px) {
  .chart-grid {
    grid-template-columns: 1fr;
  }
}

.chart-wrapper {
  position: relative;
  height: 200px;
  min-height: 140px;
}

/* Table */
.table-container {
  background: white;
  padding: 10px;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  margin-top: 8px;
  overflow-x: auto;
  flex-shrink: 0;
  max-height: 20vh;
  overflow-y: auto;
}

body.dark-mode .table-container {
  background: var(--dark-card);
}

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

th,
td {
  padding: 7px 9px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  background: var(--primary-gradient);
  color: white;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.2px;
}

body.dark-mode th {
  background: linear-gradient(135deg, #4c1d95 0%, #581c87 100%);
}

tbody tr {
  transition: background 0.3s ease;
}

tbody tr:hover {
  background: rgba(102, 126, 234, 0.05);
}

body.dark-mode tbody tr:hover {
  background: rgba(102, 126, 234, 0.1);
}

/* Tooltip */
.tooltip {
  position: relative;
  display: inline-block;
  cursor: help;
}

.tooltip-text {
  visibility: hidden;
  width: 180px;
  background: #1e293b;
  color: white;
  text-align: center;
  border-radius: 6px;
  padding: 5px;
  position: absolute;
  z-index: 100;
  bottom: 125%;
  left: 50%;
  margin-left: -90px;
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 0.7rem;
  font-weight: normal;
  box-shadow: var(--shadow-lg);
}

.tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}


.disclaimer {
  max-width: 800px;
  margin: 0 auto;
  font-size: 0.75rem;
  opacity: 0.8;
  line-height: 1.5;
}

.disclaimer strong {
  color: #fa709a;
}

/* Responsive */
@media (max-width: 768px) {
  h1 {
    font-size: 1.15rem;
  }

  .subtitle {
    font-size: 0.7rem;
  }

  .tabs {
    flex-direction: column;
  }

  .tab-btn {
    min-width: 100%;
    padding: 7px;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .btn-group {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

  .chart-wrapper {
    height: 180px;
  }

  .theme-toggle {
    position: relative;
    top: 0;
    right: 0;
    margin-bottom: 6px;
  }

  .card {
    padding: 8px;
  }

  .card-header {
    margin-bottom: 6px;
    padding-bottom: 5px;
  }

  .card-title {
    font-size: 0.85rem;
  }

  .input-group {
    margin-bottom: 8px;
  }

  .result-value {
    font-size: 0.95rem;
  }
}

/* Loading Animation */
.loading {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Print Styles */
@media print {
  .no-print {
    display: none !important;
  }

  body {
    background: white;
  }

  .card,
  .chart-container,
  .table-container {
    box-shadow: none;
    border: 1px solid #e2e8f0;
  }
}

/* Range Input Labels */
.range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 0.7rem;
  color: #64748b;
}

/* SWP Phase Tabs */
.phase-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  width: 100%;
}

.phase-content {
  display: none;
  width: 100%;
}

.phase-content.active {
  display: block;
}

.phase-tab {
  flex: 1;
  padding: 8px;
  border: 2px solid var(--border-color);
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
}

body.dark-mode .phase-tab {
  background: var(--dark-bg);
  border-color: #475569;
}

.phase-tab.active {
  background: var(--primary-gradient);
  color: white;
  border-color: transparent;
}

/* Radio Group */
.radio-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: white;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  flex: 1;
  min-width: 140px;
  transition: all 0.3s ease;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--light-text);
}

body.dark-mode .radio-label {
  background: var(--dark-bg);
  border-color: #475569;
}

.radio-label:hover {
  border-color: #667eea;
  transform: translateY(-1px);
}

.radio-label:has(input[type="radio"]:checked) {
  background: var(--primary-gradient);
  color: white;
  border-color: transparent;
}

.radio-label input[type="radio"] {
  width: auto;
  margin: 0;
  cursor: pointer;
  accent-color: #667eea;
}

/* Info Box */
.info-box {
  background: #dbeafe;
  border-left: 4px solid #3b82f6;
  padding: 8px;
  border-radius: 6px;
  margin-top: 10px;
  font-size: 0.75rem;
}

body.dark-mode .info-box {
  background: #1e3a8a;
  border-left-color: #60a5fa;
}

.info-box strong {
  color: #1d4ed8;
}

body.dark-mode .info-box strong {
  color: #93c5fd;
}