/* ===== Social Battery - Real-Time Dashboard =====
   Primary: #F59E0B (Amber)
   Dark mode first, Glassmorphism 2.0 ===== */

:root {
  --primary: #F59E0B;
  --primary-dark: #D97706;
  --primary-light: #FBBF24;
  --primary-glow: rgba(245, 158, 11, 0.35);
  --bg: #0a0e1a;
  --bg-2: #0d1220;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-hover: rgba(255, 255, 255, 0.10);
  --border: rgba(255, 255, 255, 0.10);
  --border-focus: rgba(245, 158, 11, 0.5);
  --text: #e8edf5;
  --text-muted: rgba(232, 237, 245, 0.55);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --glass: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.08);
  --battery-red: #EF4444;
  --battery-orange: #F97316;
  --battery-yellow: #FBBF24;
  --battery-green: #22C55E;
  --charge-color: #22C55E;
  --drain-color: #EF4444;
}

[data-theme="light"] {
  --bg: #FFFBEB;
  --bg-2: #FEF3C7;
  --surface: rgba(255, 255, 255, 0.75);
  --surface-hover: rgba(255, 255, 255, 0.92);
  --border: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(245, 158, 11, 0.6);
  --text: #1a2332;
  --text-muted: rgba(26, 35, 50, 0.55);
  --glass: rgba(255, 255, 255, 0.6);
  --glass-border: rgba(0, 0, 0, 0.07);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
}

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(245, 158, 11, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(251, 191, 36, 0.08) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ===== Skip Link ===== */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary);
  color: #000;
  padding: 8px 16px;
  z-index: 999;
  border-radius: 0 0 8px 0;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 0; }

/* ===== App Loader ===== */
.app-loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.4s, visibility 0.4s;
  gap: 16px;
}
.app-loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-emoji { font-size: 3rem; animation: pulse 1.2s ease-in-out infinite; }
.loader-spinner {
  width: 48px; height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.15); } }

/* ===== Container ===== */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px 40px;
  position: relative;
  z-index: 1;
}

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.app-title {
  font-size: 1.3rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.app-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.header-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  position: relative;
}
.icon-btn {
  width: 44px; height: 44px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: var(--text);
}
.icon-btn:hover { background: var(--surface-hover); border-color: var(--border-focus); }

/* ===== Language Menu ===== */
.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  z-index: 100;
  min-width: 160px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.lang-menu.hidden { display: none; }
.lang-option {
  padding: 7px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text);
  text-align: left;
  transition: all 0.15s;
  white-space: nowrap;
}
.lang-option:hover { background: var(--surface-hover); border-color: var(--border); }
.lang-option.active { background: var(--primary-glow); border-color: var(--primary); color: var(--primary); }

/* ===== Screens ===== */
.screen { display: none; }
.screen.active { display: block; animation: fadeInUp 0.35s ease; }

/* ===== Start Screen ===== */
.start-hero {
  text-align: center;
  padding: 32px 0 24px;
}
.hero-icon {
  font-size: 4rem;
  margin-bottom: 12px;
  display: block;
  filter: drop-shadow(0 0 20px rgba(245, 158, 11, 0.5));
}
.hero-badge {
  display: inline-block;
  background: var(--primary-glow);
  color: var(--primary);
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.hero-title {
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--primary-light), #F97316);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
}
.hero-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 360px;
  margin: 0 auto 24px;
}

.info-strip {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.info-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 7px 16px;
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.types-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 28px;
}
.type-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  transition: all 0.2s;
  backdrop-filter: blur(12px);
}
.type-card:hover {
  background: var(--surface-hover);
  transform: translateY(-2px);
}
.type-icon { font-size: 1.6rem; margin-bottom: 8px; }
.type-name { font-size: 0.9rem; font-weight: 700; margin-bottom: 4px; }
.type-range { font-size: 0.77rem; color: var(--text-muted); }

.type-card[data-type="solar"] .type-name { color: var(--battery-green); }
.type-card[data-type="rechargeable"] .type-name { color: var(--battery-yellow); }
.type-card[data-type="saver"] .type-name { color: var(--battery-orange); }
.type-card[data-type="emergency"] .type-name { color: var(--battery-red); }

