/* Custom Styles for Management Pages (settings, bot_replies, faqs, users) */

:root {
    /* Define color variables (consistent across the application) */
    --primary-blue: #0A66C2;
    --secondary-blue: #0077B5;
    --accent-green: #28a745;
    --accent-red: #dc3545;
    --accent-gray: #6c757d;
    --light-bg: #f5f8fa; /* Very light subtle background */
    --card-bg: #ffffff;
    --text-dark: #333d47; /* Darker, softer text */
    --text-medium: #5a6b7d; /* Medium gray for details */
    --border-light: #e0e6ec; /* Light border color */
    --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.05);
    --shadow-medium: 0 8px 25px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--light-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: var(--text-dark);
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

/* App Header Styles (Consistent across all admin/management pages) */
.app-header {
    background: linear-gradient(to right, var(--primary-blue), var(--secondary-blue));
    color: #fff;
    padding: 1rem 2rem; /* Increased padding for consistency */
    box-shadow: var(--shadow-medium);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.app-header .header-title {
    font-size: 1.85rem; /* Consistent with index.css logo */
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Back Link (used in settings, users, bot_replies, faqs) */
.app-header .back-link {
    color: rgba(255, 255, 255, 0.95);
    text-decoration: none;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.6rem; /* Consistent gap */
    transition: all 0.3s ease;
    padding: 0.6rem 1.2rem; /* Consistent button-like padding */
    border-radius: 25px; /* Pill shape */
    border: 1px solid rgba(255, 255, 255, 0.3);
    background-color: rgba(255, 255, 255, 0.15);
}
.app-header .back-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.3);
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}
.app-header .back-link:active {
    transform: translateY(0);
    box-shadow: none;
}


/* Main Content Area (Common across admin/management pages) */
.main-content {
    flex-grow: 1;
    padding: 2.5rem; /* Increased padding */
    max-width: 1000px; /* Wider for settings/management */
    margin: 2.5rem auto; /* Center with more margin */
    background-color: var(--card-bg);
    border-radius: 15px;
    box-shadow: var(--shadow-medium);
}

/* Section Heading (for page titles like "Users List", "Bot Replies List") */
.section-heading {
    font-size: 1.6rem; /* Consistent heading size */
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-light);
}

/* Add Button (e.g., "Add New User", "Add New Reply", "Add New FAQ") */
.add-btn {
    background-color: var(--accent-green);
    color: #fff;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: none;
}
.add-btn:hover {
    background-color: #218838; /* Darker green */
    transform: translateY(-1px);
}
.add-btn:active {
    transform: translateY(0);
}


/* Data Table Specific Styles (for users, bot_replies, faqs lists) */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5rem;
    background-color: #fff;
    border-radius: 10px;
    overflow: hidden; /* Ensures rounded corners on inner elements */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.data-table th, .data-table td {
    padding: 1rem;
    border: 1px solid var(--border-light);
    text-align: right; /* Default for RTL */
}

.data-table th {
    background-color: #f8f8f8;
    font-weight: 600;
    color: var(--text-dark);
}

.data-table td {
    color: var(--text-medium);
    vertical-align: top; /* Align content to the top */
}

.data-table tr:hover td {
    background-color: #f5f5f5;
}

/* Action Buttons within table rows (Edit, Delete) */
.action-btns {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end; /* Align to right in RTL */
    flex-wrap: wrap; /* Allow buttons to wrap */
}
.action-btns button {
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    border: none;
    white-space: nowrap;
}
.action-btns .edit-btn {
    background-color: var(--primary-blue);
    color: #fff;
}
.action-btns .edit-btn:hover {
    background-color: var(--secondary-blue);
    transform: translateY(-1px);
}
.action-btns .delete-btn {
    background-color: var(--accent-red);
    color: #fff;
}
.action-btns .delete-btn:hover {
    background-color: #c82333; /* Darker red */
    transform: translateY(-1px);
}
.action-btns button:active {
    transform: translateY(0);
}


/* Status Indicators (Active/Inactive for users, replies, faqs) */
.status-active, .status-inactive {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px; /* Pill shape */
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap; /* Prevent text wrapping */
}
.status-active {
    background-color: #d1e7dd; /* Light green */
    color: #0f5132; /* Dark green */
}
.status-inactive {
    background-color: #f8d7da; /* Light red */
    color: #842029; /* Dark red */
}


