/* public/style.css */

/* --- General Body Styles --- */
body {
    margin: 0;
    padding: 0;
    line-height: 1.6;
    color: #333;
    font-family: 'Lato', Arial, sans-serif; /* Consistent font for body text */
}

/* --- Styles for the Main Application Page (index.html) --- */
body.app-body {
    background-color: #e9eff3; /* Slightly darker grey background for the app to make cards pop more */
}

.app-header {
    display: flex;
    justify-content: space-between; /* Pushes logo left, user info right */
    align-items: center;
    padding: 15px 30px; /* Add some padding */
    background-color: #ffffff; /* White background for header */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); /* Subtle shadow */
    margin-bottom: 20px; /* Space below header */
}

.container {
    max-width: 1200px; /* Increased max-width for two columns */
    margin: 0px auto 30px auto; /* Adjusted top margin for header */
    padding: 30px; /* Increased padding for better separation from edges */
    background-color: #e9eff3; /* Match body background to blend more, but still allow cards to stand out */
    border-radius: 8px; /* Keep outer border radius */
    box-shadow: none; /* Remove container shadow, sections will have it */
}

.container.guided-flow {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    align-items: flex-start;
}

/* --- Card/Section Styling for index.html and now login.html --- */
.card {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15); /* More prominent shadow for cards */
    padding: 20px;
    margin-bottom: 0; /* Managed by column gap */
    display: flex; /* Make card a flex container */
    flex-direction: column; /* Stack children vertically */
}

.step-card {
    position: relative;
}

.step-header {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 10px;
}

.step-title {
    margin: 0;
    font-family: 'Playfair Display', serif;
    font-size: 1.7em;
    line-height: 1.2;
    color: #2c3e50;
}

.step-pill {
    background-color: #25B4D0;
    color: #fff;
    font-size: 0.85em;
    font-weight: bold;
    padding: 6px 14px;
    border-radius: 999px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap; /* Keep "STEP #" on one line even on narrow cards */
}

.step-hint {
    margin: 4px 0 0;
    color: #5d6d7e;
    font-size: 0.9em;
    line-height: 1.4;
}

.step-helper-text {
    margin: 0 0 15px;
    color: #6c757d;
    font-size: 0.9em;
}

.step-helper-text + textarea {
    margin-top: 5px;
}

/* Specific styling for sections */
.sms-message-section {
    /* Styles specific to the SMS message input area */
}

.people-list-section {
    /* Styles specific to the filtered people list */
}

.sms-history-section {
    /* Styles specific to the SMS history table */
}

.tag-filter-section {
    /* The card is now a flex container, so its direct children will stack */
    /* Remove overflow and max-height from here, apply to inner container */
}

/* NEW: Style for the inner tag container to be scrollable */
#tagFilter { /* This is the div that contains the tagLoadingIndicator and tag-content-wrapper */
    flex-grow: 1; /* Allows this section to take available vertical space */
    max-height: 300px; /* Set a max height for the scrollable tags list */
    overflow-y: auto; /* Enable vertical scrolling */
    border: 1px solid #eee;
    border-radius: 5px;
    padding: 10px;
    background-color: #fdfdfd;
    margin-bottom: 15px; /* Space between scrollable list and button */
}

/* --- Login Page Specific Styles (login.html) --- */
body.login-body {
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Align header to top */
    min-height: 100vh; /* Full viewport height */
    background-color: #e9eff3; 
    font-family: 'Lato', Arial, sans-serif;
    color: #333;
}

.login-page-main-content {
    flex-grow: 1; /* Allows this content to take up remaining vertical space */
    display: flex;
    justify-content: center;
    align-items: center; /* Centers the login-card */
    width: 100%; /* Take full width */
    padding: 20px 0; /* Add some vertical padding */
}

.login-card {
    text-align: center;
    max-width: 400px; /* Max width for the login card */
    width: 90%; /* Responsive width */
    padding: 40px; /* Consistent padding */
    /* .card already provides background, border-radius, box-shadow */
}

/* Harvest Church Logo specific styling - for both login and app header */
.logo {
    max-width: 200px; /* Consistent size */
    height: auto;
    display: block; /* Ensures it takes its own line */
}

/* Specific logo styling for app header to align left (this now applies to login page header too) */
.app-header .logo {
    margin: 0; /* Override centering, align left by default in flex */
    max-width: 220px; 
}

.login-card h1 { /* Changed from .login-container h1 */
    margin-top: 0px; 
    font-size: 2.2em; /* Larger font size */
    margin-bottom: 20px; /* Increased bottom margin */
    font-family: 'Playfair Display', serif;
    color: #2c3e50;
}

