/* =====================================================
   Budżet Domowy — app.css
   Motyw: niebieski (#1565C0), Zero-build, knadh/oat
   ===================================================== */

/* === ZMIENNE === */
:root {
  --primary: #1565C0;
  --primary-dark: #0D47A1;
  --primary-light: #1976D2;
  --primary-pale: #E3F2FD;
  --accent: #FF6F00;
  --success: #2E7D32;
  --success-pale: #E8F5E9;
  --warning: #F57F17;
  --warning-pale: #FFF8E1;
  --danger: #C62828;
  --danger-pale: #FFEBEE;
  --text: #212121;
  --text-secondary: #757575;
  --text-inverse: #FFFFFF;
  --bg: #FAFAFA;
  --bg-card: #FFFFFF;
  --border: #E0E0E0;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --header-h: 60px;
  --tabnav-h: 48px;
}

/* === RESET + BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100dvh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

/* === LAYOUT === */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px;
}

.view { display: block; }
.view[hidden] { display: none !important; }
.view-tab { display: block; padding: 24px 0; }
.view-tab[hidden] { display: none !important; }

/* === HEADER === */
.landing-header,
.app-header {
  background: var(--primary);
  color: var(--text-inverse);
  height: var(--header-h);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.landing-header nav,
.app-header nav {
  display: flex;
  align-items: center;
  height: var(--header-h);
  gap: 12px;
}

.brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-inverse) !important;
  text-decoration: none;
  white-space: nowrap;
}

.spacer { flex: 1; }

/* === TAB NAV === */
.tab-nav {
  background: var(--bg-card);
  border-bottom: 2px solid var(--border);
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: var(--header-h);
  z-index: 90;
}

.tab-nav::-webkit-scrollbar { display: none; }

.tab-nav a {
  padding: 14px 16px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
  text-decoration: none;
}

.tab-nav a:hover { color: var(--primary); }
.tab-nav a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* === BUTTONS === */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: var(--primary-pale);
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary:hover { background: #BBDEFB; }

.btn-ghost {
  background: transparent;
  color: var(--text-inverse);
  border: 1px solid rgba(255,255,255,0.5);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-ghost:hover { background: rgba(255,255,255,0.15); }

/* Ghost w kontekście jasnym */
.card .btn-ghost,
.modal .btn-ghost,
.settings-section .btn-ghost {
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background 0.2s;
}

.btn-icon:hover { background: var(--primary-pale); }

.btn-hero {
  background: #fff;
  color: var(--primary);
  border: none;
  padding: 16px 36px;
  border-radius: 50px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: transform 0.2s, box-shadow 0.2s;
  margin-top: 24px;
}

.btn-hero:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* === LANG SWITCH === */
.lang-switch {
  background: rgba(255,255,255,0.15);
  color: var(--text-inverse);
  border: 1px solid rgba(255,255,255,0.3);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  cursor: pointer;
  appearance: none;
}

.lang-switch option { background: var(--primary); }

/* === CARDS === */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.info-card {
  border-left: 4px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* === LANDING === */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: 80px 0 60px;
  text-align: center;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  margin-bottom: 16px;
  line-height: 1.2;
}

.hero-subtitle {
  font-size: 1.15rem;
  opacity: 0.9;
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.6;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  padding: 48px 16px;
}

.feature-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}

.feature-card:hover { transform: translateY(-4px); }

.feature-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.feature-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--primary);
}

.feature-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.landing-footer {
  background: #212121;
  color: #9E9E9E;
  text-align: center;
  padding: 24px 16px;
  font-size: 0.9rem;
}

.landing-footer a { color: #BDBDBD; }

/* === DASHBOARD === */
.month-selector {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.month-label {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
  min-width: 160px;
  text-align: center;
  text-transform: capitalize;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.summary-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}

.income-card { border-left: 4px solid var(--success); }
.expenses-card { border-left: 4px solid var(--danger); }
.savings-card { border-left: 4px solid var(--primary); }

.card-icon { font-size: 2rem; }
.card-label { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.card-value { font-size: 1.5rem; font-weight: 700; color: var(--text); margin-top: 2px; }

/* Budget rule */
.budget-bars { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }

.budget-bar-item {}

.budget-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 6px;
}

.progress-bar {
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s ease;
}

.needs-fill { background: var(--primary); }
.wants-fill { background: var(--accent); }
.savings-fill { background: var(--success); }
.progress-fill.over { background: var(--danger); }

.budget-status { font-size: 0.8rem; margin-top: 4px; color: var(--text-secondary); }
.budget-status.ok { color: var(--success); }
.budget-status.warn { color: var(--warning); }
.budget-status.over { color: var(--danger); }

/* === VIEW HEADER === */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

/* === FORMS === */
.form-card { margin-bottom: 20px; }

.form-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
}

.form-row label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-row input,
.form-row select,
.form-row textarea {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.2s;
  font-family: var(--font);
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.input-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.input-group input {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
}

/* === ENTRIES LIST === */
.entries-list { display: flex; flex-direction: column; gap: 8px; }

.entry-item {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}

.entry-item:hover { box-shadow: var(--shadow-lg); }

.entry-category-icon { font-size: 1.5rem; }
.entry-body { flex: 1; }
.entry-category { font-weight: 600; font-size: 0.95rem; }
.entry-meta { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }
.entry-amount { font-size: 1.1rem; font-weight: 700; }
.entry-amount.expense { color: var(--danger); }
.entry-amount.income { color: var(--success); }

.entry-actions { display: flex; gap: 8px; }

.btn-delete {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 1rem;
  transition: background 0.2s;
}

.btn-delete:hover { background: var(--danger-pale); }

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-secondary);
}

