:root {
    --primary-color: #4CAF50;
    --secondary-color: #8BC34A;
    --accent-color: #FFC107;
    --background-color: #f4f7f6;
    --card-background: #ffffff;
    --text-color: #333;
    --border-color: #eee;
    --shadow-color: rgba(0, 0, 0, 0.05);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: var(--background-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.container {
    background-color: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 4px 20px var(--shadow-color);
    padding: 30px;
    max-width: 900px;
    width: 100%;
    margin: 20px 0;
}

h1 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 30px;
    font-size: 2.5em;
}

section {
    margin-bottom: 40px;
    padding: 20px;
    background-color: var(--card-background);
    border-radius: 10px;
    box-shadow: 0 2px 10px var(--shadow-color);
}

h2 {
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.8em;
}

.habit-input-section {
    display: flex;
    gap: 10px;
}

.habit-input-section input[type="text"] {
    flex-grow: 1;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    outline: none;
    transition: border-color 0.3s ease;
}

.habit-input-section input[type="text"]:focus {
    border-color: var(--primary-color);
}

.habit-input-section button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.habit-input-section button:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
}

.habits-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.habit-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--background-color);
    padding: 12px 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 1.1em;
}

.habit-item button {
    background-color: #f44336;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8em;
    transition: background-color 0.3s ease;
}

.habit-item button:hover {
    background-color: #d32f2f;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-size: 1.2em;
    color: var(--primary-color);
}

.calendar-header button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease;
}

.calendar-header button:hover {
    background-color: var(--secondary-color);
}

#current-month-year {
    font-weight: bold;
    font-size: 1.4em;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    text-align: center;
}

.day-name {
    font-weight: bold;
    color: var(--primary-color);
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 5px;
}

.calendar-day {
    padding: 10px 5px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    position: relative;
    min-height: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 0.95em;
}

.calendar-day.empty {
    background-color: #f9f9f9;
    cursor: default;
}

.calendar-day:not(.empty):hover {
    background-color: var(--background-color);
    transform: translateY(-1px);
}

.calendar-day.today {
    border: 2px solid var(--accent-color);
    font-weight: bold;
}

.calendar-day.selected {
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
}

.calendar-day.has-completed-habits {
    background-color: #e0ffe0; /* Light green for days with completed habits */
}

.calendar-day.selected.has-completed-habits {
    background-color: var(--primary-color);
    color: white;
}

.completion-dot {
    width: 6px;
    height: 6px;
    background-color: var(--primary-color);
    border-radius: 50%;
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
}

.selected-day-habits {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.selected-day-habits h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.4em;
}

.selected-day-habits-list .habit-completion-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--background-color);
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
}

.selected-day-habits-list .habit-completion-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.selected-day-habits-list .habit-completion-item label {
    flex-grow: 1;
    font-size: 1.1em;
    cursor: pointer;
}

.selected-day-habits-list .habit-completion-item.completed label {
    text-decoration: line-through;
    color: #777;
}

.statistics-section {
    margin-top: 40px;
}

#weekly-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
}

.stat-card {
    background-color: var(--background-color);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    text-align: center;
    box-shadow: 0 1px 5px var(--shadow-color);
}

.stat-card h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--primary-color);
    font-size: 1.2em;
}

.stat-card p {
    font-size: 1.8em;
    font-weight: bold;
    color: var(--text-color);
    margin: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    .habits-list {
        grid-template-columns: 1fr;
    }

    .calendar-grid {
        font-size: 0.9em;
    }

    .calendar-day {
        min-height: 35px;
        padding: 8px 3px;
    }

    .habit-input-section {
        flex-direction: column;
    }

    .habit-input-section button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 2em;
    }

    h2 {
        font-size: 1.5em;
    }

    .calendar-header {
        font-size: 1em;
    }

    #current-month-year {
        font-size: 1.2em;
    }

    .calendar-day {
        font-size: 0.8em;
        min-height: 30px;
    }

    .stat-card h4 {
        font-size: 1em;
    }

    .stat-card p {
        font-size: 1.5em;
    }
}