.login-card p { /* Changed from .login-container p */
    margin-bottom: 30px;
    color: #666;
    line-height: 1.5;
}

.login-btn {
    display: inline-block;
    padding: 12px 25px;
    background-color: #ffffff;
    color: #333333;
    text-decoration: none;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-weight: bold;
    transition: all 0.3s ease;
    display: flex; /* Use flexbox for icon and text alignment */
    align-items: center;
    justify-content: center;
    gap: 10px; /* Space between icon and text */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.login-btn:hover {
    background-color: #f0f0f0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.login-btn img {
    width: 24px;
    height: 24px;
}

/* --- User Info Container (for logout button and user details) --- */
/* Now directly inside .app-header, so relative positioning is not needed here */
.user-info-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end; /* Align items to the right */
    text-align: right; /* Align text to the right */
}

.user-info {
    margin: 0;
    padding: 0;
    color: #555;
    font-size: 0.9em;
}

#userNameDisplay {
    font-weight: bold;
    font-size: 1.1em;
    color: #25B4D0; /* Accent color for user name */
}

.logout-button {
    background-color: #f44336; /* Red for logout */
    color: white;
    padding: 6px 12px; /* Smaller padding */
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.75em; /* Smaller font size */
    margin-top: 5px; /* Less space above button */
    transition: background-color 0.3s ease;
    align-self: flex-end; /* Keep aligned to the right */
}

.logout-button:hover {
    background-color: #d32f2f;
}

/* --- SMS Message Section --- */
h1 {
    color: #2c3e50;
    margin-top: 0;
    margin-bottom: 15px;
    font-family: 'Playfair Display', serif; /* Consistent font for headings */
}

textarea {
    width: calc(100% - 20px); /* Adjust for padding */
    padding: 10px;
    margin-bottom: 5px; /* Reduced margin to bring char count closer */
    border: 1px solid #ddd;
    border-radius: 5px;
    resize: vertical; /* Allow vertical resizing */
    min-height: 80px;
    font-family: 'Lato', Arial, sans-serif;
}

.char-count {
    font-size: 0.8em;
    color: #777;
    text-align: right;
    margin-bottom: 10px; /* Space below char count */
}

button {
    background-color: #25B4D0; /* Primary accent color */
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease, transform 0.1s ease;
    width: auto; /* Allow button to size naturally */
    display: inline-block; /* For side-by-side buttons */
    margin-right: 10px; /* Space between buttons */
}

/* Style for disabled buttons to show not-allowed cursor */
button:disabled {
    cursor: not-allowed !important; /* Override default cursor for disabled state */
}

button:hover {
    background-color: #1a8fa6;
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

/* General input text field styling */
.text-input {
    width: calc(100% - 20px); /* Adjust for padding */
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-family: 'Lato', Arial, sans-serif;
    box-sizing: border-box; /* Ensures padding doesn't increase total width */
}

/* --- People List Section --- */
.people-list {
    border: 1px solid #eee; /* Keep border for internal list */
    border-radius: 5px; /* Keep internal list rounded corners */
    max-height: 400px; /* Max height for scrollability */
    overflow-y: auto; /* Enable vertical scrolling */
    padding: 10px;
    background-color: #fdfdfd; /* Lighter background for internal list */
}

.person-item {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed #eee;
}

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

.person-item input[type="checkbox"] {
    margin-right: 10px;
    transform: scale(1.2); /* Slightly larger checkbox */
}

.person-item label {
    cursor: pointer;
    flex-grow: 1; /* Allow label to take available space */
}

.person-item input[type="checkbox"]:disabled + label {
    color: #aaa;
    font-style: italic;
    cursor: not-allowed;
}

.selection-controls {
    display: flex; /* Use flexbox for horizontal buttons */
    gap: 10px; /* Space between buttons */
    margin-bottom: 15px;
    justify-content: flex-start; /* Align buttons to the start */
}

.selection-controls button {
    padding: 8px 12px;
    font-size: 0.9em;
    background-color: #5cb85c; /* Green for selection buttons */
}

.selection-controls button:hover {
    background-color: #4cae4c;
}

/* --- Tag Filter Section --- */
/* The card class already makes this a flex column.
   We just need to ensure the h1, then #tagFilter (scrollable),
   then the button and cooldown wrapper stack correctly. */

/* Style for the inner tag container to be scrollable */
.tag-content-wrapper { /* This is the div that contains the actual tags/folders */
    flex-grow: 1; /* Allows this section to take available vertical space */
    max-height: 300px; /* Set a max height for the scrollable tags list */
    overflow-y: auto; /* Enable vertical scrolling */
    /* Remove border/padding/background from here, they are on #tagFilter */
}

.tag-node {
    margin-bottom: 5px;
}

.folder-header {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: bold;
    color: #333;
    padding: 5px 0;
}

/* Styling for folder checkboxes */
.folder-header input[type="checkbox"] {
    margin-left: 10px; /* Space between toggle and checkbox */
    margin-right: 8px; /* Space between checkbox and label */
    transform: scale(1.2); /* Make checkbox slightly larger */
}

.folder-toggle {
    margin-right: 8px;
    transition: transform 0.2s ease;
    display: inline-block; /* Ensure it respects transform */
}

.folder-toggle.expanded {
    transform: rotate(90deg);
}

.folder-children {
    margin-left: 20px; /* Indent children */
    border-left: 1px dotted #ccc; /* Visual indicator for nesting */
    padding-left: 10px;
}

.tag-item {
    display: flex;
    align-items: center;
    padding: 3px 0;
}

.tag-item input[type="checkbox"] {
    margin-right: 8px;
}

/* --- SMS History Section --- */
.sms-history-controls {
    margin-bottom: 15px;
    text-align: right; /* Align refresh button to the right */
}

.sms-history-controls button {
    background-color: #6c757d; /* Grey for refresh button */
}

.sms-history-controls button:hover {
    background-color: #5a6268;
}

.sms-history-container {
    border: 1px solid #eee; /* Keep border for internal list */
    border-radius: 5px; /* Keep internal list rounded corners */
    max-height: 500px; /* Max height for scrollability */
    overflow-y: auto; /* Enable vertical scrolling */
    background-color: #fdfdfd; /* Lighter background for internal list */
}

#smsHistoryTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

#smsHistoryTable th,
#smsHistoryTable td {
    padding: 10px;
    border-bottom: 1px solid #eee;
    text-align: left;
}

