/* --- 1. THEME DEFINITIONS --- */
/* This is our default "Light Theme" */
:root {
    --page-bg-color: #f4f4f4;
    --section-bg-color: #ffffff;
    --section-border-color: #ddd;
    --header-bg-color: #35424a;
    --header-text-color: #ffffff;
    --primary-text-color: #333;
    --secondary-text-color: #777;
    --accent-color-1: #35424a; /* Dark blue/grey for headers and buttons */
    --accent-color-2: #e8491d; /* Orange for logout button */
    --prayer-message-bg: transparent;
    --prayer-message-border: #c1a2d6;
    --prayer-message-text: #5d3a7d;
}

/* We can define a "Dark Theme" here for later */
body.dark-theme {
    --page-bg-color: #121212;
    --section-bg-color: #1e1e1e;
    --section-border-color: #444;
    --header-bg-color: #333333;
    --header-text-color: #e0e0e0;
    --primary-text-color: #e0e0e0;
    --secondary-text-color: #a0a0a0;
    --accent-color-1: #5f9ea0; /* Cadet blue */
    --accent-color-2: #f08080; /* Light coral */
    --prayer-message-border: #8a63a5;
    --prayer-message-text: #d3b3e6;
}

/* --- 2. GENERAL STYLES (Using Variables) --- */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--page-bg-color);
    color: var(--primary-text-color);
    line-height: 1.6;
}

header {
    justify-content: space-between;
    align-items: center;
    background-color: var(--header-bg-color);
    color: var(--header-text-color);
    padding: 1rem 0;
    text-align: center;
}

#header-left {
    display: flex;
    align-items: center;
    gap: 20px; /* Adds some space between the title and the theme switcher */
}

header h1 {
    margin: 0;
}

.app-container {
    display: flex; /* Using flexbox for layout */
    flex-wrap: wrap; /* Allow items to wrap to the next line on smaller screens */
    padding: 20px;
    gap: 20px; /* Space between sections */
    justify-content: center; /* Center sections if they don't fill the whole width */
}

.app-section {
    background-color: var(--section-bg-color);
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-width: 300px; /* Minimum width for each section */
    flex: 1; /* Allow sections to grow and fill available space */
    /* For a more column-like layout initially on larger screens, you might adjust flex-basis or width */
}

.add-item-form {
    display: flex;
    flex-direction: column; /* <<< This is the key fix: stacks items vertically */
    gap: 10px;
    margin-bottom: 20px;
}

/* Make sure all inputs and textareas in the form take up the full width */
.add-item-form input,
.add-item-form select,
.add-item-form textarea {
    width: 100%;
    padding: 8px;
    box-sizing: border-box; /* Ensures padding doesn't break the layout */
    margin-bottom: 0;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* --- Styles for Collapsible Panels (Corrected) --- */

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--accent-color-1);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

/* Remove the border from the h2 itself, as it's now on the header */
.app-section h2 {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.invite-info {
    background-color: #f9f9f9;
    border: 1px solid var(--section-border-color);
    padding: 10px;
    border-radius: 5px;
    margin: 10px 0;
}

#display-join-password {
    font-family: monospace;
    background-color: #e0e0e0;
    padding: 2px 6px;
    border-radius: 4px;
    color: #333;
}

#invite-qrcode-container {
    margin-top: 15px;
    padding: 10px;
    background-color: white;
    border: 1px solid var(--section-border-color);
    display: inline-block; /* Makes the container only as big as the QR code */
}

.panel-toggle-btn {
    background-color: transparent;
    border: 1px solid var(--secondary-text-color);
    color: var(--secondary-text-color);
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    width: 24px;
    height: 24px;
    line-height: 22px;
    text-align: center;
    padding: 0;
}

.panel-toggle-btn:hover {
    background-color: var(--page-bg-color);
}

/* THIS IS THE NEW, MORE RELIABLE RULE */
/* It finds any panel with the 'panel-collapsed' class
   and hides the '.panel-content' div inside it. */
.panel-collapsed .panel-content {
    display: none;
}


