@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* CSS Custom Properties for Design Tokens */
:root {
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'Space Grotesk', monospace;

  /* Color Palette (Obsidian & Neon Accents) */
  --bg-primary: #070913;
  --bg-secondary: rgba(13, 17, 34, 0.6);
  --bg-glass: rgba(18, 23, 47, 0.45);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glass-hover: rgba(255, 255, 255, 0.16);

  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --accent-cyan: #00f2fe;
  --accent-blue: #0072ff;
  --accent-purple: #9d4edd;
  --accent-emerald: #00f5d4;
  --accent-pink: #ff007f;
  
  --status-success: #059669;
  --status-success-glow: rgba(5, 150, 105, 0.3);
  --status-warning: #d97706;
  --status-warning-glow: rgba(217, 119, 6, 0.3);
  --status-danger: #dc2626;
  --status-danger-glow: rgba(220, 38, 38, 0.3);

  --glow-cyan: 0 0 20px rgba(0, 242, 254, 0.25);
  --glow-purple: 0 0 20px rgba(157, 78, 221, 0.25);
  --glow-pink: 0 0 20px rgba(255, 0, 127, 0.25);

  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Global */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Ambient Background Blobs (Premium Design Aspect) */
.ambient-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -2;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.18;
  animation: float 25s infinite alternate ease-in-out;
}

.blob-1 {
  width: 45vw;
  height: 45vw;
  background: radial-gradient(circle, var(--accent-cyan) 0%, var(--accent-blue) 100%);
  top: -10%;
  right: -10%;
  animation-duration: 28s;
}

.blob-2 {
  width: 40vw;
  height: 40vw;
  background: radial-gradient(circle, var(--accent-purple) 0%, var(--accent-pink) 100%);
  bottom: -10%;
  left: -5%;
  animation-duration: 22s;
  animation-delay: 2s;
}

.blob-3 {
  width: 30vw;
  height: 30vw;
  background: radial-gradient(circle, var(--accent-emerald) 0%, var(--accent-blue) 100%);
  top: 40%;
  left: 35%;
  opacity: 0.08;
  animation-duration: 35s;
}

@keyframes float {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
  }
  50% {
    transform: translate(5%, 8%) scale(1.1) rotate(180deg);
  }
  100% {
    transform: translate(-3%, -5%) scale(0.9) rotate(360deg);
  }
}

/* Glassmorphic Layering system */
.glass-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
  border-radius: 16px;
  transition: var(--transition-smooth);
}

.glass-panel:hover {
  border-color: var(--border-glass-hover);
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
  transform: translateY(-2px);
}

/* App Header & Layout */
header {
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: var(--font-mono);
  box-shadow: var(--glow-cyan);
}

.logo-text {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo-text span {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 30px;
}

.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}

.btn {
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  border: none;
  transition: var(--transition-smooth);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-blue) 100%);
  color: #000;
  font-weight: 600;
  box-shadow: var(--glow-cyan);
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 25px rgba(0, 242, 254, 0.4);
}

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

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--border-glass-hover);
}