.disclaimer {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  padding: 10px 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  min-height: 52px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #000;
  box-shadow: 0 4px 20px var(--primary-glow);
  width: 100%;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px var(--primary-glow);
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ======================================
   BATTERY DASHBOARD (New Mechanic)
   ====================================== */

.dashboard-battery {
  text-align: center;
  margin-bottom: 16px;
  position: relative;
}

.dash-battery-wrap {
  display: inline-block;
  position: relative;
}

.dash-battery-cap {
  width: 40px;
  height: 12px;
  background: var(--border);
  border-radius: 4px 4px 0 0;
  margin: 0 auto;
  transition: background 0.5s;
}

.dash-battery-body {
  width: 100px;
  height: 160px;
  border: 3px solid var(--border);
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  background: var(--surface);
  transition: border-color 0.5s;
}

.dash-battery-fill {
  position: absolute;
  bottom: 3px;
  left: 3px;
  right: 3px;
  height: 50%;
  border-radius: 5px;
  background: linear-gradient(to top, var(--battery-yellow), var(--primary-light));
  transition: height 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.5s;
}

.dash-battery-fill::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 16px,
    rgba(255, 255, 255, 0.06) 16px,
    rgba(255, 255, 255, 0.06) 18px
  );
}

.dash-battery-percent {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  z-index: 2;
}

