/* Component styles — profile, rates, CSV, summary, result, exports, collapsible, buttons */

/* ═══ PROFILE BAR ═══ */

.profile-bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  padding: var(--space-sm) 0;
}

.profile-select {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--form-text);
  font-size: var(--text-sm);
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--duration-fast);
}

.profile-select:focus {
  border-color: var(--siemens-teal);
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 153, 153, 0.15);
}

/* ═══ SMALL ICON BUTTONS ═══ */

.btn-icon-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--container-bg);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: all var(--duration-fast);
}

.btn-icon-sm:hover {
  background: var(--section-hover);
  color: var(--text-color);
  border-color: var(--border-strong);
}

.btn-icon-success {
  color: #28a745;
  border-color: rgba(40, 167, 69, 0.3);
}

.btn-icon-success:hover {
  background: rgba(40, 167, 69, 0.1);
  color: #28a745;
  border-color: #28a745;
}

.btn-icon-danger {
  color: #dc3545;
  border-color: rgba(220, 53, 69, 0.3);
}

.btn-icon-danger:hover {
  background: rgba(220, 53, 69, 0.1);
  color: #dc3545;
  border-color: #dc3545;
}

/* ═══ RATE ROW + PRESETS ═══ */

.rate-row {
  display: flex;
  align-items: flex-end;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.preset-controls {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;
}

.preset-select {
  padding: 8px 10px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--form-text);
  font-size: var(--text-sm);
  font-family: inherit;
  min-width: 100px;
  max-width: 140px;
  cursor: pointer;
}

.preset-select:focus {
  border-color: var(--siemens-teal);
  outline: none;
}

/* ═══ TIERED RATES ═══ */

.tier-toggle {
  margin-bottom: var(--space-md);
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  user-select: none;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

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

.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  background: var(--border-strong);
  border-radius: 11px;
  flex-shrink: 0;
  transition: background var(--duration-fast);
}

.toggle-input:focus-visible + .toggle-switch {
  outline: 2px solid var(--siemens-teal);
  outline-offset: 2px;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--duration-fast);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-input:checked + .toggle-switch {
  background: var(--siemens-teal);
}

.toggle-input:checked + .toggle-switch::after {
  transform: translateX(18px);
}

.toggle-text {
  font-weight: 500;
}

.tier-fields {
  display: none;
  padding-top: var(--space-sm);
}

/* Show tier fields when JS enables the inputs (updateTierInputsState) */
.tier-fields:has(input:not(:disabled)) {
  display: block;
}

/* Fallback: show class for browsers without :has() support */
.tier-fields.show {
  display: block;
}

/* ═══ ADDITIONAL CHARGES ═══ */

.additional-charges-fields {
  display: none;
  padding-top: var(--space-sm);
}

.additional-charges-fields.show {
  display: block;
}

.additional-charge-row {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  margin-bottom: var(--space-sm);
}

.additional-charge-row .charge-name {
  flex: 2;
}

.additional-charge-row .charge-amount {
  flex: 1;
}

.additional-charge-row .btn-icon-sm {
  flex-shrink: 0;
}

/* ═══ SECTION ACTIONS ═══ */

.section-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border-color);
}

/* ═══ TEXT BUTTONS ═══ */

.btn-text {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast);
}

.btn-text:hover {
  background: var(--section-hover);
  color: var(--text-color);
}

.btn-text-warning {
  color: #e67700;
}

.btn-text-warning:hover {
  background: rgba(230, 119, 0, 0.08);
  color: #cc6a00;
}

.btn-text-small {
  font-size: var(--text-xs);
  padding: 4px 8px;
}

/* ═══ CSV ROW ═══ */

.csv-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.csv-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--form-text);
  font-size: var(--text-sm);
  font-family: inherit;
  min-width: 0;
}

.csv-input::file-selector-button {
  padding: 4px 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--section-hover);
  color: var(--text-color);
  font-size: var(--text-xs);
  cursor: pointer;
  margin-right: var(--space-sm);
}

.btn-sm-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--container-bg);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--duration-fast);
}

.btn-sm-action:hover {
  background: var(--section-hover);
  color: var(--text-color);
  border-color: var(--border-strong);
}

.btn-sm-primary {
  background: var(--siemens-teal);
  color: #fff;
  border-color: var(--siemens-teal);
}

.btn-sm-primary:hover {
  background: var(--siemens-teal-dark);
  border-color: var(--siemens-teal-dark);
  color: #fff;
}

