/* =========================================================
   HABITS
========================================================= */

#habitsSection {
    min-width: 0;
}

.habitControls {
    display: grid;

    grid-template-columns: minmax(0, 1fr) 190px 150px;

    gap: 12px;

    margin-bottom: 12px;
}

.habitControls input,
.habitControls select,
.habitToolbar input,
.habitToolbar select {
    min-width: 0;

    height: 42px;

    padding: 0 14px;

    border: 1px solid var(--border);
    border-radius: 10px;

    background: var(--card);
    color: var(--text);

    font-size: 0.85rem;

    box-shadow: 0 2px 8px rgba(0,0,0,.03);
}

.habitControls input::placeholder,
.habitToolbar input::placeholder {
    color: var(--text-light);
}

.habitControls input:focus,
.habitControls select:focus,
.habitToolbar input:focus,
.habitToolbar select:focus {
    border-color: var(--primary);

    box-shadow:
        0 0 0 3px rgba(37, 99, 235, 0.1);
}

#addHabitButton {
    height: 42px;

    border: none;
    border-radius: 10px;

    background: linear-gradient(
        135deg,
        #4f7df3,
        #6366f1
    );

    color: white;

    font-weight: 600;

    box-shadow: 0 5px 14px rgba(79, 125, 243, 0.22);

    transition: 0.2s ease;
}

#addHabitButton:hover {
    transform: translateY(-2px);
}

/* =========================================================
   HABIT TOOLBAR
========================================================= */

.habitToolbar {
    display: grid;

    grid-template-columns: minmax(0, 1fr) 190px;

    gap: 12px;

    margin-bottom: 14px;
}

.habitToolbar input,
.habitToolbar select {
    width: 100%;
}

/* =========================================================
   HABIT LIST
========================================================= */

#habitList {
    display: flex;
    flex-direction: column;

    gap: 12px;

    min-height: 105px;
}

/* =========================================================
   HABIT CARD
========================================================= */

.habit {
    padding: 18px;

    background: var(--card);

    border: 1px solid var(--border);

    border-radius: 16px;

    box-shadow: var(--shadow);
}

.habitHeader {
    display: flex;

    justify-content: space-between;

    gap: 18px;
}

.habitLeft {
    min-width: 0;
    flex: 1;
}

.habitTitleRow {
    display: flex;
    align-items: center;

    gap: 10px;

    flex-wrap: wrap;
}

.habitName {
    font-size: 1rem;
    font-weight: 700;
}

.favoriteIcon {
    color: var(--yellow);
}

.categoryBadge {
    display: inline-flex;
    align-items: center;

    gap: 6px;

    padding: 5px 10px;

    border-radius: 999px;

    background: rgba(37, 99, 235, 0.1);

    color: var(--primary);

    font-size: 0.72rem;
    font-weight: 600;
}

.habitInfo {
    display: flex;
    flex-wrap: wrap;

    gap: 7px;

    margin-top: 12px;
}

.badge {
    display: inline-flex;
    align-items: center;

    gap: 6px;

    padding: 6px 9px;

    border-radius: 999px;

    background: var(--card);

    border: 1px solid var(--border);

    font-size: 0.72rem;
    font-weight: 600;
}

.badge i {
    color: var(--primary);
}

.lastCompleted {
    display: flex;
    align-items: center;

    gap: 7px;

    margin-top: 10px;

    color: var(--text-light);

    font-size: 0.75rem;
}

.habitNotes {
    margin-top: 12px;

    padding: 12px;

    border-left: 3px solid var(--primary);

    border-radius: 8px;

    background: rgba(37, 99, 235, 0.06);

    font-size: 0.8rem;

    line-height: 1.5;
}

/* =========================================================
   HABIT BUTTONS
========================================================= */

.habitButtons {
    display: grid;

    grid-template-columns: repeat(2, 40px);

    gap: 8px;

    flex-shrink: 0;
}

.habitButtons button {
    width: 40px;
    height: 40px;

    border: 1px solid var(--border);

    border-radius: 10px;

    background: var(--background);

    color: var(--text);

    display: flex;
    align-items: center;
    justify-content: center;

    transition: 0.2s ease;
}

.habitButtons button:hover {
    transform: translateY(-2px);
}

.favoriteButton:hover {
    background: var(--yellow);
    color: white;
}

.renameButton:hover {
    background: #3b82f6;
    color: white;
}

.notesButton:hover {
    background: #6366f1;
    color: white;
}

.categoryButton:hover {
    background: #8b5cf6;
    color: white;
}

.completeButton:hover,
.completeButton.completed {
    background: var(--green);
    color: white;
}

.deleteButton:hover {
    background: var(--red);
    color: white;
}