/* Battery color states */
.dash-battery-fill.level-critical { background: linear-gradient(to top, #DC2626, #EF4444); }
.dash-battery-fill.level-low { background: linear-gradient(to top, #EA580C, #F97316); }
.dash-battery-fill.level-medium { background: linear-gradient(to top, #D97706, #FBBF24); }
.dash-battery-fill.level-high { background: linear-gradient(to top, #16A34A, #22C55E); }

.dash-battery-body.level-critical { border-color: var(--battery-red); }
.dash-battery-body.level-low { border-color: var(--battery-orange); }
.dash-battery-body.level-medium { border-color: var(--battery-yellow); }
.dash-battery-body.level-high { border-color: var(--battery-green); }

.dash-battery-cap.level-critical { background: var(--battery-red); }
.dash-battery-cap.level-low { background: var(--battery-orange); }
.dash-battery-cap.level-medium { background: var(--battery-yellow); }
.dash-battery-cap.level-high { background: var(--battery-green); }

/* Floating text animation */
.float-container {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 160px;
  pointer-events: none;
  z-index: 10;
}

.float-text {
  position: absolute;
  font-size: 1.2rem;
  font-weight: 800;
  animation: floatUp 1s ease-out forwards;
  white-space: nowrap;
}

.float-text.charge {
  color: var(--charge-color);
  left: 60%;
}

.float-text.drain {
  color: var(--drain-color);
  left: 60%;
}

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(60px); }
  100% { opacity: 0; transform: translateY(-20px); }
}

/* Battery pulse on change */
.dash-battery-body.pulse-charge {
  animation: pulseCharge 0.4s ease;
}

.dash-battery-body.pulse-drain {
  animation: pulseDrain 0.4s ease;
}

@keyframes pulseCharge {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
  50% { box-shadow: 0 0 20px 4px rgba(34, 197, 94, 0.4); }
}

@keyframes pulseDrain {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
  50% { box-shadow: 0 0 20px 4px rgba(239, 68, 68, 0.4); }
}

/* Progress dots */
.dash-progress {
  text-align: center;
  margin-bottom: 16px;
}

.dash-progress span {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Scenario card */
.scenario-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 20px;
  backdrop-filter: blur(12px);
  transition: all 0.3s ease;
}

.scenario-card.entering {
  animation: cardSlideIn 0.35s ease;
}

@keyframes cardSlideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

.scenario-emoji {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.scenario-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.scenario-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Choice buttons */
.choice-buttons {
  display: flex;
  gap: 12px;
}

.choice-btn {
  flex: 1;
  padding: 16px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  min-height: 56px;
  background: var(--surface);
  color: var(--text);
}

.choice-charge {
  border-color: rgba(34, 197, 94, 0.3);
}

.choice-charge:hover {
  background: rgba(34, 197, 94, 0.15);
  border-color: var(--charge-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(34, 197, 94, 0.3);
}

.choice-charge:active {
  transform: translateY(0);
  background: rgba(34, 197, 94, 0.25);
}

.choice-drain {
  border-color: rgba(239, 68, 68, 0.3);
}

.choice-drain:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--drain-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3);
}

.choice-drain:active {
  transform: translateY(0);
  background: rgba(239, 68, 68, 0.25);
}

.choice-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* ===== Result Screen ===== */
.result-hero {
  text-align: center;
  padding: 28px 0 20px;
}

.battery-container {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}
.battery-visual {
  position: relative;
  width: 140px;
  height: 240px;
}
.battery-body {
  position: absolute;
  bottom: 0;
  left: 10px;
  width: 120px;
  height: 220px;
  border: 4px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}
.battery-cap {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 14px;
  background: var(--border);
  border-radius: 4px 4px 0 0;
}
.battery-fill-area {
  position: absolute;
  bottom: 4px;
  left: 4px;
  right: 4px;
  height: 0%;
  border-radius: 6px;
  transition: height 1.8s cubic-bezier(0.4, 0, 0.2, 1), background 0.5s;
  overflow: hidden;
}
.battery-fill-area::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 20px,
    rgba(255, 255, 255, 0.08) 20px,
    rgba(255, 255, 255, 0.08) 22px
  );
}
.battery-fill-area.charging {
  animation: batteryPulse 2s ease-in-out infinite alternate;
}
@keyframes batteryPulse {
  from { opacity: 0.85; }
  to { opacity: 1; }
}
.battery-percent {
  position: absolute;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2.2rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  z-index: 2;
}
.battery-bolt {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2rem;
  z-index: 2;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.5));
}

.battery-fill-area.level-critical { background: linear-gradient(to top, #DC2626, #EF4444); }
.battery-fill-area.level-low { background: linear-gradient(to top, #EA580C, #F97316); }
.battery-fill-area.level-medium { background: linear-gradient(to top, #D97706, #FBBF24); }
.battery-fill-area.level-high { background: linear-gradient(to top, #16A34A, #22C55E); }

.battery-body.level-critical { border-color: var(--battery-red); }
.battery-body.level-low { border-color: var(--battery-orange); }
.battery-body.level-medium { border-color: var(--battery-yellow); }
.battery-body.level-high { border-color: var(--battery-green); }

.battery-cap.level-critical { background: var(--battery-red); }
.battery-cap.level-low { background: var(--battery-orange); }
.battery-cap.level-medium { background: var(--battery-yellow); }
.battery-cap.level-high { background: var(--battery-green); }

.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: 30px;
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 12px;
  box-shadow: 0 4px 20px var(--primary-glow);
}
.type-badge.level-critical { background: linear-gradient(135deg, #DC2626, #EF4444); color: #fff; }
.type-badge.level-low { background: linear-gradient(135deg, #EA580C, #F97316); color: #fff; }
.type-badge.level-medium { background: linear-gradient(135deg, #D97706, #FBBF24); color: #000; }
.type-badge.level-high { background: linear-gradient(135deg, #16A34A, #22C55E); color: #fff; }

.type-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 400px;
  margin: 0 auto 24px;
  line-height: 1.6;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.detail-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 28px;
}
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  backdrop-filter: blur(12px);
}
.detail-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.detail-card-icon { font-size: 1.1rem; }
.detail-card-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}
.detail-card-value {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
}

.compatible-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.compatible-tag {
  padding: 6px 14px;
  background: var(--primary-glow);
  border: 1px solid var(--primary);
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
}

.share-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.share-btn {
  flex: 1;
  min-width: 120px;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
}
.share-btn:hover { background: var(--surface-hover); transform: translateY(-1px); }
.share-btn.twitter { background: #000; color: #fff; border-color: #000; }
.share-btn.twitter:hover { background: #1a1a1a; }

#cross-promo-container { margin-top: 32px; }

/* ===== Responsive ===== */
@media (max-width: 400px) {
  .types-grid { grid-template-columns: 1fr; }
  .hero-title { font-size: 1.5rem; }
  .battery-visual { width: 110px; height: 200px; }
  .battery-body { width: 100px; height: 180px; left: 5px; }
  .battery-percent { font-size: 1.8rem; }
  .dash-battery-body { width: 80px; height: 130px; }
  .dash-battery-cap { width: 32px; }
  .dash-battery-percent { font-size: 1.3rem; }
  .choice-btn { font-size: 0.85rem; padding: 14px 8px; }
}

/* ===== Animations ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .screen.active { animation: none; }
  .battery-fill-area { transition: none; }
  .dash-battery-fill { transition: none; }
}