/* ═══ KWH CONTAINER ═══ */

.kwh-container {
  max-height: 420px;
  overflow-y: auto;
  overflow-x: hidden;
  display: none;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.35s var(--ease-out),
              transform 0.35s var(--ease-out);
}

.kwh-container.show {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* Scrollbar styling */
.kwh-container::-webkit-scrollbar {
  width: 6px;
}

.kwh-container::-webkit-scrollbar-track {
  background: transparent;
}

.kwh-container::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

/* ═══ SUMMARY INLINE ═══ */

.summary-inline {
  display: none;
  margin-bottom: var(--space-md);
}

.summary-inline.show {
  display: block;
}

.summary-stats-row {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.stat-chip {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px;
  background: var(--section-hover);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  transition: background var(--duration-fast);
}

.stat-chip-value {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-color);
  line-height: 1.2;
}

.stat-chip-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.progress-text {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}

.progress-track {
  flex: 1;
  height: 6px;
  background: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
}

.progress-track .progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--siemens-teal), #28a745);
  border-radius: 3px;
  transition: width 0.6s var(--ease-out);
}

/* Bootstrap .progress compatibility inside summary */
.progress {
  background-color: var(--border-color);
  border-radius: 3px;
}

body.dark-mode .progress {
  background-color: var(--border-strong);
}

/* ═══ HERO RESULT ═══ */

.hero-result {
  display: none;
  text-align: center;
  padding: var(--space-lg) var(--space-md);
  margin-bottom: var(--space-md);
  background: linear-gradient(135deg, var(--siemens-teal-subtle), transparent);
  border-radius: var(--radius-md);
  border: 2px solid rgba(0, 153, 153, 0.2);
}

.hero-result.show {
  display: block;
}

.hero-amount {
  font-size: var(--text-hero);
  font-weight: 800;
  color: var(--siemens-teal);
  letter-spacing: -0.02em;
}

/* ═══ PRIMARY CTA ═══ */

.btn-primary-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  padding: 14px var(--space-lg);
  border: none;
  border-radius: var(--radius-md);
  background: var(--siemens-teal);
  color: #fff;
  font-size: var(--text-base);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--duration-fast),
              transform var(--duration-fast),
              box-shadow var(--duration-fast);
  box-shadow: 0 2px 8px rgba(0, 153, 153, 0.25);
}

.btn-primary-cta:hover {
  background: var(--siemens-teal-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 153, 153, 0.3);
}

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

/* Loading state on CTA (applied by showButtonLoading) */
.btn-primary-cta:disabled,
.btn-primary-cta.disabled {
  opacity: 0.7;
  cursor: wait;
}

/* ═══ EXPORT BUTTONS ═══ */

.export-row {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.btn-export {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--container-bg);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.btn-export:hover {
  background: var(--section-hover);
  color: var(--text-color);
  border-color: var(--border-strong);
}

/* ═══ COLLAPSIBLE SECTIONS (details/summary) ═══ */

.section-collapsible {
  display: none;
}

.section-collapsible.show {
  display: block;
}

.collapsible-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0;
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-color);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.collapsible-header::-webkit-details-marker {
  display: none;
}

.collapsible-header::marker {
  content: '';
}

.collapsible-chevron {
  margin-left: auto;
  font-size: var(--text-sm);
  color: var(--text-muted);
  transition: transform var(--duration-normal) var(--ease-out);
}

details[open] > .collapsible-header .collapsible-chevron {
  transform: rotate(180deg);
}

.collapsible-body {
  padding-top: var(--space-md);
}

.collapsible-actions {
  margin-bottom: var(--space-sm);
  display: flex;
  justify-content: flex-end;
}

/* ═══ HISTORY ITEMS ═══ */

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--section-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: border-color var(--duration-fast);
}

.history-item:hover {
  border-color: var(--siemens-teal);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.history-label {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-color);
}