/* =========================================================
   CALENDAR
========================================================= */

#calendarSection {
    min-width: 0;
    align-self: stretch;
    min-height: 0;
    height: auto;
    margin-bottom: 35px; 
}

.calendarContainer {
    padding: 16px;
    min-height: 0;
    height: 100%;
    box-sizing: border-box;
}

.calendar {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.calendarHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    flex: 0 0 auto;
}

.calendarHeader h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.calendarHeader button {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--background);
    color: var(--text);
    transition: 0.2s;
}

.calendarHeader button:hover {
    background: var(--primary);
    color: white;
}

.calendarWeekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    margin-bottom: 7px;
    text-align: center;
    color: var(--text-light);
    font-size: 0.78rem;
    font-weight: 600;
    flex: 0 0 auto;
}

.calendarGrid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 5px;
    align-content: start;
    flex: 0 0 auto;
}

.calendarGrid > div {
    aspect-ratio: 1 / 1;
    min-height: 0;
}

.calendarDay {
    width: 100%;
    min-height: 0;
    aspect-ratio: 1 / 1;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--background);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.15s;
}

.calendarDay:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.calendarDay.today {
    border: 1.5px solid var(--primary);
    color: var(--primary);
}

.calendarDay.completed {
    background: var(--green);
    color: white;
}

.calendarDay.otherMonth {
    opacity: 0.35;
}

#calendarDayDetails {
    flex: 1 1 auto;
    min-height: 92px;
    overflow-y: auto;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.calendarDetailsCard {
    margin: 0;
    padding: 0;
}

.calendarDetailsCard h3 {
    margin: 0 0 6px;
    font-size: 0.95rem;
    line-height: 1.3;
}

.calendarDetailsCard .noCompletions {
    margin: 0;
    color: var(--text-light);
    font-size: 0.78rem;
}

.completedHabitList {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.completedHabit {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 24px;
    font-size: 0.78rem;
}

.completedHabit i {
    color: var(--green);
}

/* =========================================================
   FAVORITES
========================================================= */

.favoriteHabits {
    display: grid;

    grid-template-columns: repeat(
        auto-fit,
        minmax(180px, 1fr)
    );

    gap: 10px;
}

.favoriteCard {
    display: flex;
    align-items: center;

    gap: 9px;

    padding: 13px 15px;

    font-size: 0.8rem;
}

.favoriteCard i {
    color: var(--yellow);
}


/* =========================================================
   HABIT PAGINATION
========================================================= */

.habitPagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;

    margin-top: 22px;
    margin-bottom: 6px;
    min-height: 40px;
}

.habitPageButton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;

    min-width: 38px;
    height: 38px;
    padding: 0 11px;

    border: 1px solid var(--border);
    border-radius: 10px;

    background: var(--card);
    color: var(--text);

    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;

    cursor: pointer;
    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        transform 0.18s ease,
        opacity 0.18s ease;
}

.habitPageButton:hover:not(:disabled) {
    background: var(--card-hover, var(--card));
    border-color: var(--primary);
    transform: translateY(-1px);
}

.habitPageButton.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.habitPageButton:disabled {
    opacity: 0.4;
    cursor: default;
}

.habitPageArrow {
    min-width: 76px;
}

@media (max-width: 500px) {

    .habitPagination {
        gap: 5px;
    }

    .habitPageArrow {
        min-width: 40px;
        padding: 0 9px;
    }

    .habitPageArrow span {
        display: none;
    }

}

/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 700px) {

    .habitControls {
        grid-template-columns: 1fr;
    }

    .habitToolbar {
        grid-template-columns: 1fr;
    }

    .habitHeader {
        flex-direction: column;
    }

    .habitButtons {
        grid-template-columns: repeat(6, 40px);
    }

}

@media (max-width: 500px) {

    .habitButtons {
        grid-template-columns: repeat(3, 40px);
    }

    .calendarDay {
        min-height: 31px;

        font-size: 0.7rem;
    }

}

/* =========================================================
   RESPONSIVE CALENDAR
========================================================= */

@media (max-width: 800px) {
    #calendarSection {
        margin-bottom: 0;
        height: auto;
    }

    #calendarSection .calendarContainer,
    #calendarSection .calendar {
        height: auto;
    }

    #calendarDayDetails {
        min-height: 90px;
        overflow-y: visible;
    }
}

@media (max-width: 500px) {
    .calendarHeader h3 {
        font-size: 1rem;
    }

    .calendarWeekdays {
        font-size: 0.72rem;
    }

    .calendarGrid {
        gap: 4px;
    }

    .calendarDay {
        font-size: 0.72rem;
        border-radius: 7px;
    }
}