.empty-state p { font-size: 1.1rem; }

/* === CHARTS === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.chart-card canvas { max-height: 280px; }

/* === BADGES (header) === */
.badge {
  display: inline-flex;
  align-items: center;
  background: rgba(255,255,255,0.2);
  color: #fff;
  border-radius: 50px;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  gap: 4px;
  white-space: nowrap;
}

/* === SETTINGS === */
.settings-section { margin-bottom: 16px; }
.settings-section h3 { margin-bottom: 12px; font-size: 1rem; }
.settings-help { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 10px; }

/* === ACHIEVEMENTS === */
.player-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.player-stat { text-align: center; flex: 1; min-width: 80px; }
.stat-label { display: block; font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; text-transform: uppercase; }
.stat-value { display: block; font-size: 1.5rem; font-weight: 700; color: var(--primary); margin-top: 4px; }

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.achievement-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}

.achievement-card.unlocked { border: 2px solid var(--primary); }
.achievement-card.locked { opacity: 0.5; filter: grayscale(1); }
.achievement-card:hover { transform: translateY(-2px); }

.achievement-icon { font-size: 2.5rem; margin-bottom: 8px; }
.achievement-name { font-size: 0.85rem; font-weight: 700; margin-bottom: 4px; }
.achievement-desc { font-size: 0.75rem; color: var(--text-secondary); }
.achievement-unlocked-badge {
  display: inline-block;
  background: var(--primary-pale);
  color: var(--primary);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 50px;
  margin-top: 6px;
}

/* Achievement unlock modal */
.achievement-unlock {
  text-align: center;
  padding: 16px;
}

.achievement-unlock h3 { font-size: 1.5rem; margin-bottom: 8px; }
.achievement-unlock h4 { font-size: 1.1rem; color: var(--primary); margin-bottom: 8px; }
.achievement-unlock p { color: var(--text-secondary); margin-bottom: 16px; }

/* === LOYALTY === */
.loyalty-section { display: flex; flex-direction: column; gap: 16px; }

.points-card { text-align: center; }
.points-balance { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.points-label { font-size: 0.9rem; color: var(--text-secondary); font-weight: 500; }
.points-value { font-size: 3rem; font-weight: 800; color: var(--primary); }

.referral-link-section { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.referral-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text-secondary);
}

.rewards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.reward-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reward-title { font-weight: 700; font-size: 0.95rem; }
.reward-cost { color: var(--primary); font-weight: 700; }
.reward-type { font-size: 0.8rem; color: var(--text-secondary); }

/* === PAIR === */
.pair-status-card { margin-bottom: 20px; }
.pair-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.9rem;
}

.pair-status-badge.connected { background: var(--success-pale); color: var(--success); }
.pair-status-badge.pending { background: var(--warning-pale); color: var(--warning); }
.pair-status-badge.none { background: var(--primary-pale); color: var(--primary); }

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* === MODALS === */
.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow-lg);
  max-width: 480px;
  width: calc(100% - 32px);
  background: var(--bg-card);
}

.modal::backdrop { background: rgba(0,0,0,0.5); }

.modal-close {
  display: block;
  width: 100%;
  margin-top: 0;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 12px;
  text-align: center;
}

/* === AD SLOTS === */
.ad-slot { margin: 16px 0; }

.ad-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.ad-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.ad-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.ad-card h4 { margin-bottom: 6px; font-size: 1rem; }
.ad-card p { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 12px; }

.ad-card a {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: background 0.2s;
}

.ad-card a:hover { background: var(--primary-dark); }

/* === TOAST NOTIFICATIONS === */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  min-width: 280px;
  max-width: calc(100vw - 32px);
}

.toast {
  background: #323232;
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
  pointer-events: auto;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === LOADING OVERLAY === */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
}

.loading-overlay[hidden] { display: none !important; }

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* === RESPONSIVE === */
@media (max-width: 600px) {
  .summary-cards { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .compare-grid { grid-template-columns: 1fr; }
  .achievements-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .rewards-grid { grid-template-columns: 1fr; }
  .hero { padding: 48px 0 40px; }

  .tab-nav a { padding: 12px 10px; font-size: 0.82rem; }
}

@media (max-width: 400px) {
  .summary-cards { grid-template-columns: 1fr; }
  .brand { font-size: 1rem; }
}

/* === UTILITY === */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.text-muted { color: var(--text-secondary); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
