/* General CSS Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base Body Styles */
body {
    font-family: Arial, sans-serif;
    background-color: #f4f7f6;
    color: #333;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

/* Header Styling */
.main-header {
    width: 100%;
    background-color: #2c3e50;
    color: #ecf0f1;
    padding: 15px 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    z-index: 1000;
    top: 0;
}

.main-header h1 {
    font-size: 1.8em;
}

.main-header a, .main-header .user-welcome {
    color: #ffda6a;
    text-decoration: none;
    font-weight: bold;
    transition: color 0.3s ease;
}

.main-header a:hover {
    color: #ffd14d;
}

.logout-link {
    margin-left: 15px;
    color: #dc3545;
}

/* Login/Register Form Layout */
.login-register-form {
    background-color: #fff;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 400px;
    margin: 50px auto;
    text-align: center;
}

.login-register-form h2 {
    color: #34495e;
    margin-bottom: 25px;
    font-size: 1.8em;
}

.login-register-form input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1em;
}

.login-register-form button {
    width: 100%;
    padding: 12px 15px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.login-register-form button:hover {
    background-color: #218838;
}

.login-register-form p {
    margin-top: 20px;
    font-size: 0.9em;
    color: #666;
}

.login-register-form p a {
    color: #007bff;
    text-decoration: none;
    font-weight: bold;
}

.login-register-form p a:hover {
    text-decoration: underline;
}

/* Message styling (for login/register feedback) */
.message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 5px;
    font-weight: bold;
}

.message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Main Content Containers */
.main-content-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    width: 90%;
    max-width: 1200px;
    margin: 20px auto;
}

.main-content-layout > div {
    background-color: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    flex: 1;
    min-width: 300px;
}

.main-content-layout h2, #chart-section h2 {
    color: #34495e;
    margin-top: 0;
    margin-bottom: 20px;
    text-align: center;
    font-size: 1.6em;
}

.input-form-container input[type="number"], .input-form-container textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
}

.input-form-container textarea {
    resize: vertical;
    min-height: 60px;
    max-height: 120px;
}

.input-form-container button {
    width: 100%;
    padding: 12px 15px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.input-form-container button:hover {
    background-color: #0056b3;
}

/* Reading History List */
.reading-list-container {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-top: 15px;
}

#reading-list {
    list-style-type: none;
    padding: 0;
}

#reading-list li {
    padding: 15px;
    margin-bottom: 10px;
    border: 1px solid #eee;
    border-left: 5px solid;
    border-radius: 5px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background-color: #fff;
}

#reading-list li:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

#reading-list li strong {
    font-size: 1.1em;
}

.category-label {
    display: inline-block;
    font-size: 0.8em;
    font-weight: bold;
    color: #fff;
    padding: 3px 8px;
    border-radius: 12px;
    margin-left: 10px;
}

.notes {
    font-size: 0.9em;
    color: #666;
    margin-top: 5px;
    font-style: italic;
}

/* Category-specific styling for list items */
.category-normal { border-left-color: #28a745; } /* Green */
.category-elevated { border-left-color: #ffc107; } /* Yellow */
.category-hypertension-stage-1 { border-left-color: #fd7e14; } /* Orange */
.category-hypertension-stage-2 { border-left-color: #dc3545; } /* Red */
.category-hypertensive-crisis { border-left-color: #6f42c1; } /* Purple */
.category-uncategorized { border-left-color: #6c757d; } /* Grey */

.category-normal .category-label { background-color: #28a745; }
.category-elevated .category-label { background-color: #ffc107; }
.category-hypertension-stage-1 .category-label { background-color: #fd7e14; }
.category-hypertension-stage-2 .category-label { background-color: #dc3545; }
.category-hypertensive-crisis .category-label { background-color: #6f42c1; }
.category-uncategorized .category-label { background-color: #6c757d; }


/* Chart Section */
#chart-section {
    max-width: 900px;
    width: 90%;
    margin: 20px auto;
}

/* Averages Section Styling */
#averages-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 90%;
    max-width: 600px;
    margin: 20px auto;
}

.average-group {
    background-color: #f8fcfc;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.average-group h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #007bff;
    font-size: 1.2em;
    text-align: center;
}

.average-group p {
    margin: 5px 0;
    font-size: 1em;
    color: #333;
    display: flex;
    justify-content: space-between;
}

.average-group p span {
    font-weight: bold;
    color: #2c3e50;
}

/* FullCalendar Overrides */
#calendar {
    max-width: 900px;
    height: 400px;
    margin: 0 auto;
}

.fc .fc-button {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

.fc .fc-button:hover {
    background-color: #0056b3;
    border-color: #0056b3;
}

.fc .fc-daygrid-event {
    background-color: #28a745;
    border-color: #28a745;
    color: white;
}

.fc .fc-daygrid-event:hover {
    background-color: #218838;
    border-color: #218838;
}

/* Utility and State-Based Styles */
.loading-container, #no-readings-message, #export-csv-link {
    display: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-header {
        flex-direction: column;
        padding: 15px 10px;
    }

    .main-header h1 {
        margin-bottom: 10px;
    }

    .main-content-layout {
        flex-direction: column;
        align-items: center;
        width: 95%;
    }

    .main-content-layout > div, #chart-section, #averages-section {
        width: 95%;
        margin: 10px auto;
        padding: 20px;
    }
}


/* Export Section Styling */
#export-section {
    background-color: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    margin: 20px auto;
    width: 90%;
    max-width: 500px;
    text-align: center;
}

#export-section h3 {
    color: #34495e;
    margin-bottom: 20px;
    font-size: 1.6em;
}

#export-section .input-group {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

#export-section label {
    font-size: 1em;
    color: #555;
    font-weight: bold;
}

#export-section input[type="month"] {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1em;
}


/* Export Section Button Styling */
#export-section .export-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px; /* Adds space between the button and the link */
    margin-top: 20px;
}

#export-section .action-button {
    padding: 12px 20px;
    font-size: 1.1em;
    font-weight: bold;
    text-align: center;
    text-decoration: none;
    color: #fff;
    background-color: #007bff; /* Blue button color */
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#export-section .action-button:hover {
    background-color: #0056b3; /* Darker blue on hover */
}

#export-section .export-link {
    background-color: #28a745; /* Green for export */
}

#export-section .export-link:hover {
    background-color: #218838; /* Darker green on hover */
}