/* admin.css */

:root {
    --bg-dark-main: #1e222d;
    --bg-dark-sidebar: #242936;
    --bg-dark-widget: #2a3040;
    --border-color: #363a45;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a4b1;
    --primary-accent: #007bff;
    --primary-accent-hover: #0056b3;
    --positive: #27ae60;
    --negative: #e74c3c;
    --warning: #f39c12;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    --border-radius: 8px;
    --font-family-persian: 'Vazirmatn', sans-serif;
}

body {
    margin: 0;
    font-family: var(--font-family-persian);
    background-color: var(--bg-dark-main);
    color: var(--text-primary);
    direction: rtl;
    overflow-x: hidden;
}

#app-container {
    display: flex;
    height: 100vh;
}

/* --- Login Screen --- */
#login-screen { width: 100%; display: flex; align-items: center; justify-content: center; }
.login-card { background-color: var(--bg-dark-widget); padding: 2.5rem; border-radius: var(--border-radius); box-shadow: var(--shadow); width: 90%; max-width: 400px; text-align: center; }
.login-card h2 { margin-top: 0; }
.login-card p { color: var(--text-secondary); }
#admin-secret-input { width: 100%; padding: 0.75rem; margin: 1rem 0; border: 1px solid var(--border-color); border-radius: 4px; background-color: var(--bg-dark-main); color: var(--text-primary); font-size: 1rem; }
#login-btn { width: 100%; padding: 0.75rem; border: none; border-radius: 4px; background-color: var(--primary-accent); color: white; font-weight: 600; cursor: pointer; font-size: 1rem; }
.error-message { color: var(--negative); margin-top: 1rem; min-height: 1.2em; }

/* --- Main Panel Layout --- */
#admin-panel { display: flex; width: 100%; height: 100vh; }
.sidebar { width: 250px; background-color: var(--bg-dark-sidebar); padding: 1.5rem; display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar h1 { font-size: 1.8rem; text-align: center; margin: 0 0 2rem 0; }
.sidebar nav { display: flex; flex-direction: column; gap: 0.5rem; }
.sidebar .nav-link { color: var(--text-secondary); text-decoration: none; padding: 0.75rem 1rem; border-radius: 6px; transition: all 0.2s ease; }
.sidebar .nav-link:hover { background-color: var(--bg-dark-widget); color: var(--text-primary); }
.sidebar .nav-link.active { background-color: var(--primary-accent); color: white; font-weight: 600; }
.sidebar-footer { margin-top: auto; }
#logout-btn { width: 100%; background-color: var(--negative); padding: 0.6rem; border: none; color: white; border-radius: 4px; cursor: pointer; }
.main-content { flex-grow: 1; overflow-y: auto; padding: 2rem; }

/* --- Dashboard & Users View --- */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; }
.stat-card { background-color: var(--bg-dark-widget); padding: 1.5rem; border-radius: var(--border-radius); }
.stat-card h4 { margin: 0 0 0.5rem 0; color: var(--text-secondary); font-size: 1rem; }
.stat-card .value { font-size: 2.5rem; font-weight: 700; }
.users-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
#user-search-input { padding: 0.6rem 1rem; background-color: var(--bg-dark-widget); border: 1px solid var(--border-color); color: var(--text-primary); border-radius: 4px; width: 300px; }
.user-table-wrapper { overflow-x: auto; }
.user-table { width: 100%; border-collapse: collapse; background-color: var(--bg-dark-widget); border-radius: var(--border-radius); overflow: hidden; }
.user-table th, .user-table td { padding: 1rem; text-align: right; border-bottom: 1px solid var(--border-color); }
.user-table th { cursor: pointer; user-select: none; }
.user-table tbody tr { cursor: pointer; transition: background-color 0.2s; }
.user-table tbody tr:hover { background-color: var(--bg-dark-sidebar); }