/* Style the button in the form */
.add-item-form button {
    width: auto; /* Let the button size itself */
    align-self: flex-start; /* Align button to the left */
    padding: 10px 15px; /* A bit more padding */
    cursor: pointer;
}
.modal-content.large {
    max-width: 900px; /* Make this modal wider */
    width: 90%;
}
.remind-discipline-btn {
    background: none;
    border: none;
    font-size: 1.1em;
    cursor: pointer;
    padding: 0 5px;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.remind-discipline-btn:hover {
    opacity: 1;
}


#user-status-area {
    text-align: right;
    padding: 0 20px 10px;
    color: var(--header-text-color);
}

#user-status-area button {
    margin-left: 10px;
    background-color: #e8491d;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
}
#user-status-area button:hover {
    background-color: #fA603a;
}

#daily-disciplines-list li, #weekly-disciplines-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}
.discipline-content {
    display: flex;
    align-items: center;
    flex-grow: 1;
}
.discipline-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fc-event-title {
    white-space: normal !important;
}

#auth-section {
    /* You might want specific styling for the auth section,
       e.g., making it a bit narrower if it's the only thing shown */
}

#auth-forms {
    display: flex;
    flex-direction: column; /* Stack forms on small screens */
    gap: 20px;
}

#auth-forms > div { /* Register and Login form containers */
    padding: 15px;
    border: 1px solid #eee;
    border-radius: 5px;
    background-color: #f9f9f9;
}

#auth-forms h2 {
    margin-top: 0;
    color: #35424a;
    border-bottom: 1px solid #ccc;
    padding-bottom: 5px;
}

#auth-forms div label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

#auth-forms div input[type="text"],
#auth-forms div input[type="password"] {
    width: calc(100% - 22px); /* Full width minus padding and border */
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

#auth-forms button[type="submit"] {
    background-color: #35424a;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
}

#auth-forms button[type="submit"]:hover {
    background-color: #4a5b66;
}

.auth-divider {
    border: none;
    border-top: 1px solid #ddd;
    margin: 10px 0;
}

.auth-message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 4px;
    text-align: center;
}
.auth-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.auth-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.discover-list {
    list-style: none;
    padding: 0;
    margin-top: 15px;
    max-height: 250px; 
    overflow-y: auto; 

}
.discover-list li {
    background-color: #f9f9f9;
    border: 1px solid #eee;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.discover-list p {
    margin: 0;
    color: #666;
    font-size: 0.9em;
}

.add-item-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.add-item-form input[type="text"] {
    flex-grow: 1; /* Input field takes available space */
    margin-bottom: 0; /* Remove bottom margin if it exists */
}
.add-item-form button {
    width: auto; /* Override width: 100% if it exists */
}

.group-tag {
    background-color: #e0eafc;
    color: #3d5a80;
    font-size: 0.7em;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 10px;
    font-weight: bold;
}

/* Show main content when user is logged in */
.main-content.visible {
    display: block !important; /* Override inline style if needed */
}
/* Style for the new group creation form section */
#create-group-section {
    /* Add specific styling if needed */
}

#create-group-form div {
    margin-bottom: 15px;
}

#create-group-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

#create-group-form input[type="text"] {
    width: calc(100% - 22px); /* Full width minus padding and border */
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

#create-group-form button[type="submit"] {
    background-color: #35424a;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
}

#create-group-form button[type="submit"]:hover {
    background-color: #4a5b66;
}

/* Rule 2: Tell the text itself how to break */
.message-content p {
    overflow-wrap: break-word;
}

/* Admin Panel Styles */


#admin-panel-section {
    /* This tells the admin panel to take up the 90% width of the page */
    min-width: 90%;
}

.admin-table-container {
    margin-top: 20px;
    /* This allows the container to shrink, which is key for overflow to work inside it */
    min-width: 0; 
}

.table-scroll-wrapper {
    width: 100%;
    /* This adds a scrollbar ONLY when the content inside is too wide */
    overflow-x: auto; 
}

