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

:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-hover: #242836;
    --border: #2a2e3d;
    --text: #e4e6ef;
    --text-muted: #6b7280;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --accent: #3b82f6;
    --sent: #22c55e;
    --received: #374151;
    --radius: 10px;
    --radius-lg: 16px;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow: hidden;
}

.app {
    display: flex;
    height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 240px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}


.status-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-reset {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-reset:hover { background: var(--bg-hover); color: var(--text); border-color: var(--primary); }
.btn-reset.spinning { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.sidebar-nav {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 12px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    transition: all 0.2s;
    font-family: inherit;
}

.nav-btn:hover { background: var(--bg-hover); color: var(--text); }
.nav-btn.active { background: var(--primary); color: white; }

/* Anti-ban widget */
.antiban-widget {
    padding: 16px;
    margin: 12px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius);
}

.antiban-widget h3 { font-size: 12px; font-weight: 600; color: var(--primary); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.5px; }

.antiban-tips {
    margin-top: 8px;
    font-size: 11px;
    line-height: 1.4;
}

.antiban-tips p { margin: 0; color: var(--text-muted); }

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 6px;
    color: var(--text-muted);
}

.stat-row span:last-child { font-weight: 600; color: var(--text); }

.progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 4px;
    margin-top: 8px;
    overflow: hidden;
}

.progress-bar.large { height: 8px; margin: 16px 0; }

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--primary));
    border-radius: 4px;
    transition: width 0.5s ease;
    width: 0%;
}

/* ===== MAIN CONTENT ===== */
.main {
    flex: 1;
    overflow-y: auto;
    position: relative;
}

.tab-content { display: none; padding: 24px; height: 100%; }
.tab-content.active { display: flex; flex-direction: column; }

.tab-header { margin-bottom: 24px; }
.tab-header h2 { font-size: 24px; font-weight: 700; }

/* ===== CONNECTION TAB ===== */
.connection-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.connection-status-card { padding: 20px; }

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

.connection-status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
}

.conn-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--danger);
    display: inline-block;
}

.conn-dot.connected { background: var(--success); box-shadow: 0 0 8px rgba(34, 197, 94, 0.5); }
.conn-dot.connecting { background: var(--warning); animation: pulse 1.5s infinite; }
.conn-dot.stopped { background: var(--text-muted); }

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

.connection-qr-card {
    text-align: center;
    padding: 24px;
}

.connection-qr-card h3 { margin-bottom: 16px; }

.qr-display {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.qr-display img {
    max-width: 260px;
    width: 100%;
    border-radius: var(--radius);
    border: 3px solid var(--primary);
    padding: 12px;
    background: white;
}

.qr-steps {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

.connection-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.connection-buttons .btn { flex: 1; min-width: 140px; }

.connection-actions-info {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.8;
}

.connection-actions-info p { margin-bottom: 4px; }
.connection-actions-info strong { color: var(--text); }

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-success { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-primary { background: rgba(99, 102, 241, 0.15); color: var(--primary); }

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.stat-card .stat-value { font-size: 32px; font-weight: 700; color: var(--text); }
.stat-card .stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.warning .stat-value { color: var(--warning); }

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

.card h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

/* ===== SERVER LOGS ===== */
.logs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.logs-header h3 { margin-bottom: 0; }

.server-logs {
    background: #0d0f14;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    max-height: 250px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.6;
}

.log-entry {
    display: flex;
    gap: 8px;
    padding: 2px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.log-time { color: var(--text-muted); white-space: nowrap; min-width: 70px; }
.log-msg { flex: 1; word-break: break-word; }

.log-entry.log-success .log-msg { color: var(--success); }
.log-entry.log-error .log-msg { color: var(--danger); }
.log-entry.log-warning .log-msg { color: var(--warning); }
.log-entry.log-campaign .log-msg { color: var(--accent); }
.log-entry.log-antiban .log-msg { color: var(--warning); }
.log-entry.log-info .log-msg { color: var(--text); }

/* ===== CAMPAIGN EXPORT ===== */
.campaign-item-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.campaign-item-actions .btn-sm { font-size: 11px; padding: 3px 8px; }

/* ===== CAMPAIGN PREVIEW ===== */
.preview-list {
    max-height: 300px;
    overflow-y: auto;
}

.preview-item {
    display: flex;
    gap: 12px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    align-items: flex-start;
}

.preview-item:last-child { border-bottom: none; }

.preview-number {
    font-weight: 600;
    color: var(--text);
    min-width: 120px;
    white-space: nowrap;
}

.preview-msg {
    color: var(--text-muted);
    flex: 1;
    line-height: 1.4;
}

.preview-variant-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    white-space: nowrap;
}

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }

input[type="text"], textarea, select {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.2s;
    resize: vertical;
}

input[type="text"]:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

small { font-size: 12px; color: var(--text-muted); }

.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ===== BUTTONS ===== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-hover); color: var(--text); }
.btn-secondary:hover { background: var(--border); }
.btn-warning { background: var(--warning); color: black; }
.btn-warning:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== CAMPAIGNS LIST ===== */
.campaigns-list, .recent-replies { max-height: 250px; overflow-y: auto; }

