:root {
    --primary: #00a884;
    --primary-light: #ecfdf5;
    --primary-hover: #008f70;
    --bg-main: #f0f2f5;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-main: #1c1e21;
    --text-muted: #65676b;
    --border: #e4e6eb;
    --valid: #22c55e;
    --invalid: #ef4444;
    --warning: #f59e0b;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-hover: 0 4px 20px rgba(0,0,0,0.12);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
    font-family: 'Tajawal', sans-serif;
    font-weight: 500;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0;
    z-index: 100;
}

.logo-section {
    padding: 0 1.5rem 2.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.4rem;
    font-weight: 800;
}

.nav-group-label {
    padding: 1.5rem 1.5rem 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 700;
}

.nav-links {
    list-style: none;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    margin: 0.2rem 1rem;
    padding: 0.8rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    border-radius: 12px;
}

.nav-item span {
    font-size: 1.2rem;
}

.nav-item:hover {
    background: var(--bg-main);
    color: var(--primary);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

/* Main Content */
.main-layout {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    height: 70px;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
    flex-shrink: 0;
}

.content-area {
    flex: 1;
    padding: 2.5rem;
    overflow-y: auto;
}

/* Dashboard Specifics */
.welcome-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 2rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.welcome-text h1 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.welcome-text p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.refresh-dashboard-btn {
    background: var(--bg-main);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: 0.3s;
}

/* Warmer Feature Styles */
.warmer-dashboard {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.warmer-msg-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.warmer-msg-item {
    background: #f8fafc;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: 0.2s;
}

.warmer-msg-item:hover {
    background: #f1f5f9;
}

.remove-msg-btn {
    color: var(--invalid);
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.6;
    transition: 0.2s;
}

.remove-msg-btn:hover {
    opacity: 1;
}

.warmer-devices-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.warmer-device-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.warmer-device-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.warmer-device-info {
    flex: 1;
}

.warmer-device-name {
    font-weight: 700;
    font-size: 0.9rem;
    display: block;
}

.warmer-device-status {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    margin-top: 0.3rem;
}

.stat-icon-box {
    width: 45px;
    height: 45px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.stat-icon-box.teal { background: #e6fffa; color: #319795; }
.stat-icon-box.green { background: #f0fff4; color: #38a169; }
.stat-icon-box.orange { background: #fffaf0; color: #dd6b20; }
.stat-icon-box.blue { background: #ebf8ff; color: #3182ce; }

.mini-chart-container {
    height: 50px;
    width: 100%;
    margin-top: 1rem;
}

/* Main Row */
.dashboard-main-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.activity-section {
    background: white;
    padding: 2rem;
    border-radius: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.section-header h3 { font-size: 1.3rem; font-weight: 800; }
.section-header p { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.3rem; }

.main-chart-container {
    margin-top: 2rem;
    height: 350px;
}

.widgets-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.widget-card {
    background: white;
    padding: 1.5rem;
    border-radius: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.widget-header h3 { font-size: 1.1rem; font-weight: 800; }
.widget-icon { font-size: 1.2rem; opacity: 0.5; }

.unread-messages-status {
    text-align: center;
    padding: 1rem 0;
}

.status-icon.success-bg {
    width: 40px;
    height: 40px;
    background: var(--valid);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.2rem;
}

.integration-card {
    background: white;
    padding: 2rem;
    border-radius: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-top: 1rem;
}

.status-online {
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.2rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

/* API Documentation Styles */
.api-doc-card {
    background: white;
    border-radius: 1.5rem;
    padding: 2.5rem;
    box-shadow: var(--shadow-sm);
    max-width: 900px;
    margin: 0 auto;
    direction: ltr; /* Force English direction for API docs */
    text-align: left;
}

.api-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.api-icon {
    width: 4rem;
    height: 4rem;
    background: #f0fdf4;
    color: #16a34a;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.token-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    padding: 2rem;
    margin-bottom: 2.5rem;
}

.token-box label {
    display: block;
    font-weight: 700;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.token-box p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.token-input-group {
    display: flex;
    gap: 1rem;
}

.token-input-group input {
    flex: 1;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    font-family: monospace;
    font-size: 0.9rem;
}

.api-endpoint-box {
    margin-bottom: 2.5rem;
}

.endpoint-url {
    background: #0f172a;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-family: monospace;
}

.endpoint-url .method {
    background: #16a34a;
    padding: 0.25rem 0.75rem;
    border-radius: 0.4rem;
    font-size: 0.8rem;
    font-weight: 700;
}

.api-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0 2.5rem;
}

.api-table th, .api-table td {
    text-align: right;
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.api-table th {
    background: #f8fafc;
    color: #64748b;
    font-weight: 600;
    font-size: 0.85rem;
}

.api-example-box pre {
    background: #1e293b;
    color: #f8fafc;
    padding: 1.5rem;
    border-radius: 1rem;
    overflow-x: auto;
    direction: ltr;
}

.api-example-box code {
    font-family: 'Consolas', monospace;
    font-size: 0.9rem;
}

/* Chatbot Screen Styles */
.chatbot-container {
    padding: 1rem;
}

.chatbot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    background: white;
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-sm);
}

.rules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.rule-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid #e2e8f0;
    transition: transform 0.2s;
}

.rule-card:hover {
    transform: translateY(-5px);
}

.rule-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.rule-keyword {
    background: #f0fdf4;
    color: #16a34a;
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    font-weight: 700;
    font-size: 0.9rem;
}

.rule-match-badge {
    font-size: 0.75rem;
    color: #64748b;
    background: #f1f5f9;
    padding: 0.2rem 0.5rem;
    border-radius: 0.3rem;
}

.rule-response {
    color: #334155;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 0.5rem;
}

.rule-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-delete {
    background: #fef2f2;
    color: #dc2626;
    border: none;
    padding: 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
}

.modal-content {
    background-color: white;
    margin: 8% auto;
    padding: 2.5rem;
    border-radius: 2rem;
    width: 90%;
    max-width: 550px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
    animation: modalSlideUp 0.3s ease-out;
}

@keyframes modalSlideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 1rem;
}

.modal-header h3 {
    font-size: 1.5rem;
    color: var(--secondary);
    font-weight: 800;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.modal-body .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.modal-body label {
    font-weight: 600;
    color: #475569;
    font-size: 0.95rem;
}

.modal-body input, .modal-body select, .modal-body textarea {
    padding: 0.8rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 1rem;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s;
}

.modal-body input:focus, .modal-body select:focus, .modal-body textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.1);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2.5rem;
}

.close {
    font-size: 2rem;
    cursor: pointer;
    color: #94a3b8;
    line-height: 1;
    transition: color 0.2s;
}

.btn-copy {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    padding: 0.5rem 1rem;
    border-radius: 0.75rem;
    cursor: pointer;
    font-weight: 600;
}

.endpoint-url-container {
    background: #0f172a;
    padding: 1rem;
    border-radius: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
}

.endpoint-url-container code {
    color: #10b981;
    font-family: monospace;
    font-size: 0.95rem;
}

.btn-copy-lite {
    background: rgba(255,255,255,0.1);
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
}

.btn-copy-lite:hover {
    background: rgba(255,255,255,0.2);
}

/* Tabs */
.tabs-header {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid #f1f5f9;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 600;
    color: #64748b;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.btn-setup-guide {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
    padding: 0.6rem 1.2rem;
    border-radius: 0.75rem;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.9rem;
    margin-left: auto;
    transition: all 0.2s;
}

.btn-setup-guide:hover {
    background: #dbeafe;
}

.setup-step {
    margin-bottom: 2rem;
}

.setup-step h4 {
    color: var(--secondary);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.env-sample-box {
    background: #0f172a;
    border-radius: 1rem;
    padding: 1.5rem;
    position: relative;
    margin-top: 1rem;
}

.env-sample-box pre {
    color: #e2e8f0;
    margin: 0;
    font-family: 'Consolas', monospace;
}

.btn-copy-env {
    position: absolute;
    right: 1rem;
    top: 1rem;
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    padding: 0.3rem 0.7rem;
    border-radius: 0.4rem;
    font-size: 0.75rem;
    cursor: pointer;
}
.add-btn {
    background: var(--primary);
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
}

.add-btn:hover { background: var(--primary-hover); }

.session-grid { display: grid; gap: 1rem; margin-top: 1.5rem; }
.session-card {
    background: #f8fafc;
    border-radius: 16px;
    padding: 1.2rem 1.5rem;
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.inbox-container { 
    height: calc(100vh - 120px); 
    display: flex; 
    background: white; 
    border-radius: 24px; 
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.chat-list {
    width: 350px;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: #f8fafc;
}

.chat-list-header {
    padding: 1.5rem;
    background: white;
    border-bottom: 1px solid var(--border);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: var(--bg-main);
    padding: 0.7rem 1.2rem;
    border-radius: 12px;
}

.search-box input {
    border: none;
    background: transparent;
    width: 100%;
    outline: none;
    font-size: 0.9rem;
}

.chat-items {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    padding: 1.2rem 1.5rem;
    display: flex;
    gap: 1rem;
    cursor: pointer;
    transition: 0.2s;
    border-bottom: 1px solid rgba(0,0,0,0.03);
}

.chat-item:hover { background: #f1f5f9; }
.chat-item.active { background: var(--primary-light); }

.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: var(--primary-light);
    flex-shrink: 0;
}

.chat-info { flex: 1; min-width: 0; }
.chat-name-row { display: flex; justify-content: space-between; margin-bottom: 0.3rem; }
.chat-name { font-weight: 700; color: var(--text-main); font-size: 0.95rem; }
.chat-time { font-size: 0.75rem; color: var(--text-muted); }
.chat-preview { 
    font-size: 0.85rem; 
    color: var(--text-muted); 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

/* Chat Window */
.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    position: relative;
}

.chat-header {
    padding: 1rem 2rem;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    height: 70px;
}

.chat-messages {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    background: #fdfdfd;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.chat-input-area {
    padding: 1.5rem 2rem;
    background: white;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 1rem;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 0.9rem 1.5rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--bg-main);
    outline: none;
    transition: 0.2s;
}

.chat-input:focus { border-color: var(--primary); background: white; }

/* Empty State */
.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    opacity: 0.2;
}

.chat-empty-state h2 { color: var(--text-main); margin-bottom: 0.5rem; }

/* Message Bubbles */
.msg-bubble { 
    max-width: 70%; 
    padding: 0.9rem 1.3rem; 
    border-radius: 18px; 
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    position: relative;
    font-size: 0.95rem;
    line-height: 1.5;
}

.msg-me { 
    align-self: flex-end;
    background: var(--primary); 
    color: white; 
    border-bottom-left-radius: 4px; 
}

.msg-other { 
    align-self: flex-start; 
    background: white; 
    border: 1px solid var(--border);
    border-bottom-right-radius: 4px; 
}

.msg-time {
    font-size: 0.65rem;
    opacity: 0.7;
    margin-top: 0.4rem;
    display: block;
}

/* Connection Status Dots */
.status-row { display: flex; align-items: center; gap: 0.5rem; }
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.status-connected { background: var(--valid); }
.status-inactive { background: #94a3b8; }
.status-connecting { 
    background: #f59e0b; 
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
    100% { opacity: 1; transform: scale(1); }
}

/* QR Code Styling */
#qr-section {
    text-align: center;
    padding: 2rem;
}

#qr-container {
    display: flex;
    justify-content: center;
    margin: 1.5rem 0;
}

.qr-code-img {
    max-width: 320px;
    width: 100%;
    border-radius: 16px;
    border: 8px solid white;
    box-shadow: var(--shadow-hover);
    transition: transform 0.3s ease;
}

.qr-code-img:hover {
    transform: scale(1.02);
}