/* Loading and No Data Messages (Common across admin/management pages) */
#loadingMessage, #noRepliesMessage, #noUsersMessage, #noFaqsMessage {
    text-align: center;
    padding: 2rem;
    font-size: 1.1rem;
    border-radius: 12px;
    margin-top: 1.5rem;
    box-shadow: var(--shadow-light);
}
#loadingMessage {
    color: var(--primary-blue);
    background-color: #e6f3ff;
    border: 1px solid #b3d9ff;
}
#noRepliesMessage, #noUsersMessage, #noFaqsMessage {
    color: var(--text-medium);
    background-color: #fcfcfc;
    border: 1px dashed var(--border-light);
}

.hidden { display: none !important; }


/* --- Modal Styles (Common for Add/Edit Forms) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}
.modal-content {
    background-color: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 500px; /* Standard modal width */
    transform: translateY(-20px);
    transition: transform 0.3s ease;
    position: relative;
    max-height: 90vh; /* Limit modal height */
    overflow-y: auto; /* Allow scrolling within modal */
}
.modal-overlay.show .modal-content {
    transform: translateY(0);
}
.modal-content h3 {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--primary-blue);
    margin-bottom: 25px;
    text-align: center;
}
.modal-close-btn {
    position: absolute;
    top: 15px;
    left: 15px; /* Adjust for RTL if icon should be on the other side, or use flexbox for header */
    background: none;
    border: none;
    font-size: 1.8rem;
    color: #777;
    cursor: pointer;
    transition: color 0.2s ease;
}
.modal-close-btn:hover {
    color: #333;
}
.form-group {
    margin-bottom: 18px;
}
.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #444;
    margin-bottom: 6px;
}
.form-text-hint { /* New style for hint text under form fields */
    font-size: 0.8rem;
    color: var(--text-medium);
    margin-top: 4px;
    display: block; /* Ensure it takes its own line */
}

.input-field {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-color: #fcfcfc;
    color: var(--text-dark);
}
.input-field:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(10, 102, 194, 0.15);
}
.input-field[type="color"] { /* For color input fields */
    padding: 0.3rem;
    height: 40px;
}
.input-field[type="number"] { /* For number inputs like order_index */
    max-width: 150px; /* Limit width */
}
textarea.input-field {
    min-height: 80px; /* Standard height for textareas */
    resize: vertical; /* Allow vertical resizing */
}

.modal-submit-btn {
    background-color: var(--accent-green); /* Green submit button */
    color: #fff;
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 25px;
}
.modal-submit-btn:hover {
    background-color: #218838;
    transform: translateY(-2px);
}
.modal-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.modal-submit-btn:active {
    transform: translateY(0);
}

.modal-message {
    text-align: center;
    margin-top: 15px;
    font-size: 0.9rem;
    padding: 10px;
    border-radius: 8px;
    display: none;
}
.modal-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.modal-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
.modal-message.show {
    display: block;
}

/* Toggle Switch (Consistent with settings.html) */
.toggle-switch-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0;
}
.toggle-switch-container label:first-child {
    flex-grow: 1;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0;
}
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: var(--accent-green);
}
input:focus + .slider {
    box-shadow: 0 0 1px var(--accent-green);
}
input:checked + .slider:before {
    transform: translateX(24px);
}

/* WhatsApp Status Section specific styles (from settings.html) */
.whatsapp-status-section {
    text-align: center;
    /* Added common section styles as well */
    background-color: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow-light);
    margin-bottom: 2.5rem; /* Space between sections if used outside form */
}
/* Section title style specific to settings */
.whatsapp-status-section h3, .form-section .section-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary-blue);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-light);
}
.whatsapp-status-section h3 i, .form-section .section-title i {
    font-size: 1.8rem;
    color: var(--secondary-blue);
}
#whatsappQrContainer {
    margin-bottom: 1.5rem;
    border: 1px dashed var(--border-light);
    border-radius: 10px;
    padding: 1rem;
    background-color: #fcfcfc;
}
#whatsappQrCode {
    max-width: 200px;
    height: auto;
    margin: 0 auto 1rem;
    display: block;
    border: 1px solid #ddd;
    border-radius: 8px;
}
#whatsappStatusMessage {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
}
.status-connecting {
    background-color: #fff3cd; /* Light yellow */
    color: #664d03; /* Dark yellow text */
    border-color: #ffe0b3;
}
.status-connected {
    background-color: #d1e7dd; /* Light green */
    color: #0f5132; /* Dark green text */
    border-color: #b7e3c5;
}
.status-disconnected {
    background-color: #f8d7da; /* Light red */
    color: #842029; /* Dark red text */
    border-color: #ffb3b3;
}
.status-loading {
    background-color: #e6f3ff;
    color: #007bff;
    border-color: #cce0f5;
}
.status-default {
    background-color: #e2e3e5;
    color: #495057;
    border-color: #cdd8e4;
}

