/* public/css/style.css */

/* General Body and Container Styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f7f6;
    color: #333;
    line-height: 1.6;
    overflow-x: hidden; /* Added to prevent horizontal scroll */
}

.container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    overflow: visible; /* Ensure content flows out if needed, though modals are usually body children */
}

/* Navbar Styles */
.navbar {
    background-color: #007bff; /* Keep existing blue background */
    color: #fff;
    padding: 10px 20px; /* Slightly reduced padding for a more compact look */
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping for better responsiveness */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: sticky; /* Keep sticky for navigation */
    top: 0;
    z-index: 1000; /* Ensure it's above most content, but below Bootstrap modals (1050/1055) */
}

.navbar h1 {
    margin: 0;
    font-size: 1.8em; /* Keep existing font size */
    font-weight: 600;
}

.navbar .menu-toggle {
    display: none; /* Hidden on larger screens */
    font-size: 2em;
    cursor: pointer;
    color: #fff; /* Ensure toggle icon is white */
}

.navbar .nav-links {
    display: flex;
    gap: 15px; /* Slightly reduced gap for a tighter navigation */
    align-items: center;
}

.navbar .nav-links a {
    color: #fff;
    text-decoration: none;
    padding: 10px 15px; /* Adjusted padding for better clickable area */
    border-radius: 5px;
    transition: background-color 0.3s ease;
    white-space: nowrap; /* Prevent text wrapping in nav links */
}

.navbar .nav-links a:hover,
.navbar .nav-links a.active {
    background-color: rgba(255, 255, 255, 0.2); /* Keep existing hover effect */
}

/* Dropdown specific styling */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropbtn {
    color: #fff; /* Match main nav links color */
    padding: 10px 15px; /* Match main nav links padding */
    text-decoration: none;
    display: block;
    background-color: transparent;
    border: none;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    white-space: nowrap;
    border-radius: 5px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.dropbtn:hover {
    background-color: rgba(255, 255, 255, 0.2); /* Match main nav links hover effect */
}

.dropdown-content {
    display: none; /* Hidden by default */
    position: absolute;
    background-color: #0069d9; /* Darker blue, consistent with mobile nav background */
    min-width: 180px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.4); /* Stronger shadow for depth */
    z-index: 1001; /* Ensure it's above the navbar */
    left: 0;
    top: 100%;
    border-radius: 5px;
    overflow: hidden; /* Ensures content respects border-radius */
    animation: fadeIn 0.3s ease-out; /* Smooth fade-in animation */
}

/* Keyframe for fade-in animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-content a {
    color: #fff; /* White text for sub-menu items */
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
    transition: background-color 0.3s ease;
}

.dropdown-content a:hover {
    background-color: rgba(255, 255, 255, 0.1); /* Subtle hover effect for sub-menu */
}

/* Show dropdown content on hover */
.dropdown:hover .dropdown-content {
    display: block;
}

/* Icon styling for dropdown caret */
.dropbtn .fa-caret-down {
    margin-left: 5px;
    transition: transform 0.3s ease; /* Smooth rotation for caret */
}

.dropdown:hover .dropbtn .fa-caret-down {
    transform: rotate(180deg); /* Rotate caret on hover */
}

