/* * =========================================================
 * UPDATED STYLE.CSS - WHATSAPP-STYLE INDEPENDENT SCROLLING
 * =========================================================
 */

/* =======================================
   GENERAL STYLES & LAYOUT BASE
   ======================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100vh; /* Force height to match window */
    width: 100vw;
    margin: 0;
    padding: 0;
    overflow: hidden; /* CRITICAL: Prevents the entire page from scrolling */
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column; /* Header on top, Container below */
    background-color: #f4f7f9;
    color: #333;
}

/* =======================================
   HEADER STYLES (Fixed at Top)
   ======================================= */
#header {
    height: 65px; /* Fixed height for the header */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    background: #205072;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex-shrink: 0; /* Ensures header never shrinks */
    z-index: 100;
}

#header h1 {
    margin: 0;
    font-size: 24px;
}

#message-counts {
    font-size: 14px;
}

.top-link {
    color: #a0c4ff;
    font-weight: 500;
    text-decoration: none;
    margin-left: 15px;
}

.top-link:hover {
    color: #ffffff;
    text-decoration: underline;
}

/* =======================================
   MAIN CONTAINER (Layout Wrapper)
   ======================================= */
#container {
    display: flex;
    flex: 1; /* Takes up all remaining vertical space */
    width: 100%;
    overflow: hidden; /* Keeps the children contained */
}

/* =======================================
   INBOX STYLES - LEFT PANEL (Topics)
   ======================================= */
#topics-panel {
    width: 380px;
    background: #ffffff;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column; /* Stack search and list */
    flex-shrink: 0;
}

#search-container {
    padding: 15px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0; /* Search bar stays at the top */
}

#search-bar {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #cce0eb;
    border-radius: 20px;
    font-size: 14px;
    background-color: #f0f2f5;
}

/* Topic List Area (SCROLLABLE) */
#topics-list-container, #topic-suggestions-box {
    flex: 1;           /* Fills remaining sidebar height */
    overflow-y: auto;  /* CRITICAL: Only the list scrolls */
    background-color: #fff;
}

.topic-item, .topic-suggestion {
    padding: 15px 20px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topic-item:hover, .topic-suggestion:hover {
    background-color: #f5f6f7;
}

.topic-item.active {
    background-color: #e7f3ff;
    border-left: 4px solid #4285f4;
    font-weight: bold;
}

/* =======================================
   MESSAGE BOX - RIGHT PANEL (Chat)
   ======================================= */
#message-box {
    flex: 1;            /* Fills remaining horizontal space */
    background: #e5ddd5; /* Classic WhatsApp Background */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#topic-title-display {
    padding: 15px 25px;
    background: #f0f2f5;
    margin: 0;
    border-bottom: 1px solid #ddd;
    font-size: 18px;
    color: #205072;
    flex-shrink: 0; /* Chat header stays at the top */
}

/* Message Content Area (SCROLLABLE) */
#message-box .message-list {
    flex: 1;
    overflow-y: auto; /* CRITICAL: Messages scroll independently */
    padding: 20px 40px;
}

.message {
    margin-bottom: 20px;
    max-width: 80%;
}

.message h3 {
    font-size: 16px;
    margin-bottom: 5px;
    color: #205072;
}

.message small {
    color: #888;
    display: block;
    margin-bottom: 8px;
}

.message pre {
    background: #ffffff;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    font-size: 15px;
    white-space: pre-wrap;
    font-family: inherit;
    line-height: 1.5;
}

hr {
    border: 0;
    border-top: 1px solid rgba(0,0,0,0.05);
    margin: 10px 0;
}

/* =======================================
   SCROLLBAR STYLING (Optional, for modern look)
   ======================================= */
#topics-list-container::-webkit-scrollbar,
.message-list::-webkit-scrollbar {
    width: 6px;
}

#topics-list-container::-webkit-scrollbar-thumb,
.message-list::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
}

/* =======================================
   SHARED COMPONENTS (Forms, Admin, etc.)
   ======================================= */
.login-container, .create-user-container, .admin-container {
    max-width: 95%;
    margin: 30px auto;
    background-color: #fff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

label { display: block; margin: 15px 0 5px; font-weight: 600; }

input[type="text"], input[type="password"], select, textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #cce0eb;
    border-radius: 6px;
    background-color: #fcfdff;
}

button {
    width: 100%;
    padding: 12px 20px;
    background-color: #4285f4;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

button:hover { background-color: #357ae8; 
}

/* =======================================
   CUSTOM MESSAGE GRID STYLES (send_custom_message.php)
   ======================================= */

.message-grid {
    display: flex;
    gap: 30px;
    margin-top: 20px;
}

.message-form-container {
    flex: 1;
    padding: 25px;
    border: 1px solid #e1e9ed;
    border-radius: 10px;
    background-color: #fcfdff;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.3s;
}

.message-form-container:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.message-form-container h3 {
    margin-top: 0;
    font-size: 20px;
    color: #205072;
    border-bottom: 3px solid #b3d7ff;
    padding-bottom: 10px;
    margin-bottom: 20px;
    font-weight: 700;
}

/* Specific button colors for clarity */
#bulkSubmitBtn {
    background-color: #00897b;
}
#bulkSubmitBtn:hover:not(:disabled) {
    background-color: #00796b;
}

#individualSubmitBtn {
    background-color: #ff6f00;
}
#individualSubmitBtn:hover:not(:disabled) {
    background-color: #e65100;
}

/* Status Message Area */
#message-status-area {
    margin-top: 25px;
    padding: 15px 25px;
    border-radius: 8px;
    font-weight: 600;
    display: none;
    text-align: center;
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .message-grid {
        flex-direction: column;
    }
}

/* =======================================
   ADMIN STYLES (admin.php)
   ======================================= */

/* Admin Table Styles */
#statsTable {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 20px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

#statsTable thead {
    background-color: #205072;
    color: #fff;
}

#statsTable th, #statsTable td {
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
}

#statsTable th:first-child { border-top-left-radius: 8px; }
#statsTable th:last-child { border-top-right-radius: 8px; }

#statsTable tbody tr:nth-child(even) {
    background-color: #f7f9fa;
}

#statsTable tbody tr:hover {
    background-color: #e9f2ff;
}

.filter-bar input[type="text"] {
    width: 300px;
    display: inline-block;
    margin-right: 10px;
}

.filter-bar button {
    width: auto;
    padding: 8px 15px;
    margin-top: 0;
}
