/* ==========================================================================
   UPLITH MOBILE PWA - CORE APP STYLES
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

input, button, textarea, select {
  font-family: inherit;
  user-select: auto;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-obsidian);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Poppins for Headers & Hero Financial Metrics */
h1, h2, h3, h4, h5, h6, .font-heading, .metric-value, .hero-num, .lhdn-code {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Background Atmosphere Glow */
.app-bg-glow {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 280px;
  background: radial-gradient(circle at 50% -40px, rgba(59, 130, 246, 0.18), rgba(16, 185, 129, 0.05) 50%, transparent 80%);
  pointer-events: none;
  z-index: 0;
}

/* Desktop Preview / Responsive Outer Container */
.desktop-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  width: 100vw;
  background: var(--shell-outer-bg);
  position: relative;
  transition: background var(--transition-normal);
}

/* Device Shell */
.app-container {
  width: 100%;
  max-width: 440px;
  height: 100vh;
  max-height: 100vh;
  background-color: var(--bg-obsidian);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-elevated);
  transition: background-color var(--transition-normal);
}

@media (min-width: 768px) {
  .app-container {
    height: 92vh;
    max-height: 920px;
    border-radius: 40px;
    border: 8px solid var(--device-border);
  }
}

/* Top App Header */
.app-header {
  position: relative;
  z-index: 10;
  padding: calc(var(--sat) + 10px) 12px 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-normal), border-color var(--transition-normal);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-logo-icon {
  width: 34px;
  height: 34px;
  background: var(--bg-card);
  border-radius: 10px;
  padding: 4px;
  border: 1px solid rgba(59, 130, 246, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
}

.brand-logo-icon svg {
  width: 22px;
  height: 22px;
}

.brand-meta {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
  background: none;
  -webkit-text-fill-color: var(--text-main);
  line-height: 1.1;
}

.brand-subtitle {
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 3.5px;
  flex-shrink: 0;
}

.pwa-install-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--accent-blue-bg);
  border: 1px solid var(--border-glow-blue);
  color: var(--accent-blue);
  font-size: 10px;
  font-weight: 600;
  padding: 3.5px 6.5px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pwa-install-badge:hover {
  background: rgba(37, 99, 235, 0.18);
  transform: translateY(-1px);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3.5px 6.5px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  background: var(--accent-green-bg);
  color: var(--accent-green);
  border: 1px solid rgba(5, 150, 105, 0.25);
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
  animation: pulseAnim 2s infinite;
}

@keyframes pulseAnim {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 12px var(--accent-green); }
  100% { transform: scale(0.9); opacity: 0.8; }
}

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

/* Segmented Top Quick Filter / Mode Switcher */
.quick-mode-bar {
  display: flex;
  gap: 6px;
  padding: 8px 16px 4px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  z-index: 5;
}
.quick-mode-bar::-webkit-scrollbar { display: none; }

.quick-mode-pill {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.quick-mode-pill.active {
  background: var(--accent-blue);
  color: #ffffff;
  border-color: var(--accent-blue);
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.35);
}

/* Main Content Area */
.app-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 16px calc(var(--sab) + 84px) 16px;
  position: relative;
  z-index: 1;
  -webkit-overflow-scrolling: touch;
}

/* Custom Minimal Scrollbar */
.app-content::-webkit-scrollbar {
  width: 4px;
}
.app-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* Screens / Module Views */
.screen-view {
  display: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.screen-view.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* Bottom Navigation Bar */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  padding: 8px 12px calc(var(--sab) + 8px) 12px;
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  transition: background var(--transition-normal), border-color var(--transition-normal);
}

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  font-size: 10.5px;
  font-weight: 600;
  background: var(--bg-surface-active);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.theme-toggle-btn:hover {
  transform: translateY(-1px);
  background: var(--bg-surface-subtle);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 2px 4px 2px;
  border-radius: 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  transition: transform var(--transition-spring), stroke var(--transition-fast);
}

.nav-item span {
  font-size: 10px;
  font-weight: 600;
  margin-top: 3px;
  letter-spacing: -0.01em;
  transition: color var(--transition-fast);
}

.nav-item.active {
  color: var(--text-main);
}

.nav-item.active svg {
  stroke: var(--accent-blue);
  transform: scale(1.12);
  filter: drop-shadow(0 0 6px var(--border-glow-blue));
}

.nav-item.active span {
  color: var(--text-main);
  font-weight: 700;
}

.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 1px;
  width: 14px;
  height: 3px;
  background: var(--accent-blue);
  border-radius: 3px;
  box-shadow: 0 0 8px var(--accent-blue);
}

/* Card Containers */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 7px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-title svg {
  width: 16px;
  height: 16px;
  stroke: var(--accent-blue);
}

.card-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.card-badge.green {
  background: var(--accent-green-bg);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.card-badge.orange {
  background: var(--accent-orange-bg);
  color: var(--accent-orange);
  border: 1px solid rgba(249, 115, 22, 0.25);
}

.card-badge.pink {
  background: var(--accent-pink-bg);
  color: var(--accent-pink);
  border: 1px solid rgba(236, 72, 153, 0.25);
}

.card-badge.blue {
  background: var(--accent-blue-bg);
  color: var(--accent-blue);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

/* Hero Numbers Grid */
.metrics-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 14px;
}

.metrics-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.metric-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  box-shadow: var(--shadow-card);
}

.metric-label {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-val {
  font-size: clamp(11px, 3.2vw, 14.5px);
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.metric-val.green { color: var(--accent-green); }
.metric-val.blue { color: var(--accent-blue); }
.metric-val.pink { color: var(--accent-pink); }
.metric-val.orange { color: var(--accent-orange); }

.metric-sub {
  font-size: 9px;
  color: var(--text-dim);
  margin-top: 2px;
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: calc(var(--sat) + 20px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 380px;
}

.toast {
  background: rgba(21, 28, 46, 0.95);
  border: 1px solid rgba(59, 130, 246, 0.4);
  backdrop-filter: blur(12px);
  color: #ffffff;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-elevated), 0 0 20px rgba(59, 130, 246, 0.3);
  animation: slideDownToast 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideDownToast {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: var(--accent-blue);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

.btn-primary:hover {
  background: var(--accent-blue-light);
  transform: translateY(-1px);
}

.btn-subtle {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.btn-subtle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.btn-copy {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 4px 10px;
  font-size: 11px;
  border-radius: var(--radius-sm);
}

.btn-copy:hover {
  background: rgba(59, 130, 246, 0.25);
  color: #ffffff;
}

.btn-copy.copied {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.4);
}