.campaign-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.campaign-item-info h4 { font-size: 14px; margin-bottom: 4px; }
.campaign-item-info span { font-size: 12px; color: var(--text-muted); }

.campaign-item-stats { display: flex; gap: 12px; font-size: 12px; }
.campaign-item-stats span { display: flex; align-items: center; gap: 4px; }

/* ===== REPLY ITEM ===== */
.reply-item {
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius);
    margin-bottom: 8px;
    border-left: 3px solid var(--success);
}

.reply-item .reply-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.reply-item .reply-name { font-weight: 600; font-size: 13px; }
.reply-item .reply-time { font-size: 11px; color: var(--text-muted); }
.reply-item .reply-text { font-size: 13px; color: var(--text-muted); }

/* ===== CONVERSATIONS LAYOUT ===== */
.conversations-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
    flex: 1;
    min-height: 0;
}

.contacts-panel { display: flex; flex-direction: column; overflow: hidden; }
.contacts-header { display: flex; justify-content: space-between; align-items: center; }
.contacts-header h3 { margin-bottom: 0; }

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

.contact-item {
    padding: 10px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.contact-item:hover { background: var(--bg-hover); }
.contact-item.active { background: var(--primary); }

.contact-info { flex: 1; min-width: 0; }
.contact-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-number { font-size: 11px; color: var(--text-muted); }
.contact-item.active .contact-number { color: rgba(255,255,255,0.7); }

.contact-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.contact-status.replied { background: var(--success); }
.contact-status.sent { background: var(--warning); }
.contact-status.active { background: var(--accent); }

.contact-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.contact-item:hover .contact-actions { opacity: 1; }
.contact-item.active .contact-actions { opacity: 1; }

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-icon:hover { background: rgba(255,255,255,0.1); color: var(--text); }
.contact-item.active .btn-icon { color: rgba(255,255,255,0.7); }
.contact-item.active .btn-icon:hover { color: white; background: rgba(255,255,255,0.15); }

/* ===== CHAT PANEL ===== */
.chat-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

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

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

.chat-input {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.send-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.send-form textarea {
    flex: 1;
    min-height: 40px;
    max-height: 100px;
    resize: none;
}

.send-form button { flex-shrink: 0; }

/* ===== ATTACH MENU ===== */
.attach-wrapper {
    position: relative;
    flex-shrink: 0;
}
.attach-btn {
    height: 40px;
    padding: 0 12px;
    font-size: 18px;
}
.attach-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    width: 320px;
    max-height: 420px;
    overflow-y: auto;
    background: var(--bg, #fff);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    padding: 12px;
    z-index: 100;
}
.attach-menu.hidden { display: none; }
.attach-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.attach-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-muted);
}
.attach-section { margin-bottom: 12px; }
.attach-section:last-child { margin-bottom: 0; }
.attach-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.attach-docs-list {
    max-height: 140px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px;
}
.attach-doc-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}
.attach-doc-item:hover { background: rgba(0,0,0,0.05); }
.attach-doc-item .doc-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin-right: 8px;
}
.attach-doc-item .doc-send {
    font-size: 11px;
    padding: 3px 8px;
}
.attach-upload-input {
    display: block;
    width: 100%;
    margin-bottom: 6px;
    font-size: 12px;
}
.attach-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.attach-caption {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
}
.small { font-size: 12px; }

/* ===== MESSAGES ===== */
.message-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}

.message-bubble.received {
    background: var(--received);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message-bubble.sent {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.2);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    gap: 12px;
}

.message-sender { font-size: 12px; font-weight: 600; }
.message-bubble.received .message-sender { color: var(--accent); }
.message-bubble.sent .message-sender { color: var(--success); }
.message-time { font-size: 10px; color: var(--text-muted); }
.message-body { white-space: pre-wrap; }

.ai-disabled-notice {
    text-align: center;
    padding: 6px 12px;
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    align-self: center;
}

/* ===== SETTINGS ===== */
.ia-settings-row {
    display: flex;
    gap: 20px;
    align-items: stretch;
}

