/* ============================================
   Finanças Pessoais — Estilos
   Paleta: verde-sálvia (primária), esmeralda,
   coral, âmbar, creme
   ============================================ */

:root {
  --primary: #3D6B5C;
  --primary-dark: #2E5245;
  --primary-light: #6BA88E;
  --income: #4A9375;
  --income-light: #7FC9A4;
  --expense: #D97757;
  --expense-light: #E89477;
  --savings: #E8B84D;
  --savings-light: #F0C77A;

  --bg: #FAF6F0;
  --card: #FFFFFF;
  --card-hover: #F5F0E8;

  --text: #2A2A28;
  --text-secondary: #6B6B65;
  --text-muted: #9B9B92;

  --border: #E8E4DA;
  --border-strong: #D0CCC0;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

/* Modo escuro */
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #6BA88E;
    --primary-dark: #4A8770;
    --primary-light: #8BC3A9;
    --income: #7FC9A4;
    --expense: #E89477;
    --savings: #F0C77A;

    --bg: #1A1D1B;
    --card: #2A2D2B;
    --card-hover: #35383A;

    --text: #E8E6DD;
    --text-secondary: #B8B8B0;
    --text-muted: #7A7A72;

    --border: #3A3D3B;
    --border-strong: #4A4D4B;
  }
}

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

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   Login
   ============================================ */
.login-body {
  background: linear-gradient(135deg, var(--bg) 0%, var(--card-hover) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-container {
  width: 100%;
  max-width: 400px;
}

.login-card {
  background: var(--card);
  border-radius: var(--radius-xl);
  padding: 40px 32px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  text-align: center;
}

.login-logo {
  margin-bottom: 24px;
}

.logo-circle {
  width: 72px;
  height: 72px;
  background: var(--primary);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  box-shadow: 0 4px 16px rgba(61, 107, 92, 0.25);
}

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

.login-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.btn-google {
  width: 100%;
  background: var(--card);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-google:hover {
  background: var(--card-hover);
  border-color: var(--primary);
}

.btn-google:active {
  transform: scale(0.98);
}

.login-error {
  margin-top: 16px;
  padding: 12px 16px;
  background: rgba(217, 119, 87, 0.1);
  border: 1px solid var(--expense);
  border-radius: var(--radius-sm);
  color: var(--expense);
  font-size: 13px;
}

.login-footer {
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================
   Loading overlay
   ============================================ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ============================================
   App layout (páginas internas)
   ============================================ */
.app-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 80px; /* espaço para tab bar */
}

.app-header {
  background: var(--primary);
  color: white;
  padding: 20px 20px 24px;
  padding-top: calc(20px + env(safe-area-inset-top));
}

.app-header .greeting {
  font-size: 13px;
  opacity: 0.85;
  margin-bottom: 4px;
}

.app-header .user-name {
  font-size: 22px;
  font-weight: 700;
}

.btn-logout {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 12px;
}

.btn-logout:hover {
  background: rgba(255, 255, 255, 0.25);
}

.app-content {
  flex: 1;
  padding: 20px;
}

.card {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 20px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.welcome-msg {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.welcome-msg h2 {
  font-size: 20px;
  color: var(--text);
  margin-bottom: 8px;
}

/* Tab bar (bottom navigation) */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 12px 0;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 100;
}

.tab {
  flex: 1;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px 0;
}

.tab .tab-icon {
  font-size: 22px;
  display: block;
  margin-bottom: 2px;
}

.tab.active {
  color: var(--primary);
  font-weight: 600;
}