/* Form sections for settings page */
.settings-form-container { /* This is the main form wrapper in settings.html */
    display: flex;
    flex-direction: column;
    gap: 2.5rem; /* Space between form sections */
}
.form-section { /* Individual sections within the settings form */
    background-color: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow-light);
}
.form-section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Save Button (common in settings.html) */
.save-btn {
    background-color: var(--primary-blue);
    color: #fff;
    padding: 0.8rem 2rem;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    border: none;
    margin-top: 2rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}
.save-btn:hover {
    background-color: var(--secondary-blue);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}
.save-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: translateY(0);
    box-shadow: none;
}


/* Responsive Adjustments (Common across admin/management pages) */
@media (max-width: 1024px) {
    .main-content {
        padding: 1.5rem;
        margin: 1.5rem auto;
    }
    .app-header {
        padding: 1rem;
    }
    .modal-content {
        max-width: 450px; /* Slightly smaller modals */
        padding: 25px;
    }
    .form-section {
        padding: 1.5rem;
    }
    .form-section-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* Adjust grid for smaller screens */
        gap: 1rem;
    }
    .add-btn, .modal-submit-btn, .save-btn { /* Apply to all common buttons */
        padding: 0.7rem 1.5rem;
        font-size: 1rem;
    }
}

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.8rem;
    }
    .app-header .back-link {
        width: 100%;
        justify-content: center;
    }
    .main-content {
        padding: 1rem;
        margin: 1rem auto;
    }
    .section-heading {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.8rem;
    }
    .add-btn {
        width: 100%;
        justify-content: center;
    }
    /* Table Responsive for small screens */
    .data-table th, .data-table td {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    .data-table thead {
        display: none; /* Hide table headers on small screens */
    }
    .data-table, .data-table tbody, .data-table tr, .data-table td {
        display: block;
        width: 100%;
    }
    .data-table tr {
        margin-bottom: 1rem;
        border: 1px solid var(--border-light);
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.05);
        display: flex;
        flex-direction: column;
        padding: 0.75rem;
    }
    .data-table td {
        text-align: right; /* Default for RTL */
        padding-left: 50%; /* Make space for pseudo-element label */
        position: relative;
        border: none; /* Remove individual cell borders */
        padding-bottom: 0.5rem;
        padding-top: 0.5rem;
    }
    .data-table td:last-child {
        padding-bottom: 0.75rem; /* More padding for the last cell */
    }
    .data-table td::before {
        content: attr(data-label); /* Use data-label for content */
        position: absolute;
        right: 1rem; /* Position label for RTL */
        width: 45%;
        text-align: right; /* Align label text for RTL */
        font-weight: 600;
        color: var(--text-dark);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        top: 0.5rem; /* Adjust vertical position */
    }
    .data-table .action-btns {
        justify-content: flex-start; /* Align action buttons to start (left in RTL) */
        padding-top: 0.75rem;
        border-top: 1px solid var(--border-light);
        margin-top: 0.5rem;
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    .action-btns button {
        width: auto; /* Allow buttons to size content */
        flex-grow: 1; /* Allow buttons to grow */
    }

    .modal-content {
        padding: 20px;
        max-width: 95%; /* Make modal wider on very small screens */
    }
    .form-group .input-field, .form-group .input-field[type="number"] {
        max-width: 100%; /* Ensure inputs take full width in modal on very small screens */
    }
    .form-section-grid { /* For settings page specific grid */
        grid-template-columns: 1fr; /* Single column for all fields */
    }
}