/* ===== Bot TT - Modern Dashboard Stylesheet ===== */

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6C5CE7;
    --primary-light: #7C6CF7;
    --primary-dark: #5A4BD1;
    --accent: #00B4D8;
    --accent-light: #48CAE4;
    --success: #00B894;
    --warning: #F9A825;
    --danger: #E17055;
    --info: #4EA8DE;
    
    --bg-dark: #F5F7FA;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F0F2F5;
    --bg-input: #F0F2F5;
    --bg-sidebar: #FFFFFF;
    
    --text-primary: #1A1A2E;
    --text-secondary: #5A5A7A;
    --text-muted: #8B8BA7;
    
    --border: #E2E4EA;
    --border-light: #D0D3DA;
    
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    
    --sidebar-width: 260px;
    --topbar-height: 64px;
    
    --transition: all 0.3s ease;
}

html {
    font-size: 15px;
}

body {
    font-family: 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: var(--primary-light); text-decoration: none; }
a:hover { color: var(--primary); }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: #C8CBD0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #A0A4AB; }

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: var(--transition);
    box-shadow: 2px 0 8px rgba(0,0,0,0.04);
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-light);
}

.logo i {
    font-size: 1.6rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 5px;
    display: none;
}

.bot-status {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.status-indicator.active { color: var(--success); }
.status-indicator.active i { animation: pulse 2s infinite; }
.status-indicator.inactive { color: var(--danger); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.ai-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 4px 10px;
    border-radius: 20px;
    width: fit-content;
}

.sidebar-nav {
    flex: 1;
    padding: 15px 10px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: var(--transition);
    margin-bottom: 4px;
    position: relative;
    font-weight: 400;
}

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

.nav-item.active {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.2), rgba(0, 206, 201, 0.1));
    color: var(--primary-light);
    font-weight: 500;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.nav-item .badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border);
}

.version {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-align: center;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.main-content.expanded {
    margin-left: 0;
}

/* ===== Topbar ===== */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 16px;
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.topbar-title i {
    color: var(--primary-light);
    font-size: 1.1rem;
}

.topbar-title h1 {
    font-size: 1.15rem;
    font-weight: 600;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.topbar-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.notification-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border);
    transition: var(--transition);
    border-radius: 24px;
}

.slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    transition: var(--transition);
    border-radius: 50%;
}

input:checked + .slider { background: var(--success); }
input:checked + .slider::before { transform: translateX(20px); }

/* ===== Page Content ===== */
.page-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-light);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header h2 i {
    color: var(--primary-light);
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-icon.purple { background: rgba(108, 92, 231, 0.1); color: var(--primary); }
.stat-icon.green { background: rgba(0, 184, 148, 0.1); color: var(--success); }
.stat-icon.blue { background: rgba(78, 168, 222, 0.1); color: var(--info); }
.stat-icon.orange { background: rgba(225, 112, 85, 0.1); color: var(--danger); }
.stat-icon.teal { background: rgba(0, 180, 216, 0.1); color: var(--accent); }
.stat-icon.yellow { background: rgba(249, 168, 37, 0.1); color: var(--warning); }

.stat-info h3 {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-bottom: 4px;
}

.stat-info .value {
    font-size: 1.6rem;
    font-weight: 700;
}

.stat-info .sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== Grid Layout ===== */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

/* ===== Form Elements ===== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.form-group label i {
    margin-right: 6px;
    color: var(--primary-light);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%235A5A7A' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 10px center;
    background-repeat: no-repeat;
    background-size: 20px;
    padding-right: 36px;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}
.btn-primary:hover {
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #00A381);
    color: white;
}
.btn-success:hover {
    box-shadow: 0 4px 15px rgba(0, 184, 148, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #C44569);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary-light);
    background: rgba(108, 92, 231, 0.1);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===== Tables ===== */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th, table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table th {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table td {
    font-size: 0.9rem;
}

table tbody tr:hover {
    background: var(--bg-card-hover);
}

/* ===== Notification Items ===== */
.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 10px;
    transition: var(--transition);
    cursor: pointer;
}

.notification-item:hover {
    border-color: var(--primary);
    background: var(--bg-card-hover);
}

.notification-item.unread {
    border-left: 3px solid var(--primary);
    background: rgba(108, 92, 231, 0.05);
}

.notification-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}

.notification-icon.sales { background: rgba(0, 184, 148, 0.1); color: var(--success); }
.notification-icon.error { background: rgba(225, 112, 85, 0.1); color: var(--danger); }
.notification-icon.info { background: rgba(78, 168, 222, 0.1); color: var(--info); }
.notification-icon.follower { background: rgba(108, 92, 231, 0.1); color: var(--primary); }

.notification-content { flex: 1; }
.notification-content h4 { font-size: 0.9rem; font-weight: 500; margin-bottom: 4px; }
.notification-content p { font-size: 0.8rem; color: var(--text-secondary); }
.notification-time { font-size: 0.7rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }

.btn-icon-delete {
    background: none;
    border: none;
    color: #CCC;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    font-size: 0.75rem;
    transition: all 0.2s;
    line-height: 1;
}
.btn-icon-delete:hover { color: var(--danger); background: rgba(225,112,85,0.1); }

/* ===== Chat UI ===== */
.chat-container {
    display: flex;
    gap: 20px;
    height: calc(100vh - var(--topbar-height) - 80px);
    min-height: 500px;
}

.chat-list {
    width: 400px;
    flex-shrink: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-list-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

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

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border);
}

