* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f7f6;
    color: #333;
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 90px; /* spazio per il fab button */
}

h1 {
    text-align: center;
    color: #2c3e50;
}

h2 {
    font-size: 1.1em;
    color: #2c3e50;
    margin: 0;
}

h4 {
    font-size: 0.95em;
    color: #2c3e50;
    margin: 18px 0 8px 0;
}

.hidden { display: none !important; }

/* ---------- LOGIN ---------- */
.login-screen {
    text-align: center;
    margin-top: 80px;
}
.login-screen p {
    color: #666;
    margin-bottom: 25px;
}

/* ---------- HEADER ---------- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}
.user-email {
    font-size: 0.85em;
    color: #888;
}

/* ---------- BARRA PUNTI + STATISTICHE/RECAP ---------- */
.top-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}
.points-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(90deg, #192ca5, #4f60f3);
    color: white;
    font-weight: bold;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.95em;
}
.top-bar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---------- BOTTONI ---------- */
.btn-primary {
    background: linear-gradient(90deg, #192ca5, #4f60f3);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
}
.btn-link {
    background: none;
    border: none;
    color: #192ca5;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.9em;
}
.btn-link.center {
    display: block;
    margin: 0 auto 15px auto;
}
.btn-small {
    background: #eef0ff;
    border: none;
    color: #192ca5;
    font-weight: bold;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85em;
}
.btn-icon {
    background: none;
    border: none;
    font-size: 1.5em;
    color: #192ca5;
    cursor: pointer;
    padding: 0 15px;
}

/* ---------- NAVIGAZIONE DATA ---------- */
.date-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}
.date-label {
    font-weight: bold;
    font-size: 1.05em;
    min-width: 160px;
    text-align: center;
    text-transform: capitalize;
}

/* ---------- PROGRESSO (cerchio) ---------- */
.progress-ring-wrap {
    position: relative;
    width: 130px;
    height: 130px;
    margin: 20px auto 25px auto;
}
.progress-ring {
    transform: rotate(-90deg);
}
.progress-ring-bg {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 11;
}
.progress-ring-fill {
    fill: none;
    stroke: #192ca5;
    stroke-width: 11;
    stroke-linecap: round;
    stroke-dasharray: 351.86;
    stroke-dashoffset: 351.86;
    transition: stroke-dashoffset 0.4s ease-in-out;
}
.progress-ring-label {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6em;
    font-weight: bold;
    color: #192ca5;
}

/* ---------- SEZIONI ---------- */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 25px;
    margin-bottom: 10px;
}

/* ---------- PULSANTE "COME TI SENTI?" (apre il modale check-in) ---------- */
.btn-checkin {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 320px;
    margin: 0 auto 20px auto;
    background: white;
    border: none;
    border-radius: 14px;
    padding: 14px 18px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    cursor: pointer;
    text-align: left;
}
.btn-checkin-icon {
    font-size: 1.8em;
    line-height: 1;
}
.btn-checkin-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.btn-checkin-text strong {
    color: #2c3e50;
    font-size: 1em;
}
.btn-checkin-text small {
    color: #888;
    font-size: 0.8em;
}

/* ---------- CHECK-IN GIORNALIERO (energia / umore / sonno / acqua, dentro il modale) ---------- */
.checkin-slot + .checkin-slot {
    border-top: 1px solid #eee;
    padding-top: 14px;
}
.checkin-slot-title {
    font-weight: bold;
    color: #2c3e50;
    font-size: 0.95em;
    margin-bottom: 8px;
}
.checkin-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}
.checkin-row-label {
    font-size: 0.82em;
    color: #777;
    min-width: 52px;
}
.emoji-picker {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
}
.emoji-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid transparent;
    background: #f4f7f6;
    font-size: 1.1em;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.emoji-btn.active {
    background: #eef0ff;
    border-color: #192ca5;
}

/* ---------- ACQUA (bicchieri bevuti) ---------- */
.water-tracker {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
}
.water-tracker span {
    font-weight: bold;
    color: #2c3e50;
    min-width: 100px;
    text-align: center;
}
.water-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(90deg, #192ca5, #4f60f3);
    color: white;
    font-size: 1.3em;
    line-height: 1;
    cursor: pointer;
}

/* ---------- TOGGLE SEZIONE CATEGORIE ---------- */
.section-toggle {
    background: none;
    border: none;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1.1em;
    color: #2c3e50;
    font-weight: normal;
    padding: 0;
    cursor: pointer;
}
.toggle-icon {
    display: inline-block;
    font-size: 0.8em;
    color: #192ca5;
    transition: transform 0.2s ease;
}

/* ---------- ARRETRATI ---------- */
.section-count {
    background: #c0392b;
    color: white;
    font-size: 0.7em;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 10px;
}
.backlog-ring-wrap {
    margin: 5px auto 8px auto;
}
.backlog-caption {
    text-align: center;
    color: #888;
    font-size: 0.85em;
    margin: 0 0 14px 0;
}
.recovered-badge {
    font-size: 0.72em;
    font-weight: bold;
    color: #8e44ad;
    background: #f3e9f8;
    padding: 2px 6px;
    border-radius: 6px;
}