#smsHistoryTable th {
    background-color: #f2f2f2;
    font-weight: bold;
    color: #555;
}

#smsHistoryTable tbody tr:nth-child(even) {
    background-color: #fafafa;
}

#smsHistoryTable tbody tr:hover {
    background-color: #e9f7fc; /* Light blue on hover */
}

/* Status specific styling */
.status-delivered {
    color: #28a745; /* Green */
    font-weight: bold;
}

.status-failed {
    color: #dc3545; /* Red */
    font-weight: bold;
}

.status-pending {
    color: #ffc107; /* Yellow/Orange */
    font-weight: bold;
}

/* NEW: Legend Item Styling */
.legend-item {
    display: inline-flex;
    align-items: center;
    margin-right: 10px;
}

.legend-item span:first-child {
    font-size: 0.9em;
    margin-right: 5px;
}

/* NEW: Pagination Controls Styling */
.pagination-controls {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    color: #555;
}

.pagination-controls button {
    background-color: #6c757d; /* Match refresh button */
    color: white;
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.3s ease, transform 0.1s ease;
}

.pagination-controls button:hover {
    background-color: #5a6268;
    transform: translateY(-1px);
}

.pagination-controls button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* --- Message Box Styling --- */
.message-box {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 25px;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1000;
    min-width: 250px;
}

.message-box.show {
    opacity: 1;
    visibility: visible;
}

.message-box.info {
    background-color: #17a2b8; /* Blue-ish for info */
}

.message-box.success {
    background-color: #28a745; /* Green for success */
}

.message-box.error {
    background-color: #dc3545; /* Red for error */
}

.message-box.warning {
    background-color: #ffc107; /* Orange for warning */
    color: #333; /* Darker text for warning */
}

/* --- Loading Indicator Styling --- */
.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    font-style: italic;
    color: #777;
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: #25B4D0;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Responsive adjustments --- */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 15px;
    }

    .app-header .logo {
        margin-bottom: 10px;
    }

    .user-info-container {
        align-items: flex-start;
        text-align: left;
        width: 100%; /* Take full width on small screens */
    }

    .logout-button {
        align-self: flex-start; /* Align to the left on small screens */
        margin-top: 15px;
    }

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

    .container.guided-flow {
        grid-template-columns: 1fr;
    }

    .selection-controls {
        flex-direction: column; /* Stack buttons vertically */
        gap: 8px;
    }

    .selection-controls button {
        width: 100%; /* Full width buttons */
        margin-right: 0;
    }

    .sms-history-controls {
        text-align: left; /* Align refresh button to the left on small screens */
    }

    .pagination-controls {
        flex-direction: column;
        gap: 8px;
    }

    .pagination-controls button {
        width: 100%;
    }
}