/* Logout link specific styling for multi-line */
.nav-links .logout-link {
    display: flex;
    flex-direction: column; /* Stack content vertically */
    align-items: center; /* Center horizontally */
    text-align: center; /* Center text */
    line-height: 1.2; /* Adjust line height for better spacing */
    padding: 5px 15px; /* Adjusted padding to fit multi-line content */
    color: #fff; /* Ensure text is white */
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

.nav-links .logout-link:hover {
    background-color: rgba(255, 255, 255, 0.2); /* Consistent hover effect */
}


/* Page Title Styles */
.page-title {
    text-align: center;
    color: #007bff;
    margin-top: 20px;
    margin-bottom: 30px;
    font-size: 2.2em;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

/* Messages (Success/Error/Warning) */
.message {
    padding: 12px 20px;
    margin-bottom: 20px;
    border-radius: 6px;
    font-weight: bold;
    text-align: center;
    opacity: 1; /* Default opacity */
    transition: opacity 0.5s ease-out; /* For fade-out effect */
}

.message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

/* Form Section Styles */
.form-section, .list-section {
    background-color: #fcfcfc;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.05);
}

.form-section h3, .list-section h3 {
    color: #007bff;
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.5em;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

form {
    display: flex;
    flex-direction: column;
}

form label {
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
    font-size: 0.95em;
}

form input[type="text"],
form input[type="password"],
form input[type="email"],
form input[type="number"],
form input[type="date"],
form input[type="month"],
form select,
form textarea {
    padding: 10px 12px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1em;
    width: calc(100% - 24px); /* Account for padding */
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

form input[type="text"]:focus,
form input[type="password"]:focus,
form input[type="email"]:focus,
form input[type="number"]:focus,
form input[type="date"]:focus,
form input[type="month"]:focus,
form select:focus,
form textarea:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
    outline: none;
}

form textarea {
    resize: vertical;
    min-height: 80px;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 15px;
    align-items: center;
}

.checkbox-group input[type="checkbox"] {
    margin-right: 5px;
    width: auto; /* Override 100% width */
}

.checkbox-group label {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    font-weight: normal;
}

.required-field {
    color: red;
    margin-left: 4px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    font-size: 1em;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
    border: 1px solid transparent;
    margin-top: 10px;
    margin-right: 10px; /* For multiple buttons */
}

.btn-primary {
    background-color: #007bff;
    color: #fff;
    border-color: #007bff;
}

.btn-primary:hover {
    background-color: #0056b3;
    border-color: #0056b3;
}

.btn-secondary {
    background-color: #6c757d;
    color: #fff;
    border-color: #6c757d;
}

.btn-secondary:hover {
    background-color: #5a6268;
    border-color: #545b62;
}

.btn-danger {
    background-color: #dc3545;
    color: #fff;
    border-color: #dc3545;
}

.btn-danger:hover {
    background-color: #c82333;
    border-color: #bd2130;
}

.btn-info {
    background-color: #17a2b8;
    color: #fff;
    border-color: #17a2b8;
}

.btn-info:hover {
    background-color: #138496;
    border-color: #117a8b;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85em;
    margin-top: 0;
    margin-right: 5px;
}

/* Table Styles */
.table-responsive {
    overflow-x: auto; /* Enable horizontal scrolling on small screens */
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background-color: #fff;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    overflow: hidden; /* Ensures border-radius applies to content */
}

.data-table th,
.data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.data-table th {
    background-color: #007bff;
    color: #fff;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.9em;
}

.data-table tbody tr:nth-child(even) {
    background-color: #f8f8f8;
}

.data-table tbody tr:hover {
    background-color: #f1f1f1;
}

.data-table td a.btn {
    margin-top: 0;
    margin-right: 5px;
}

/* Login Box */
.login-box {
    width: 100%;
    max-width: 400px;
    margin: 80px auto;
    padding: 40px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.login-box h2 {
    color: #007bff;
    margin-bottom: 30px;
    font-size: 2em;
}

.login-box form {
    align-items: center;
}

.login-box form input {
    width: calc(100% - 24px); /* Adjust for padding */
    margin-bottom: 20px;
}

.login-box form button {
    width: 100%;
    padding: 12px;
    font-size: 1.1em;
    margin-top: 10px;
}

/* Footer Styles */
footer {
    text-align: center;
    padding: 20px;
    margin-top: 40px;
    color: #777;
    font-size: 0.9em;
    border-top: 1px solid #eee;
    background-color: #f9f9f9;
}

/* Schedule Page Specific Styles */
.schedule-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 25px;
    padding: 15px;
    background-color: #e9f5ff;
    border-radius: 8px;
    border: 1px solid #cce5ff;
    gap: 15px;
}

.schedule-controls .inline-form {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0; /* Override default form margin */
}

.schedule-controls .inline-form label {
    margin-bottom: 0;
    font-weight: normal;
}

.schedule-controls .inline-form select,
.schedule-controls .inline-form input[type="month"],
.schedule-controls .inline-form input[type="date"] {
    margin-bottom: 0;
    width: auto;
    min-width: 150px;
}

.schedule-controls .month-navigation {
    display: flex;
    align-items: center;
    gap: 15px;
}

.schedule-controls .month-navigation h3 {
    margin: 0;
    font-size: 1.4em;
    color: #007bff;
}

.schedule-controls .export-buttons {
    display: flex;
    gap: 10px;
}

/* Calendar Styles */
.calendar {
    margin-top: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background-color: #fff;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.05);
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background-color: #007bff;
    color: #fff;
    padding: 10px 0;
    font-weight: bold;
    text-align: center;
    font-size: 0.95em;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-left: 1px solid #eee;
    border-top: 1px solid #eee;
}

.calendar-day {
    border-right: 1px solid #eee;
    border-bottom: 1px solid #eee;
    min-height: 120px;
    padding: 10px;
    position: relative;
    background-color: #fff;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.calendar-day:hover {
    background-color: #f0f8ff;
}

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

.calendar-day.today {
    background-color: #e6f7ff;
    border: 2px solid #007bff;
    padding: 8px; /* Adjust padding for border */
}

.calendar-day.holiday {
    background-color: #ffe6e6; /* Light red for holidays */
}

.calendar-day .day-number {
    font-weight: bold;
    font-size: 1.2em;
    color: #333;
    margin-bottom: 5px;
}

.calendar-day .day-info {
    font-size: 0.85em;
    color: #666;
}

.calendar-day .day-info p {
    margin: 2px 0;
}

.calendar-day .day-notes {
    font-style: italic;
    color: #888;
}

.calendar-day .assigned-lifeguards-summary {
    list-style: none;
    padding: 0;
    margin: 5px 0 0 0;
    font-size: 0.8em;
}

.calendar-day .assigned-lifeguards-summary li {
    margin-bottom: 2px;
    color: #333;
}

.calendar-day .lifeguard-count {
    font-weight: bold;
    margin-top: 5px;
}

.calendar-day.lifeguard-shortage {
    background-color: #ffe0b2; /* Light orange for shortage */
    border: 2px solid #ff9800;
}

/* Removed custom .modal and .modal-content styles to avoid conflict with Bootstrap */

/* Assigned Lifeguard Entry (within modal/form) */
.assigned-lifeguard-entry {
    border: 1px solid #e0e0e0;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
    background-color: #fcfcfc;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.assigned-lifeguard-entry select,
.assigned-lifeguard-entry input[type="number"] {
    flex: 1;
    min-width: 120px;
    margin-bottom: 0; /* Override default form input margin */
}

.assigned-lifeguard-entry .calculated-pay {
    font-weight: bold;
    color: #28a745;
    margin-left: auto;
    white-space: nowrap; /* Prevent wrapping */
}

.assigned-lifeguard-entry .btn-danger {
    margin-top: 0;
    margin-left: 10px;
}

/* Time Setting Group (pools.php) */
.time-setting-group {
    border: 1px solid #e0e0e0;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 8px;
    background-color: #fcfcfc;
}

.time-setting-group h5 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #007bff;
    font-size: 1.2em;
    border-bottom: 1px dashed #eee;
    padding-bottom: 5px;
}

.time-setting-group label {
    display: inline-block;
    width: 80px; /* Align labels */
    margin-right: 10px;
    margin-bottom: 8px;
}

.time-setting-group input[type="number"] {
    width: 100px;
    margin-right: 20px;
    margin-bottom: 8px;
}

.time-setting-group .btn {
    margin-top: 0;
    margin-bottom: 8px;
}

/* Roster Export Table (roster_export.php) */
.roster-table th,
.roster-table td {
    white-space: nowrap; /* Prevent content from wrapping in narrow columns */
    padding: 8px 10px;
    font-size: 0.85em;
}

.roster-table th:first-child,
.roster-table td:first-child {
    position: sticky;
    left: 0;
    background-color: #007bff; /* Sticky header background */
    z-index: 2;
    box-shadow: 2px 0 2px rgba(0, 0, 0, 0.05); /* Shadow for sticky column */
}

.roster-table td:first-child {
    background-color: #fff; /* Sticky cell background */
}

.roster-table tbody tr:nth-child(even) td:first-child {
    background-color: #f8f8f8; /* Alternating background for sticky column */
}

.roster-text-summary {
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    padding: 15px;
    border-radius: 5px;
    font-family: monospace;
    white-space: pre-wrap; /* Preserve whitespace and wrap text */
}

/* New multi-line assignment entry styles for lifeguard_schedule.php */
.assignment-entry {
    border: 1px solid #ddd;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
    background-color: #f9f9f9;
}

.assignment-entry .form-row {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping */
    gap: 15px; /* Spacing between fields */
    margin-bottom: 10px;
}

.assignment-entry .form-group {
    flex: 1; /* Allow each group to fill space */
    min-width: 180px; /* Minimum width to prevent excessive squeezing */
    display: flex;
    flex-direction: column;
}

.assignment-entry label {
    font-weight: bold;
    margin-bottom: 5px;
    color: #555;
    font-size: 0.9em;
}

.assignment-entry input[type="date"],
.assignment-entry input[type="number"],
.assignment-entry select {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1em;
    width: 100%; /* Ensure inputs and selects fill their container */
    box-sizing: border-box; /* Include padding and border in width */
}

.assignment-entry .action-row {
    display: flex;
    justify-content: flex-end; /* Buttons to the right */
    align-items: center;
    margin-top: 10px;
}

.assignment-entry .calculated-pay {
    font-weight: bold;
    color: #007bff;
    margin-right: auto; /* Push total to the left */
    font-size: 1.1em;
}

/* Responsive Adjustments */
@media (max-width: 992px) {
    .navbar .nav-links {
        gap: 10px;
    }
    .navbar .nav-links a {
        padding: 6px 10px;
        font-size: 0.9em;
    }
}

@media (max-width: 768px) {
    .navbar {
        flex-direction: column; /* Stack items vertically */
        align-items: flex-start; /* Align items to the left */
        flex-wrap: wrap;
        padding: 10px 15px;
    }
    .navbar h1 {
        width: 100%;
        text-align: center;
        margin-bottom: 10px;
    }
    .navbar .menu-toggle {
        display: block;
        position: absolute;
        right: 15px;
        top: 15px;
        font-size: 28px; /* Larger icon for touch */
        color: white; /* Ensure it's visible */
    }
    .navbar .nav-links {
        flex-direction: column;
        width: 100%;
        gap: 0; /* Remove gap when stacked vertically */
        display: none; /* Hidden by default on mobile */
        text-align: center;
        background-color: #0069d9; /* Darker blue for dropdown menu */
        border-radius: 5px;
        margin-top: 10px;
    }
    .navbar .nav-links.active {
        display: flex; /* Show when active */
    }
    .navbar .nav-links a, .dropbtn {
        width: 100%;
        text-align: left; /* Align text to the left */
        padding: 12px 20px; /* Larger touch target */
        border-radius: 0; /* No border-radius for full-width items */
        border-bottom: 1px solid rgba(255, 255, 255, 0.1); /* Separator */
    }
    .navbar .nav-links a:last-child {
        border-bottom: none;
    }

    /* Mobile dropdown specific styles */
    .dropdown {
        width: 100%;
    }
    .dropdown-content {
        position: static; /* Stack statically in mobile */
        width: 100%;
        box-shadow: none; /* Remove shadow */
        border-radius: 0;
        background-color: #0056b3; /* Even darker blue for nested sub-menus */
        animation: none; /* Disable animation for mobile */
        border-top: 1px solid rgba(255, 255, 255, 0.1); /* Separator */
    }
    .dropdown-content a {
        padding-left: 40px; /* Indent sub-menu items */
    }

    .container {
        margin: 10px auto;
        padding: 15px;
    }

    .page-title {
        font-size: 1.8em;
    }

    .form-section, .list-section {
        padding: 15px;
    }

    form input[type="text"],
    form input[type="password"],
    form input[type="email"],
    form input[type="number"],
    form input[type="date"],
    form input[type="month"],
    form select,
    form textarea {
        width: calc(100% - 20px); /* Adjust padding for smaller screens */
    }

    .checkbox-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .btn {
        width: 100%;
        margin-right: 0;
        margin-bottom: 10px;
    }

    .schedule-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .schedule-controls .inline-form {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        width: 100%;
    }
    .schedule-controls .inline-form select,
    .schedule-controls .inline-form input {
        width: 100%;
        min-width: unset;
    }
    .schedule-controls .month-navigation {
        width: 100%;
        justify-content: space-between;
    }
    .schedule-controls .export-buttons {
        width: 100%;
        flex-direction: column;
    }

    .calendar-day {
        min-height: 100px;
        padding: 8px;
    }
    .calendar-day .day-number {
        font-size: 1em;
    }
    .calendar-day .day-info {
        font-size: 0.75em;
    }

    /* Modal content will be handled by Bootstrap now */

    /* Responsive adjustments for new assignment entry */
    .assignment-entry .form-row {
        flex-direction: column; /* Stack vertically on small screens */
    }
    .assignment-entry .form-group {
        min-width: unset; /* Remove min-width constraint */
        width: 100%;
    }
    .assignment-entry .action-row {
        flex-direction: column;
        align-items: stretch;
    }
    .assignment-entry .calculated-pay {
        margin-right: 0;
        margin-bottom: 10px;
        text-align: center;
    }
    .assignment-entry .btn-danger {
        width: 100%;
        margin-left: 0;
    }

    /* Logout link mobile adjustments */
    .nav-links .logout-link {
        align-items: flex-start; /* Align to left on mobile */
        text-align: left;
        padding: 12px 20px; /* Match other mobile links */
    }
}

@media (max-width: 480px) {
    .login-box {
        padding: 20px;
        margin: 40px auto;
    }
    .login-box h2 {
        font-size: 1.5em;
    }
}

/* Autocomplete Styles (from original file) */
.autocomplete-suggestions {
    position: absolute;
    border: 1px solid #ddd;
    background-color: #fff;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    width: calc(100% - 2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    display: none;
    top: 100%;
    left: 0;
}

.suggestion-item {
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background-color: #f0f0f0;
}

.suggestion-item.no-results {
    color: #888;
    cursor: default;
    font-style: italic;
}

.inline-form {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.inline-form label {
    white-space: nowrap;
}

.inline-form input[type="text"],
.inline-form input[type="month"] {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

#pool_search_input {
    flex-grow: 1;
    min-width: 150px;
}

.explanation-note {
    margin-top: 20px;
    padding: 10px;
    background-color: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    font-size: 0.9em;
    color: #555;
}