.ia-prompt-col {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.ia-prompt-col textarea { flex: 1; resize: vertical; }

.ia-temp-col {
    width: 160px;
    min-width: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

input[type="range"] {
    width: 100%;
    margin: 12px 0 4px;
    accent-color: var(--primary);
}

.temp-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); }

.prompt-status {
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 12px;
    margin-bottom: 12px;
}

/* ===== PROGRESS STATS ===== */
.progress-stats {
    display: flex;
    gap: 20px;
    font-size: 14px;
    margin-bottom: 16px;
}

/* ===== NOTIFICATION ===== */
.notification {
    position: fixed;
    top: 16px;
    right: 16px;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.3s ease;
}

.notification.show { transform: translateX(0); opacity: 1; }
.notification.success { background: var(--success); color: white; }
.notification.error { background: var(--danger); color: white; }

/* ===== AUTH OVERLAY ===== */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 10, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.auth-modal {
    width: min(480px, 100%);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 32px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.26);
    text-align: center;
}

.auth-modal h2 {
    margin-bottom: 12px;
    font-size: 1.35rem;
}

.auth-modal p {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.auth-modal input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel-bg);
    color: var(--text);
    font-size: 1rem;
    margin-bottom: 16px;
}

.auth-actions {
    display: flex;
    justify-content: center;
}

.auth-error {
    margin-top: 14px;
    color: var(--danger);
    min-height: 20px;
    font-size: 0.95rem;
}

.auth-hint {
    margin-top: 16px;
    font-size: 0.95rem;
    color: var(--text-muted);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== ANTI-BAN SETTINGS ===== */
.antiban-settings-card { margin-top: 8px; }
.antiban-settings-header { margin-bottom: 20px; }
.antiban-settings-header h3 { margin-bottom: 8px; }

.settings-section { margin-bottom: 24px; }
.settings-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.warmup-explanation {
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: var(--radius);
    padding: 14px 16px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
}

.warmup-preview {
    margin-top: 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.warmup-preview h5 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.warmup-bars {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 80px;
}

.warmup-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.warmup-bar {
    width: 100%;
    min-height: 4px;
    border-radius: 3px 3px 0 0;
    background: var(--primary);
    transition: height 0.3s;
    position: relative;
}

.warmup-bar.current {
    background: var(--success);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

.warmup-bar.future { opacity: 0.4; }

.warmup-bar-label {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}

.warmup-bar-value {
    font-size: 10px;
    font-weight: 600;
    color: var(--text);
}

.warmup-disabled-msg {
    text-align: center;
    padding: 16px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ===== TOOLTIP (i) ICON ===== */
.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 11px;
    font-style: normal;
    font-weight: 700;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    border-radius: 50%;
    cursor: help;
    vertical-align: middle;
    margin-left: 4px;
    position: relative;
}

.tooltip-icon:hover { background: rgba(99, 102, 241, 0.3); }

/* ===== VARIATIONS SECTION (campagne) ===== */
.variations-section {
    margin: 8px 0 16px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

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

.variations-header label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.variations-container {
    max-height: 300px;
    overflow-y: auto;
}

.variation-card {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.variation-card:last-child { border-bottom: none; }
.variation-card:hover { background: rgba(99, 102, 241, 0.03); }

.variation-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.variation-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.variation-badge.original {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.variation-text {
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
    white-space: pre-wrap;
}

.variations-info {
    padding: 10px 16px;
    background: rgba(34, 197, 94, 0.05);
    border-top: 1px solid var(--border);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

p.ai-disabled-notice {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--danger);
    padding: 10px 14px;
    margin: 8px 0;
    border-radius: 4px;
    font-size: 12px;
    color: var(--danger);
    text-align: center;
}

.variations-loading {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
}

.variations-loading .spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
}

/* ===== STUDENT EXTRACTOR ===== */
.students-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.student-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    transition: all 0.2s;
}

.student-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
}

.student-photo {
    width: 64px;
    height: 64px;
    min-width: 64px;
    background: var(--bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    overflow: hidden;
    border: 2px solid var(--border);
}

.student-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

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

.student-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.student-id {
    font-weight: 700;
    font-size: 13px;
    color: var(--primary);
    background: rgba(99,102,241,0.08);
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
}

.student-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.student-details-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
}

.student-detail {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.student-detail strong {
    color: var(--text);
    font-weight: 500;
}

.student-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 110px;
}

/* ===== STUDENT TAGS ===== */
.student-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.student-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.student-tag:hover {
    border-color: var(--primary);
    color: var(--text);
    background: rgba(99, 102, 241, 0.06);
}

.student-tag.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.student-tag.tag-major       { border-color: rgba(99, 102, 241, 0.3); }
.student-tag.tag-grade       { border-color: rgba(34, 197, 94, 0.3); }
.student-tag.tag-nationality { border-color: rgba(245, 158, 11, 0.3); }
.student-tag.tag-campus      { border-color: rgba(236, 72, 153, 0.3); }
.student-tag.tag-docs        { border-color: rgba(59, 130, 246, 0.3); color: #3b82f6; }

/* ===== STUDENT DOCUMENTS ===== */
.student-docs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.student-doc-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(59, 130, 246, 0.08);
    color: #3b82f6;
    text-decoration: none;
    border: 1px solid rgba(59, 130, 246, 0.2);
    font-weight: 500;
    transition: all 0.15s;
}

.student-doc-link:hover {
    background: rgba(59, 130, 246, 0.15);
    transform: translateY(-1px);
}

/* ===== TAG FILTER BAR ===== */
.student-tag-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0;
    padding: 10px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.student-tag-filters:empty {
    display: none;
}

.tag-group {
    display: inline-block;
}

.tag-group summary {
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    list-style: none;
    user-select: none;
}

.tag-group summary::-webkit-details-marker { display: none; }

.tag-group[open] summary {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.06);
}

.tag-count {
    display: inline-block;
    background: var(--primary);
    color: white;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 4px;
}

.tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
    padding: 8px;
    background: var(--bg-card);
    border-radius: 6px;
    max-width: 100%;
}

/* Collapsible tag chips - show only 2 rows by default */
.tag-chips.collapsible {
    max-height: 52px;
    overflow: hidden;
    position: relative;
}

.tag-expand-btn {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 4px 10px;
    font-size: 11px;
    color: var(--primary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.tag-expand-btn:hover {
    background: rgba(99, 102, 241, 0.06);
    border-color: var(--primary);
}

/* Tag chip label with checkbox */
.tag-chip-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    user-select: none;
}

.tag-chip-label:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
    color: var(--text);
}

.tag-chip-label.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    font-weight: 600;
    transform: scale(1.02);
}