.chat-item:hover, .chat-item.active {
    background: var(--bg-card-hover);
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.chat-avatar.line { background: #06C755; color: white; }
.chat-avatar.facebook { background: #1877F2; color: white; }
.chat-avatar.test { background: var(--warning); color: white; }

/* AI toggle per chat */
.chat-item.ai-off { opacity: 0.6; }
.chat-item.ai-off .chat-avatar { position: relative; }
.chat-item.ai-off .chat-avatar::after {
    content: '';
    position: absolute;
    bottom: -2px; right: -2px;
    width: 12px; height: 12px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg-card);
}

/* Small toggle switch */
.toggle-switch-sm {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}
.toggle-switch-sm input { opacity: 0; width: 0; height: 0; }
.toggle-slider-sm {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #ccc;
    border-radius: 20px;
    transition: 0.3s;
}
.toggle-slider-sm::before {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    left: 2px; bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}
.toggle-switch-sm input:checked + .toggle-slider-sm { background: var(--success); }
.toggle-switch-sm input:checked + .toggle-slider-sm::before { transform: translateX(16px); }

.chat-item-info {
    flex: 1;
    min-width: 0;
}

.chat-item-name {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 2px;
}

.chat-item-last {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-time {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.chat-window {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-window-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 70%;
    padding: 10px 16px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}

.message.user {
    align-self: flex-start;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.message.bot {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message .sender-label {
    font-size: 0.7rem;
    font-weight: 600;
    margin-bottom: 4px;
    display: block;
}

.message.user .sender-label {
    color: var(--primary);
}

.message.bot .sender-label {
    color: rgba(255,255,255,0.8);
}

.message .time {
    font-size: 0.65rem;
    opacity: 0.7;
    margin-top: 4px;
    display: block;
}

.message.bot .time {
    text-align: right;
}

.message .cache-badge {
    font-size: 0.6rem;
    background: rgba(0, 206, 201, 0.2);
    color: var(--accent);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
}

.chat-input-area {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input-area input[type="text"] {
    flex: 1;
}

.chat-img-btn {
    width: 38px;
    height: 38px;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    color: var(--primary);
}
.chat-img-btn:hover {
    background: var(--primary);
    color: white;
}

/* Message image */
.msg-image-wrap {
    margin: 6px 0;
}
.msg-image {
    max-width: 220px;
    max-height: 200px;
    border-radius: 10px;
    cursor: pointer;
    object-fit: cover;
    transition: transform 0.2s;
}
.msg-image:hover {
    transform: scale(1.03);
}

/* ===== AI Model Cards ===== */
.model-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.model-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.model-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.model-card.selected {
    border-color: var(--accent);
    background: rgba(0, 206, 201, 0.05);
}

.model-card.selected::after {
    content: '\f058';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 12px;
    right: 12px;
    color: var(--accent);
    font-size: 1.2rem;
}

.model-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.model-card .model-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.model-card .pricing {
    display: flex;
    gap: 16px;
    font-size: 0.75rem;
}

.model-card .pricing .price-item {
    display: flex;
    flex-direction: column;
}

.model-card .pricing .price-label {
    color: var(--text-muted);
}

.model-card .pricing .price-value {
    font-weight: 600;
    color: var(--accent);
}

.model-card .recommend-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent), #00B894);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* ===== Business Info Categories ===== */
.category-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.category-tab {
    padding: 6px 16px;
    border-radius: 20px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    transition: var(--transition);
}

.category-tab:hover, .category-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.info-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
    transition: var(--transition);
}

.info-card:hover {
    border-color: var(--primary);
}

.info-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.info-card-header h4 {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-card-header .tag {
    font-size: 0.7rem;
    background: rgba(108, 92, 231, 0.2);
    color: var(--primary-light);
    padding: 2px 8px;
    border-radius: 4px;
}

.info-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ===== Settings Section ===== */
.settings-section {
    margin-bottom: 24px;
}

.settings-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-section h3 i {
    color: var(--primary-light);
}

.settings-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px;
    transform: translateY(20px);
    transition: var(--transition);
}

.modal-overlay.show .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
}

.modal-close:hover {
    color: var(--text-primary);
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    min-width: 250px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }
.toast.warning { background: var(--warning); color: #333; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 0.85rem;
}

/* ===== Loading ===== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Provider Toggle ===== */
.provider-toggle {
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}

.provider-btn {
    flex: 1;
    padding: 14px;
    text-align: center;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9rem;
}

.provider-btn:hover {
    background: var(--bg-card-hover);
}

.provider-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.provider-btn img {
    width: 20px;
    height: 20px;
}

/* ===== Test Chat ===== */
.test-chat {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.test-chat-messages {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 12px;
    padding: 8px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-toggle {
        display: block;
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-2 {
        grid-template-columns: 1fr;
    }
    
    .chat-container {
        flex-direction: column;
        height: auto;
    }
    
    .chat-list {
        width: 100%;
        max-height: 250px;
    }
    
    .settings-row {
        grid-template-columns: 1fr;
    }
    
    .model-grid {
        grid-template-columns: 1fr;
    }

    .page-content {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Webhook URL Display ===== */
.webhook-url {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--accent);
    word-break: break-all;
}

.webhook-url .copy-btn {
    padding: 4px 10px;
    background: var(--border);
    border: none;
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.75rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.webhook-url .copy-btn:hover {
    background: var(--primary);
}

/* ===== Cost Calculator ===== */
.cost-display {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.1), rgba(0, 206, 201, 0.1));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.cost-display .amount {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
}

.cost-display .label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ===== Tab content ===== */
.tab-content {
    display: none;
}

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

/* ===== Page Select Card ===== */
.page-select-card:hover {
    border-color: var(--primary-light) !important;
    box-shadow: 0 2px 8px rgba(108,92,231,0.1);
}

/* ===== Toggle Switch ===== */
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #ccc;
    border-radius: 26px;
    transition: 0.3s;
}
.toggle-slider::before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
}
