:root {
  --bg-color: #0f172a;
  --card-bg: rgba(30, 41, 59, 0.7);
  --accent-color: #38bdf8;
  --danger-color: #ef4444;
  --text-main: #f8fafc;
  --text-dim: #94a3b8;
  --glass-border: rgba(255, 255, 255, 0.1);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--bg-color);
  background-image: radial-gradient(circle at top right, #1e293b, #0f172a);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Header */
.app-header {
  text-align: center;
  margin-bottom: 2rem;
}

.app-header h1 {
  font-size: 2.2rem;
  font-weight: 700;
  margin: 0;
  background: linear-gradient(to right, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* Sekcja Dodawania */
.add-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  padding: 1.5rem;
  border-radius: 20px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  margin-bottom: 2rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

input {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  color: white;
  font-size: 1rem;
  transition: border 0.3s;
}

input:focus {
  outline: none;
  border-color: var(--accent-color);
}

#addBtn {
  width: 100%;
  background: var(--accent-color);
  color: #0f172a;
  border: none;
  padding: 1rem;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, background 0.3s;
}

#addBtn:active {
  transform: scale(0.98);
}

/* Karta Nawyku (Generowana przez JS) */
.habit {
  background: var(--card-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  padding: 1.2rem;
  margin-bottom: 1rem;
  border-radius: 18px;
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 1rem;
  align-items: center;
  animation: slideIn 0.4s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.habit2 {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.habit2 strong {
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.counter {
  font-family: 'Courier New', monospace; /* Dla stałej szerokości cyfr */
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-color);
  background: rgba(56, 189, 248, 0.1);
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-block;
  width: fit-content;
}

.habit2 small {
  color: var(--text-dim);
  font-size: 0.75rem;
}

/* Przyciski sterujące */
.habit-controls {
  margin-top: 0.8rem;
  display: flex;
  gap: 0.5rem;
}

.habit-controls button {
  flex: 1;
  padding: 0.5rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
}

.edit {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid var(--glass-border);
}

.danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger-color);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Wykres */
.chart {
  width: 110px;
  height: 110px;
}

/* Banner Instalacji */
.install-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 40px);
  max-width: 440px;
  background: #1e293b;
  border: 1px solid var(--accent-color);
  border-radius: 16px;
  z-index: 9999;
  padding: 1rem;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.install-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  text-align: center;
}

.install-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

#installBtn {
  flex: 1;
  background: var(--accent-color);
  border: none;
  padding: 10px;
  border-radius: 8px;
  font-weight: bold;
}

#closeBanner {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: white;
  padding: 10px 15px;
  border-radius: 8px;
}

.lang-selector select {
  background: var(--card-bg);
  color: white;
  border: 1px solid var(--glass-border);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
}

/* Przyciski specjalne */
.reset-btn {
  background: #f59e0b !important; /* Bursztynowy */
  color: #000 !important;
}

.stats-btn {
  background: #10b981 !important; /* Szmaragdowy */
}

/* Modal Stylizacja */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0; top: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(5px);
}

.modal-content {
  background: #0f172a;
  margin: 5% auto;
  padding: 20px;
  width: 90%;
  max-width: 500px;
  border-radius: 20px;
  border: 1px solid var(--accent-color);
  max-height: 85vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #1e293b;
  margin-bottom: 20px;
}

#closeModal {
  background: none; border: none; color: white; font-size: 2rem; cursor: pointer;
}

/* Statystyki Boxy */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 20px;
}

.stat-box {
  background: rgba(255,255,255,0.05);
  padding: 15px;
  border-radius: 12px;
  text-align: center;
}

.stat-label { font-size: 0.8rem; color: var(--text-dim); display: block; }
.stat-value { font-size: 1.5rem; font-weight: bold; color: var(--accent-color); }

/* Historia */
.history-item {
  border-left: 3px solid #ef4444;
  padding-left: 15px;
  margin-bottom: 15px;
  background: rgba(239, 68, 68, 0.05);
  padding: 10px;
  border-radius: 0 8px 8px 0;
}

.history-item span { font-size: 0.8rem; color: var(--text-dim); }
.history-item p { margin: 5px 0 0 0; font-size: 0.95rem; }

/* Styl dla siatki kalendarza */
/* Kontener kalendarza - musi być elastyczny */
#calendarChart {
  display: grid !important;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  background: rgba(15, 23, 42, 0.5); /* Ciemniejsze tło dla kontrastu */
  padding: 10px;
  border-radius: 12px;
  margin: 15px 0;
  border: 1px solid var(--glass-border);
  min-height: 200px; /* Minimalna wysokość, ale bez MAX */
  height: auto !important; 
}

.calendar-nav {
  grid-column: span 7;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0 10px 0;
}

.calendar-day {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
}

/* Lista historii pod kalendarzem */
.history-list {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--glass-border);
  clear: both; /* Gwarantuje, że historia będzie pod kalendarzem */
}

.calendar-nav button {
  background: var(--accent-color);
  border: none;
  border-radius: 4px;
  padding: 2px 10px;
  color: white;
  cursor: pointer;
}

.calendar-header-day {
  text-align: center;
  font-weight: bold;
  font-size: 0.7rem;
  color: var(--text-dim);
  padding-bottom: 5px;
}

#calendarChart button {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
}

#calendarChart button:hover {
    background: var(--accent-color);
}

#settingsBtn {
    color: var(--text-dim);
    z-index: 100;
	position: fixed; right: 10px; top: 10px; background: none; border: none; font-size: 1.5rem; cursor: pointer;
}

#settingsBtn:hover {
    color: var(--accent-color);
    transform: rotate(90deg);
}

/* Styl dla przycisku zamykania (analogicznie do closeModal) */
#closeSettings {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
}

/* Kontener suwaka */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

/* Ukrycie domyślnego checkboxa */
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

/* Tło suwaka */
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #475569;
  transition: .4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #10b981; /* Szmaragdowy przy aktywnym */
}

input:checked + .slider:before {
  transform: translateX(26px);
}

/* --- EKRAN BLOKADY PIN --- */
.pin-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-color); /* Pełne krycie tła */
    background-image: radial-gradient(circle at center, #1e293b, #0f172a);
    z-index: 9999; /* Musi być na samym wierzchu */
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.pin-content {
    text-align: center;
    width: 100%;
    max-width: 320px;
}

.pin-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

.pin-dots {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 30px 0;
}

.pin-dots span {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 2px solid var(--accent-color);
    background: transparent;
    transition: all 0.2s;
}

.pin-dots span.filled {
    background: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color);
}

.pin-dots span.error {
    border-color: var(--danger-color);
    background: var(--danger-color);
    animation: shake 0.3s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    justify-items: center;
}

.pin-pad button {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pin-pad button:active {
    background: var(--accent-color);
    color: black;
}

.pin-pad .pin-delete {
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.1);
}

.pin-pad .pin-empty {
    background: transparent;
    border: none;
    cursor: default;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.updating-spinner {
    animation: spin 1.5s linear infinite;
    pointer-events: none; /* Opcjonalnie blokujemy kliknięcia podczas update'u */
    opacity: 0.7;
}