/* Reset */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5;
    color: #222;
    padding: 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s, color 0.3s;
}

body.dark {
    background-color: #121212;
    color: #eee;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

header h1 {
    font-size: 2rem;
}

#darkModeToggle {
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    transition: transform 0.3s;
}

#darkModeToggle:hover {
    transform: rotate(20deg);
}

.quote-section {
    background: #fff;
    padding: 1rem 2rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-style: italic;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s, color 0.3s;
}

body.dark .quote-section {
    background: #1e1e1e;
}

.habit-input-section {
    margin-bottom: 1.5rem;
}

.habit-input-section h2 {
    margin-bottom: 0.5rem;
}

#habitForm {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

#habitForm input[type="text"],
#habitForm select,
#habitForm input[type="date"] {
    flex: 1;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid #bbb;
    font-size: 1rem;
    transition: border-color 0.3s;
}

#habitForm input[type="text"]:focus,
#habitForm select:focus,
#habitForm input[type="date"]:focus {
    border-color: #4a90e2;
    outline: none;
}

#habitForm button {
    padding: 0.5rem 1.5rem;
    background-color: #4a90e2;
    color: white;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#habitForm button:hover {
    background-color: #357ABD;
}

.filter-sort-section {
    margin-bottom: 1rem;
}

.filter-sort-section label {
    margin-right: 0.5rem;
    font-weight: 600;
}

.filter-sort-section select {
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    border: 1px solid #bbb;
    font-size: 1rem;
}

.habits-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.habit-card {
    background: #fff;
    border-radius: 12px;
    padding: 1rem 1.2rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    position: relative;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s;
}

body.dark .habit-card {
    background: #1e1e1e;
}

.habit-card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.3rem;
}

.habit-info {
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 0.5rem;
}

body.dark .habit-info {
    color: #ccc;
}

.check-in-btn {
    align-self: flex-start;
    padding: 0.4rem 1rem;
    background-color: #4caf50;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.3s;
}

.check-in-btn.missed {
    background-color: #e74c3c;
}

.check-in-btn:hover {
    opacity: 0.85;
}

.streak {
    font-weight: 700;
    margin-top: auto;
    color: #4caf50;
}

body.dark .streak {
    color: #81c784;
}

.edit-btn,
.delete-btn {
    position: absolute;
    top: 12px;
    width: 24px;
    height: 24px;
    border: none;
    cursor: pointer;
    background: none;
    color: #999;
    font-size: 1.2rem;
    transition: color 0.3s;
}

.edit-btn:hover,
.delete-btn:hover {
    color: #4a90e2;
}

.edit-btn {
    right: 38px;
}

.delete-btn {
    right: 12px;
}

.heatmap-section {
    margin-bottom: 2rem;
}

#heatmap {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: 700px;
}

.day-box {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background-color: #eee;
    cursor: default;
    transition: background-color 0.3s;
    position: relative;
}

.day-box.completed {
    background-color: #4caf50;
}

.day-box.missed {
    background-color: #e74c3c;
    opacity: 0.5;
}

.day-box:hover::after {
    content: attr(data-date);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    padding: 3px 8px;
    background: #333;
    color: #fff;
    font-size: 0.75rem;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10;
}

footer {
    text-align: center;
    padding: 1rem 0;
    color: #777;
    font-size: 0.9rem;
}


/* Responsive */

@media (max-width: 600px) {
    #habitForm {
        flex-direction: column;
    }
    #habitForm input,
    #habitForm select,
    #habitForm button {
        width: 100%;
    }
    .habits-container {
        grid-template-columns: 1fr;
    }
}