.admin-table th, .admin-table td {
    /* This is the missing piece: it forces content onto one line,
       making the table wide enough to need the scrollbar. */
    margin:auto;
    max-width:500px;   
    overflow-wrap: anywhere;
    padding: 8px; /* Restoring padding for readability */
    text-align: left;
    border-bottom: 1px solid #ddd;
    
}	
/* Style for the Edit Group Button */
.secondary-btn {
    background-color: #6c757d;
    color: white;
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 10px;
}
.secondary-btn:hover {
    background-color: #5a6268;
}

/* Modal styles */
.modal-overlay {
    position: fixed; /* Stay in place */
    z-index: 100; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.5); /* Black w/ opacity */
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto; /* 15% from the top and centered */
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    border-radius: 8px;
    position: relative;
}

.modal-close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 10px;
    right: 20px;
}

.modal-close-btn:hover,
.modal-close-btn:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

/* Styles for Manage User Modal */
.user-management-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

#user-current-groups-list {
    list-style: none;
    padding-left: 0;
}

#user-current-groups-list li {
    display: flex;
    justify-content: space-between;
    align-items: start;
    padding: 8px;
    background-color: #f9f9f9;
    border-radius: 4px;
    margin-bottom: 5px;
}

#add-user-to-group-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

#add-user-group-selector {
    flex-grow: 1; /* Dropdown takes available space */
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.fc-daygrid-event {
    white-space: normal !important; /* Allow wrapping on the main event element */
}

.fc-daygrid-event-harness .fc-event {
    display: flex;
    flex-wrap: nowrap; /* Keep time and title on the same line initially */
    align-items: flex-start;
    gap: 4px; /* Adds a small space between the time and the title */
}

/* This ensures the time part doesn't shrink */
.fc-event-time {
    flex-shrink: 0;
}

/* This allows the title part to wrap if it's too long */
.fc-event-title {
    white-space: normal !important;
    flex-grow: 1;
}
/* Use a simple class to hide elements */
.hidden {
    display: none !important;
}


/* Responsive for auth forms */
@media (min-width: 768px) {
    #auth-forms {
        flex-direction: row; /* Place forms side-by-side on larger screens */
    }
    #auth-forms > div {
        flex: 1; /* Each form container takes equal space */
    }
    .auth-divider {
        display: none; /* Hide divider when side-by-side */
    }
}
.member-actions {
    display: flex;
    gap: 5px; /* Adds a small space between buttons */
}
.management-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    overflow-wrap: break-word;
}

#group-member-list {
    list-style: none;
    padding-left: 0;
    overflow-wrap: break-word;
}

#group-member-list li {
    display: flex;
    justify-content: space-between;
    align-items: start;
    padding: 8px;
    background-color: #f9f9f9;
    border-radius: 4px;
    margin-bottom: 5px;
    overflow-wrap: break-word;
}



/* If you want a more distinct two-column layout on wider screens for example: */
/*
@media (min-width: 768px) {
    .app-container {
        justify-content: space-around;
    }
    .app-section {
        flex-basis: 45%; / Roughly two columns
    }
}
*/

.message {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    overflow-wrap: break-word;
}

.message-content {
    min-width: 0;
}

/* This will make prayer requests stand out in the message feed */
.message.prayer-message {
    background-color: transparent;
    border: none;
    border-top: 1px dashed #c1a2d6;
    border-bottom: 1px dashed #c1a2d6;
    /* Reduce padding and margin for a more compact look */
    padding: 6px 8px; 
    margin-bottom: 6px;
    box-shadow: none;
}
.message.prayer-message p {
    font-style: italic;
    color: #5d3a7d;
    margin: 0; /* Remove default paragraph margin */
}
 	
.delete-message-btn {
    background: none;
    border: none;
    color: #cc0000;
    font-size: 1.2em;
    cursor: pointer;
    padding: 0 5px;
}
.app-section h2 {
    color: #35424a;
    margin-top: 0;
    border-bottom: 2px solid #35424a;
    padding-bottom: 10px;
}

.content-placeholder {
    margin-top: 15px;
    font-style: italic;
    color: #777;
}

.content-placeholder ul {
    list-style: none;
    padding: 0;
}

.content-placeholder li {
    padding: 5px 0;
}