.btn-logout {
  background: rgba(220, 38, 38, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(220, 38, 38, 0.3);
}

.btn-logout:hover {
  background: rgba(220, 38, 38, 0.3);
}

/* Dashboard Body Layout */
main {
  flex: 1;
  padding: 0 2rem 2rem 2rem;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

/* Top Summary Banner: Net Profit Calculator (Glow Accent) */
.net-profit-banner {
  margin-bottom: 2rem;
  padding: 1.75rem;
  border: 1px solid rgba(0, 242, 254, 0.15);
  box-shadow: 0 8px 32px 0 rgba(0, 242, 254, 0.05);
}

.banner-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

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

.profit-segment {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.profit-segment:first-child {
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  padding-right: 2rem;
}

@media (max-width: 768px) {
  .profit-segment:first-child {
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-right: 0;
    padding-bottom: 1.5rem;
  }
}

.profit-details h4 {
  text-transform: uppercase;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-secondary);
  letter-spacing: 1px;
  margin-bottom: 0.25rem;
}

.profit-value {
  font-size: 2.25rem;
  font-weight: 700;
  font-family: var(--font-mono);
  background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.profit-value.positive {
  background: linear-gradient(135deg, var(--accent-emerald) 0%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.profit-value.negative {
  background: linear-gradient(135deg, #f87171 0%, var(--accent-pink) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.profit-breakdown {
  text-align: right;
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.breakdown-row {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.breakdown-row span:last-child {
  font-family: var(--font-mono);
  color: var(--text-primary);
}

/* Grid Layout for Sections */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
}

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

.section-card {
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.75rem;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.section-icon {
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.section-card:nth-child(1) .section-icon {
  color: var(--accent-cyan);
  background: rgba(0, 242, 254, 0.08);
}
.section-card:nth-child(2) .section-icon {
  color: var(--accent-purple);
  background: rgba(157, 78, 221, 0.08);
}
.section-card:nth-child(3) .section-icon {
  color: var(--accent-emerald);
  background: rgba(0, 245, 212, 0.08);
}
.section-card:nth-child(4) .section-icon {
  color: var(--accent-pink);
  background: rgba(255, 0, 127, 0.08);
}

.section-badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-weight: 500;
  text-transform: uppercase;
}

.badge-live {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  animation: pulse-border 2s infinite;
}

.badge-mock {
  background: rgba(245, 158, 11, 0.1);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Card metrics layout */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (max-width: 480px) {
  .metrics-row {
    grid-template-columns: 1fr;
  }
}

.metric-card {
  padding: 1.25rem;
  background: rgba(255,255,255,0.02);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.03);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.metric-card h5 {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-card .val {
  font-size: 1.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

/* Tier Split display (Stripe Customers) */
.tier-distribution {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tier-bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.tier-label {
  width: 90px;
  font-size: 0.85rem;
  font-weight: 500;
}

.progress-container {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 1s ease-in-out;
}

.tier-count {
  width: 45px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
}

.fill-free {
  background: linear-gradient(90deg, #94a3b8, #cbd5e1);
}

.fill-essencial {
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.4);
}

.fill-profissional {
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-pink));
  box-shadow: 0 0 10px rgba(255, 0, 127, 0.4);
}

/* Quota / Status widgets */
.quota-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.quota-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.quota-status-badge {
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.status-free {
  background: #2563eb;
  color: #fff;
}

.status-paid {
  background: #059669;
  color: #fff;
}

.quota-values {
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.quota-values span {
  color: var(--text-primary);
  font-weight: 600;
}

/* API Error Monitor Graphic */
.error-monitor {
  background: rgba(220, 38, 38, 0.03);
  border: 1px solid rgba(220, 38, 38, 0.1);
}

.error-bar-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 50px;
  padding: 0.5rem 0;
  gap: 3px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.error-chart-bar {
  flex: 1;
  background: rgba(220, 38, 38, 0.3);
  border-radius: 2px 2px 0 0;
  transition: height 0.5s ease;
  position: relative;
  cursor: pointer;
}

.error-chart-bar:hover {
  background: rgba(220, 38, 38, 0.7);
  box-shadow: 0 0 8px rgba(220, 38, 38, 0.6);
}

/* Tooltip on hover */
.error-chart-bar::before {
  content: attr(data-val);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #000;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 2px 4px;
  border-radius: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.error-chart-bar:hover::before {
  opacity: 1;
}

/* Database & Ping Health Indicators */
.health-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  position: relative;
}

.status-dot.online {
  background-color: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
}

.status-dot.online::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  border: 2px solid var(--accent-emerald);
  opacity: 1;
  animation: ping-ring 1.5s infinite;
}

@keyframes ping-ring {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}

.deploy-logs {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: rgba(0,0,0,0.3);
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.03);
  white-space: normal;
  word-break: break-all;
  line-height: 1.4;
  color: var(--text-secondary);
}

.deploy-logs span {
  color: var(--accent-cyan);
}

/* Login Page Styling */
.login-body {
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-container {
  width: 100%;
  max-width: 440px;
  padding: 2.5rem;
  position: relative;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 1rem;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: var(--transition-smooth);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.15);
  background: rgba(255,255,255,0.06);
}

.form-error {
  background: rgba(220,38,38,0.15);
  border: 1px solid rgba(220,38,38,0.3);
  color: #fecaca;
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  text-align: center;
  margin-bottom: 1.25rem;
  display: none;
}

.btn-submit {
  width: 100%;
  justify-content: center;
  padding: 0.8rem;
  font-size: 1rem;
  margin-top: 0.5rem;
}

/* Animations */
@keyframes pulse-border {
  0% { border-color: rgba(16, 185, 129, 0.3); }
  50% { border-color: rgba(16, 185, 129, 0.8); }
  100% { border-color: rgba(16, 185, 129, 0.3); }
}

/* Footer info */
footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: var(--font-mono);
}