/* --- Modal --- */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.7); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background-color: var(--bg-dark-widget); width: 90%; max-width: 1000px; max-height: 90vh; display: flex; flex-direction: column; border-radius: var(--border-radius); box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.modal-header { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.close-modal-btn { background: none; border: none; font-size: 2rem; color: var(--text-secondary); cursor: pointer; }
.modal-body { padding: 1.5rem; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.modal-section { display: flex; flex-direction: column; gap: 1rem; }
.modal-section h4 { margin: 0 0 0.5rem 0; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border-color); }
.info-grid { display: grid; grid-template-columns: auto 1fr; gap: 0.5rem 1rem; align-items: center; }
.info-grid dt { font-weight: 600; color: var(--text-secondary); }
.info-grid dd { margin: 0; }
.modal-section button { padding: 0.6rem; border-radius: 4px; border: none; font-weight: 600; cursor: pointer; }
.modal-input, .modal-textarea, .modal-section select { width: 100%; padding: 0.6rem; border: 1px solid var(--border-color); background-color: var(--bg-dark-main); color: var(--text-primary); border-radius: 4px; font-family: inherit; }
pre { background-color: var(--bg-dark-main); padding: 1rem; border-radius: 4px; white-space: pre-wrap; word-break: break-all; max-height: 250px; overflow-y: auto; direction: ltr; }
.modal-note { font-size: 0.85rem; padding: 0.75rem; background-color: var(--bg-dark-main); border-right: 3px solid var(--warning); color: var(--text-secondary); border-radius: 4px; }


.form-group { display: flex; flex-direction: column; gap: 0.5rem; }
.form-group label { font-weight: 500; }
.form-group select { width: 100%; padding: 0.6rem; border: 1px solid var(--border-color); background-color: var(--bg-dark-main); color: var(--text-primary); border-radius: 4px; font-family: inherit; }
.checkbox-group { display: flex; gap: 1rem; flex-wrap: wrap; }
.checkbox-group label { display: flex; align-items: center; gap: 0.5rem; }

/* Security Section Styles */
#account-status-select { font-size: 1rem; }
.terminated-option { background-color: var(--negative) !important; color: white !important; font-weight: bold !important; }

/* --- Config Editor (Global and User) --- */
.config-editor { background-color: var(--bg-dark-main); border: 1px solid var(--border-color); border-radius: 4px; padding: 1rem; }
.config-editor-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.config-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 0.75rem; align-items: center; margin-bottom: 0.75rem; }
.config-row input { padding: 0.5rem; background-color: var(--bg-dark-widget); border: 1px solid var(--border-color); color: var(--text-primary); border-radius: 4px; }
.btn-delete-row { background-color: var(--negative); color: white; border: none; border-radius: 4px; width: 32px; height: 32px; cursor: pointer; }
.btn-add-row { background-color: var(--positive); color: white; padding: 0.5rem 1rem; }
.config-editor p { color: var(--text-secondary); font-size: 0.9em; margin-top: 1.5rem; }

/* New styles for batch save and module selector */
.btn-save-all { background-color: var(--positive); color: white; padding: 0.8rem; font-size: 1.1rem; width: 100%; }
.config-module-selector { margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.config-module-selector label { font-weight: 600; }
#user-config-module-select { width: 100%; padding: 0.6rem; background-color: var(--bg-dark-sidebar); border: 1px solid var(--border-color); color: var(--text-primary); border-radius: 4px; }

/* --- Chat Status Indicators --- */
.chat-status-indicator { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-left: 8px; vertical-align: middle; }
.status-open { background-color: var(--positive); }
.status-closed { background-color: var(--text-secondary); }
.urgent-indicator { font-weight: bold; color: var(--warning); margin-bottom: 0.5rem; font-size: 0.8rem; }

/* --- Responsive Additions --- */
.main-header { display: none; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.main-header h2 { margin: 0; font-size: 1.4rem; }
.hamburger-btn { background: none; border: 1px solid var(--border-color); color: var(--text-primary); font-size: 1.5rem; cursor: pointer; border-radius: 4px; width: 40px; height: 40px; }
.overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); z-index: 999; display: none; }
.overlay.active { display: block; }

@media (max-width: 768px) {
    .sidebar { position: fixed; top: 0; right: -260px; height: 100%; z-index: 1000; transition: transform 0.3s ease-in-out; box-shadow: -5px 0 15px rgba(0,0,0,0.3); }
    .sidebar.open { transform: translateX(-260px); }
    .main-content { padding: 1rem; }
    .main-header { display: flex; }
    .modal-body { grid-template-columns: 1fr; gap: 1.5rem; }
    #user-search-input { width: auto; flex-grow: 1; }
    .users-header { flex-wrap: wrap; gap: 1rem; }
}