.history-meta {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.history-period {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: -4px;
}

.history-breakdown {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-line {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.history-line-charge {
  padding-left: 8px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.history-line-total {
  font-weight: 600;
  color: var(--text-color);
  border-top: 1px solid var(--border-color);
  padding-top: 4px;
  margin-top: 2px;
}

.history-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ═══ EV IMPACT STATS ═══ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.stat-card {
  text-align: center;
  padding: 16px;
  background: var(--section-hover);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  transition: border-color var(--duration-fast);
}

.stat-card:hover {
  border-color: var(--siemens-teal);
}

.stat-icon {
  font-size: 1.3rem;
  color: var(--siemens-teal);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--siemens-teal);
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: 2px;
}

.stat-detail {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

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

/* ═══ TREND INSIGHT ═══ */

.trend-insight {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-sm);
}

/* ═══ STORAGE INDICATOR ═══ */

.storage-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  padding: 2px 8px;
  background: var(--section-hover);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

.storage-indicator i {
  font-size: 0.65rem;
}

.storage-clear-btn {
  margin-left: 4px;
  padding: 0 6px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  border-left: 1px solid var(--border-color);
  transition: color var(--duration-fast);
}

.storage-clear-btn:hover {
  color: #dc3545;
}

/* ═══ LOADING SPINNER ═══ */

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  text-align: center;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border-color);
  border-top-color: var(--siemens-teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 10px;
}

.loading-text {
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
}

/* ═══ STAR RATING ═══ */

.star-rating {
  display: flex;
  gap: 4px;
  font-size: 1.8rem;
  margin-top: 8px;
}

.star {
  color: var(--border-strong);
  cursor: pointer;
  transition: color var(--duration-fast), transform 0.1s;
  user-select: none;
}

.star:hover {
  transform: scale(1.1);
}

.star.active {
  color: #ffc107;
}

.star.hover {
  color: #ffdb4a;
}

body.dark-mode .star {
  color: var(--border-strong);
}

body.dark-mode .star.active {
  color: #ffc107;
}

/* ═══ ALERTS (from JS) ═══ */

.alert {
  border-radius: var(--radius-sm);
}

/* ═══ DARK MODE SPECIFICS ═══ */

body.dark-mode .csv-input::file-selector-button {
  background: var(--border-strong);
  color: var(--text-color);
  border-color: var(--border-color);
}

body.dark-mode .stat-chip {
  background: var(--pre-bg);
  border-color: var(--border-color);
}

body.dark-mode .history-item {
  background: var(--pre-bg);
  border-color: var(--border-color);
}

body.dark-mode .modal-footer small {
  color: var(--text-muted);
}

body.dark-mode .modal-footer strong {
  color: var(--text-color);
}

/* ═══ RESULT TEXT (old .result class used by JS) ═══ */
.result {
  font-size: 1.5rem;
  font-weight: bold;
  color: #28a745;
}

/* ═══ PWA INSTALL BANNER ═══ */

.pwa-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1060;
  transform: translateY(100%);
  transition: transform 0.4s var(--ease-out);
}

.pwa-banner.show {
  transform: translateY(0);
}

.pwa-banner-inner {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-sm) var(--space-md);
  background: var(--container-bg);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

.pwa-banner-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.pwa-banner-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.pwa-banner-text strong {
  font-size: var(--text-sm);
  color: var(--text-color);
}

.pwa-banner-text small {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.pwa-banner-btn {
  flex-shrink: 0;
  padding: 8px 16px;
  background: var(--siemens-teal);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration-fast);
}

.pwa-banner-btn:hover {
  background: var(--siemens-teal-dark);
}

.pwa-banner-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.pwa-banner-dismiss:hover {
  color: var(--text-color);
}

body.dark-mode .pwa-banner-inner {
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

/* ═══ iOS INSTALL OVERLAY ═══ */

.ios-install-overlay {
  position: fixed;
  inset: 0;
  z-index: 1070;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.ios-install-overlay.show {
  opacity: 1;
}

.ios-install-card {
  position: relative;
  background: var(--container-bg);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-lg) var(--space-md);
  margin: var(--space-md);
  max-width: 340px;
  width: 100%;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
  transform: translateY(20px);
  transition: transform 0.3s var(--ease-out);
}

.ios-install-overlay.show .ios-install-card {
  transform: translateY(0);
}

.ios-install-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.ios-install-close:hover {
  color: var(--text-color);
}

.ios-install-card h3 {
  margin: 0 0 var(--space-md);
  font-size: var(--text-lg);
  color: var(--text-color);
  text-align: center;
}

.ios-install-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: ios-step;
}

.ios-install-steps li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  font-size: var(--text-sm);
  color: var(--text-color);
  line-height: 1.5;
}

.ios-install-steps li + li {
  border-top: 1px solid var(--border-color);
}

.ios-step-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--siemens-teal);
  color: white;
}

body.dark-mode .ios-install-card {
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}