/* ---------- CATEGORIE / STREAK ---------- */
.category-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.category-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    color: white;
    font-size: 0.85em;
    font-weight: bold;
}
.category-chip .streak {
    background: rgba(0,0,0,0.2);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.9em;
}
.category-chip .chip-points {
    background: rgba(255,255,255,0.25);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.9em;
}
.category-chip .chip-action {
    background: none;
    border: none;
    color: white;
    opacity: 0.85;
    cursor: pointer;
    font-size: 0.95em;
    padding: 0 2px;
}
.category-chip .chip-action:hover {
    opacity: 1;
}

/* ---------- TASK LIST ---------- */
.task-list {
    list-style: none;
    padding: 0;
}
.task-item {
    background: white;
    margin-bottom: 12px;
    padding: 15px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.task-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.05em;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}
.task-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.task-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}
.task-time {
    font-size: 0.8em;
    color: #888;
    font-weight: bold;
}
.category-badge {
    font-size: 0.75em;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 6px;
    color: white;
    display: inline-block;
    width: fit-content;
}
.task-checkbox {
    width: 22px;
    height: 22px;
    cursor: pointer;
    accent-color: #192ca5;
    flex-shrink: 0;
}
.completed {
    text-decoration: line-through;
    color: #888;
}
.empty-state {
    text-align: center;
    color: #999;
    font-style: italic;
    margin-top: 30px;
}

/* ---------- FAB ---------- */
.fab {
    position: fixed;
    bottom: 25px;
    right: max(25px, calc(50% - 250px + 25px));
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(90deg, #192ca5, #4f60f3);
    color: white;
    font-size: 2em;
    border: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
    cursor: pointer;
    line-height: 1;
}

/* ---------- MODALI ---------- */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}
.modal-content {
    background: white;
    border-radius: 14px;
    padding: 25px;
    width: 100%;
    max-width: 400px;
    max-height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.modal-content h3 {
    margin: 0 0 5px 0;
    color: #2c3e50;
}
.modal-content label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.9em;
    font-weight: bold;
    color: #555;
}
.modal-content input,
.modal-content select {
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ddd;
    font-size: 1em;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 10px;
}
.field-hint {
    font-size: 0.78em;
    color: #999;
    margin: -8px 0 0 0;
}

/* ---------- TOGGLE TIPO TASK ---------- */
.type-toggle {
    display: flex;
    gap: 8px;
}
.type-btn {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ddd;
    background: white;
    color: #555;
    font-weight: bold;
    cursor: pointer;
}
.type-btn.active {
    background: linear-gradient(90deg, #192ca5, #4f60f3);
    color: white;
    border-color: transparent;
}

/* ---------- SELETTORE GIORNI RICORRENZA ---------- */
.day-toggle-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.day-toggle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid #ddd;
    background: white;
    color: #555;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.85em;
    padding: 0;
}
.day-toggle.active {
    background: linear-gradient(90deg, #192ca5, #4f60f3);
    color: white;
    border-color: transparent;
}
.day-toggle:disabled,
.day-toggle.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---------- AZIONI SULLA TASK (modifica/elimina) ---------- */
.task-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.task-action-btn {
    background: none;
    border: none;
    font-size: 1.1em;
    cursor: pointer;
    padding: 4px 6px;
    color: #999;
}
.task-action-btn:hover {
    color: #192ca5;
}
.recurring-icon {
    font-size: 0.75em;
    color: #888;
    margin-left: 4px;
}
.appointment-badge {
    font-size: 0.75em;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 6px;
    color: #555;
    background: #eee;
    display: inline-block;
    width: fit-content;
}

/* ---------- STATISTICHE ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.stat-card {
    background: #f4f7f6;
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.stat-card.wide {
    grid-column: span 2;
}
.stat-value {
    font-size: 1.6em;
    font-weight: bold;
    color: #192ca5;
}
.stat-label {
    font-size: 0.8em;
    color: #777;
    text-align: center;
}
.stats-streak-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.stats-streak-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f4f7f6;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9em;
}
.stats-streak-list .cat-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
}
.stats-streak-list .cat-name {
    display: flex;
    align-items: center;
}
.stats-empty {
    color: #999;
    font-style: italic;
    font-size: 0.9em;
}

/* ---------- OBIETTIVI SETTIMANALI (barra di progresso) ---------- */
.goal-item-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
    margin-bottom: 6px;
    width: 100%;
}
.goal-bar-container {
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    height: 10px;
    width: 100%;
}
.goal-bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s ease;
}

/* ---------- TOAST (incoraggiamento / bonus) ---------- */
.app-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: linear-gradient(90deg, #192ca5, #4f60f3);
    color: white;
    font-weight: bold;
    padding: 12px 20px;
    border-radius: 30px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 200;
    text-align: center;
    max-width: 90%;
}
.app-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.app-toast.bonus {
    background: linear-gradient(90deg, #f39c12, #f7b733);
}