/* Disabled state - gray out when no matches */
.tag-chip-label.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--bg);
    color: var(--text-muted);
    pointer-events: none;
}

.tag-chip-label.disabled .tag-checkbox {
    cursor: not-allowed;
}

.tag-checkbox {
    width: 14px;
    height: 14px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary);
}

.tag-chip-text {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.tag-chip-count {
    font-size: 10px;
    opacity: 0.7;
}

.tag-chip-label.active .tag-chip-count {
    opacity: 0.9;
}

/* Documents tag special styling */
.tag-chip-label.tag-docs {
    background: rgba(59, 130, 246, 0.08);
    color: #3b82f6;
    border-color: rgba(59, 130, 246, 0.3);
    font-weight: 500;
}

.tag-chip-label.tag-docs.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.tag-chip-label.tag-docs.disabled {
    background: var(--bg);
    color: var(--text-muted);
    border-color: var(--border);
    opacity: 0.4;
}

/* Clear filter button */
.tag-chip.tag-clear {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
    font-weight: 500;
    padding: 4px 12px;
}

.tag-chip.tag-clear:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--danger);
}

.student-email {
    font-size: 11px;
    color: var(--accent);
    word-break: break-all;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid var(--border);
}

/* ===== STUDENT CURRENT ID STATUS ===== */
.student-current-id {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    margin-top: 6px;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-block;
}

.student-current-id.processing {
    color: var(--text-muted);
    background: rgba(107, 114, 128, 0.1);
}

.student-current-id.success {
    color: var(--success);
    background: rgba(34, 197, 94, 0.1);
}

.student-current-id.cached {
    color: var(--warning);
    background: rgba(245, 158, 11, 0.1);
}

.student-current-id.error {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.08);
}

/* ===== STUDENT SEARCH ===== */
#student-search {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 14px;
    color: var(--text);
    font-size: 13px;
    width: 100%;
    transition: border-color 0.2s;
}

#student-search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* ===== BTN SUCCESS ===== */
.btn-success { background: var(--success); color: white; }
.btn-success:hover { opacity: 0.88; transform: translateY(-1px); }

/* ===== STUDENT CHECKBOX SELECT ===== */
.student-select-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px 0 2px;
    cursor: pointer;
    flex-shrink: 0;
}

.student-checkbox {
    width: 17px;
    height: 17px;
    accent-color: var(--primary);
    cursor: pointer;
    border-radius: 4px;
}