.content-placeholder textarea {
    width: calc(100% - 22px); /* Adjust width considering padding/border */
    padding: 10px;
    margin-top: 10px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    min-height: 60px;
}

.content-placeholder button {
    background-color: #35424a;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
}

.content-placeholder button:hover {
    background-color: #4a5b66;
}

.message {
    background-color: #e9e9e9;
    padding: 8px;
    border-radius: 4px;
    margin-bottom: 8px;
}

#messages-container {
    max-height: 50vh; /* You can adjust this value to your liking (e.g., 60vh) */
    overflow-y: auto;  /* Add a vertical scrollbar ONLY when needed */
    border: 1px solid #eee;
    padding: 10px;
    display: flex; /* These help the inner elements behave correctly */
    flex-direction: column;
    
}

footer {
    text-align: center;
    padding: 20px;
    background-color: #333;
    color: #fff;
    margin-top: 30px;
}

/* --- FullCalendar Style Overrides --- */

/* Allow event titles to wrap onto multiple lines */
.fc-event-title-container, .fc-event-main {
    white-space: normal !important; /* Allow wrapping */
}

.fc-daygrid-event-dot {
    display: none; /* Hides the little dot next to the title for a cleaner look */
}

.fc-daygrid-event {
    /* Prevents the event from overflowing its day cell too much */
    overflow: hidden; 
}

.tabs {
    overflow: hidden;
    border-bottom: 1px solid #ccc;
    margin-bottom: 10px;
}
.tab-link {
    background-color: inherit;
    float: left;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 14px 16px;
    transition: 0.3s;
    font-size: 17px;
}
.tab-link:hover {
    background-color: #ddd;
}
.tab-link.active {
    background-color: #ccc;
    font-weight: bold;
}
.tab-content {
    display: none; /* Hide all tabs by default */
    padding: 6px 12px;
}
.tab-content.active {
    display: block; /* Show the active tab */
}
#daily-disciplines-list, #weekly-disciplines-list {
    list-style: none;
    padding: 0;
}

#task-list-ul {
    list-style: none;
    padding: 0;
}

#task-list-ul li {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    display: flex; /* For aligning checkbox and label nicely */
    align-items: center;
}

#task-list-ul li:last-child {
    border-bottom: none;
}

#task-list-ul input[type="checkbox"] {
    margin-right: 10px;
    /* Optional: custom styling for checkbox */
    width: 18px;
    height: 18px;
    cursor: pointer;
}

#task-list-ul label {
    flex-grow: 1; /* Label takes remaining space */
    cursor: pointer;
}

#task-list-ul li.completed label {
    text-decoration: line-through;
    color: #888;
}

#group-selection-section {
    /* Add any specific styling if needed */
}

#group-selection-section label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

#group-selector {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box; /* Ensures padding doesn't add to width */
}

#current-group-name-display {
    color: #35424a;
    font-size: 1.2em;
}

/* This rule will only apply to screens wider than 992px (laptops/desktops) */
@media (min-width: 992px) {

    /* We target the Daily Reading panel by its unique ID */
    #daily-reading {
        /* This sets the ideal width to 70% of the available space. 
           You can change this to 66% or 75% to get the exact size you like! */
        flex-basis: 70%;

        /* This tells it not to grow any further, keeping other panels from being too squished. */
        flex-grow: 0;
    }
}

/* On larger screens, make the calendar panel take up the full width */
@media (min-width: 1024px) {

    /* This part remains the same */
    .app-container {
        display: grid;
        grid-template-columns: 1fr 400px;
        align-items: flex-start;
        gap: 20px;
    }

    #main-column {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }

    /* --- SIMPLIFIED SIDEBAR STYLES --- */

    /* The message board is just a sticky container now.
       JavaScript will handle the height of its contents. */
    #message-board {
        position: sticky;
        top: 20px;
        max-height: calc(100vh - 40px); /* It can't be taller than the screen */
    }

    /* The message list needs overflow, but its height will be set by JS */
    #messages-container {
        overflow-y: auto;
        border: 1px solid var(--section-border-color);
        padding: 10px;
        margin: 15px 0;
    }
}