/* ========================================= */
/* === 1. Base Styles & General Layout === */
/* ========================================= */

body {
    font-family: Arial, sans-serif;
    background-color: #f4f4f9;
    color: #333;
    margin: 0;
    padding: 0;
    text-align: center;
}

header {
    background-color: #7ca8d4;
    color: rgb(11, 11, 11);
    padding: 20px 10px; 
    margin-bottom: 20px;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    /* Adjusted padding for better mobile flow */
    padding: 20px 0; 
}

h2 {
    text-align: center;
    margin-bottom: .2rem;
    margin-top: 2rem;
    font-family: Arial, sans-serif;
    font-size: 1.5rem;
    color: black;
}

p, p1 {
    text-align: center;
    margin-bottom: .1rem;
    font-family: Arial, sans-serif;
    font-size: 1.5rem;
}
p { color: red; } /* Fasting Window */
p1 { color: green; } /* Eating Window */


/* ========================================= */
/* === 2. Toggle Switch Styles & Controls === */
/* ========================================= */

.toggle-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 15px;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.fasting-label {
    margin: 0 10px;
    font-weight: bold;
    color: rgb(11, 11, 11);
    font-size: 0.9em;
}

/* The actual switch container */
.switch {
    position: relative;
    display: inline-block;
    width: 60px; 
    height: 34px; 
}

/* Hide default HTML checkbox */
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* The slider/track */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #f39c12; 
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px; 
    width: 26px; 
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #2ecc71;
}

/* Move slider to the right when checked (5/2) */
input:checked + .slider:before {
    transform: translateX(26px);
}

/* 5/2 Day Selector Controls */
#fiveTwoControls {
    margin-top: 15px;
    margin-bottom: 20px;
}
#fiveTwoControls label {
    font-size: 0.9em;
    font-weight: bold;
}
#fiveTwoControls select {
    padding: 5px;
    font-size: 0.9em;
    border-radius: 4px;
    border: 1px solid #ccc;
}
#fiveTwoControls p {
    font-size: 0.8rem;
    color: #555;
    margin-top: 5px;
}


/* ========================================= */
/* === 3. Calendar Grid Styles === */
/* ========================================= */

#calendarContainer {
    display: grid;
    /* Auto-fit up to 4 columns on wide screens */
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
}

.month-calendar {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    padding: 10px;
    min-width: 280px; 
}

.month-calendar h2 {
    margin-top: 0;
    color: #1abc9c;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 8px;
    font-size: 1.3rem;
}

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

.day-header {
    font-weight: bold;
    color: #2c3e50;
    padding: 5px 0;
    font-size: 0.7rem; 
}

.day-cell {
    padding: 5px 0;
    border-radius: 4px;
    cursor: default;
    transition: background-color 0.1s;
    font-weight: 500;
    font-size: 0.8rem;
    height: 20px; 
    line-height: 20px;
}

.empty {
    background: none !important;
    border: none !important;
}

/* Status-specific styles */
.fast-day {
    background-color: #fcebeb; /* Light Red */
    border: 1px solid #e74c3c;
    color: black;
}

.eat-day {
    background-color: #e8fce8; /* Light Green */
    border: 1px solid #2ecc71;
    color: black;
}

.day-cell.today {
    box-shadow: 0 0 0 3px #FFA500; /* Orange border for today */
    border: 2px solid #CC8400;
    font-weight: bold;
}

.day-cell:hover {
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}



/* Optional: Different background for completed fast days vs eat days */
.day-cell.completed-day.fast-day {
    background-color: #7a7a7a30; /* Light green background */
}
.day-cell.completed-day.eat-day {
    background-color: #7a7a7a33; /* Light grey background */
}


/* ================================================= */
/* === 4. Mobile Responsiveness (Media Query) === */
/* ================================================= */

@media (max-width: 600px) {
    
    main {
        padding: 10px 0; /* Resetting padding for mobile width */
        max-width: 100%;
    }

    /* Force single column for calendars on small screens */
    #calendarContainer {
        /* *** Defensive Fix for Mobile Display *** */
        display: grid; 
        grid-template-columns: 1fr;
        min-height: 500px; /* Ensure container has a visible height */
        width: 100%;
        overflow-x: hidden;
        padding: 0 5px; /* Small horizontal padding inside main */
        /* ************************************** */
    }
    
    .month-calendar {
        min-height: 200px; 
        width: 95%; 
        margin-left: auto;
        margin-right: auto;
        box-sizing: border-box; 
    }

    /* Reduce font sizes for header text */
    header h1 {
        font-size: 1.6rem;
    }
    header h2 {
        font-size: 1.1rem;
        margin-top: 1rem;
    }
    header p, header p1 {
        font-size: 1rem;
    }
    
    /* Adjust day grid size */
    .day-cell, .day-header {
        font-size: 0.65rem;
        padding: 3px 0;
        height: 16px;
        line-height: 16px;
    }
 




    /* Stack 5/2 controls vertically */
    #fiveTwoControls {
        display: flex;
        flex-direction: column;
        gap: 10px;
        align-items: center;
        margin-top:1rem;
    }
    #fiveTwoControls label {
        margin-left: 0 !important;
        margin-bottom: -5px;
        display: block;
    }
    #fiveTwoControls select {
        width: 80%;
        max-width: 250px;
        text-align: center;
    }
}