.student-card {
    transition: box-shadow 0.15s, border-color 0.15s, background 0.15s;
}

.student-card.selected {
    border-color: var(--primary) !important;
    background: rgba(99, 102, 241, 0.07);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.18);
}

/* ===== STUDENT SELECTION BAR ===== */
.student-selection-bar {
    display: none;
    align-items: center;
    gap: 10px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius);
    padding: 8px 14px;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 500;
    flex-wrap: wrap;
}

.student-selection-bar .btn {
    font-size: 12px;
    padding: 5px 12px;
}

/* ===== STUDENT SORT/FILTER TOOLBAR ===== */
.student-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.student-toolbar .student-search-bar {
    flex: 1;
    min-width: 180px;
    margin-bottom: 0;
}

#btn-sort-id {
    white-space: nowrap;
    flex-shrink: 0;
}

#btn-select-all, #btn-deselect-all {
    white-space: nowrap;
    flex-shrink: 0;
}

/* Spinner (variations loading) */
.variations-loading .spinner {
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

.antiban-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 12px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    gap: 16px;
    transition: border-color 0.2s;
}

.setting-item:hover { border-color: rgba(99, 102, 241, 0.3); }

.setting-info { flex: 1; min-width: 0; }
.setting-info label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.setting-info small { font-size: 11px; color: var(--text-muted); line-height: 1.3; display: block; }

.setting-control {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.setting-control input[type="number"] {
    width: 100px;
    text-align: center;
    padding: 8px 10px;
    font-size: 14px;
    font-weight: 600;
}

.setting-control .unit {
    font-size: 11px;
    color: var(--text-muted);
    min-width: 30px;
}

/* Toggle switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    cursor: pointer;
}

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

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 26px;
    transition: all 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    bottom: 3px;
    background: var(--text);
    border-radius: 50%;
    transition: all 0.3s;
}

.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(22px); }

/* ===== UTILITIES ===== */
.muted { color: var(--text-muted); font-size: 13px; }
.center { text-align: center; padding: 40px; }
.char-count { display: block; text-align: right; margin-top: 4px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .conversations-layout { grid-template-columns: 1fr; }
    .contacts-panel { max-height: 200px; }
}

/* Toggle switch IA global */
.ai-toggle-global {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-toggle-status {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.ai-toggle-status.ai-on { color: var(--success); }
.ai-toggle-status.ai-off { color: var(--danger); }

.ai-toggle-campaign {
    padding: 12px 16px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.15);
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--danger);
    transition: .3s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
}

input:checked + .slider { background-color: var(--success); }
input:checked + .slider:before { transform: translateX(20px); }
.slider.round { border-radius: 24px; }
.slider.round:before { border-radius: 50%; }

@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-header h1, .nav-btn span, .antiban-widget h3,
    .stat-row span:first-child, .antiban-widget .stat-row { display: none; }
    .nav-btn { text-align: center; padding: 12px 8px; }
}

/* ===== REPLY INTERVAL TABLE ===== */
.reply-interval-table {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.reply-interval-table .table-header {
    display: grid;
    grid-template-columns: 1.5fr 1fr 120px 2fr 150px;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(99, 102, 241, 0.08);
    border-radius: var(--radius) var(--radius) 0 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.reply-interval-table .table-body {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 600px;
    overflow-y: auto;
}

.reply-interval-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 120px 2fr 150px;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
    align-items: center;
}

.reply-interval-row:hover {
    background: var(--bg-hover);
}

.reply-interval-row:last-child {
    border-bottom: none;
}

.reply-interval-row .col-name {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.reply-interval-row .col-name strong {
    font-size: 14px;
    color: var(--text);
}

.reply-interval-row .col-name small {
    font-size: 12px;
    color: var(--text-muted);
}

.reply-interval-row .col-number {
    font-size: 13px;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
}

.reply-interval-row .col-days {
    display: flex;
    align-items: center;
}

.reply-interval-row .col-last-msg {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-interval-row .col-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

@media (max-width: 1200px) {
    .reply-interval-table .table-header,
    .reply-interval-row {
        grid-template-columns: 1.5fr 1fr 100px 150px;
    }

    .reply-interval-row .col-last-msg {
        display: none;
    }

    .reply-interval-table .table-header .col-last-msg {
        display: none;
    }
}

@media (max-width: 768px) {
    .reply-interval-table .table-header,
    .reply-interval-row {
        grid-template-columns: 2fr 120px 100px;
    }

    .reply-interval-row .col-number,
    .reply-interval-table .table-header .col-number {
        display: none;
    }
}
