/* FR-Bot — minimal styles */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --warning: #eab308;
    --danger: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--gray-900);
    background: var(--gray-50);
    line-height: 1.5;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 33.33%;
    min-width: 300px;
    max-width: 450px;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    background: #fff;
}

.main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--gray-50);
}

/* Header */
.header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
}

.header h1 {
    font-size: 18px;
    font-weight: 600;
}

/* Status indicator */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}
.status-dot.connected { background: var(--success); }
.status-dot.disconnected { background: var(--danger); }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
}
.badge-new { background: #dbeafe; color: #1e40af; }
.badge-in_progress { background: #fef3c7; color: #92400e; }
.badge-closed_success { background: #d1fae5; color: #065f46; }
.badge-closed_rejected { background: var(--gray-100); color: var(--gray-500); }

.badge-unread {
    background: var(--primary);
    color: #fff;
    min-width: 20px;
    text-align: center;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
}

/* Lead list */
.lead-list {
    overflow-y: auto;
    flex: 1;
}

.lead-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.15s;
}
.lead-item:hover { background: var(--gray-50); }
.lead-item.active { background: #eff6ff; }
.lead-item.unread .lead-name { font-weight: 600; }

.lead-info { flex: 1; min-width: 0; }
.lead-name { font-size: 14px; font-weight: 500; }
.lead-preview {
    font-size: 13px;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lead-meta {
    text-align: right;
    flex-shrink: 0;
}
.lead-time {
    font-size: 12px;
    color: var(--gray-400);
}

/* Chat */
.chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

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

.message {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}
.message.incoming {
    align-self: flex-start;
    background: var(--gray-100);
}
.message.outgoing {
    align-self: flex-end;
    background: #dbeafe;
}
.message.outgoing-tg {
    align-self: flex-end;
    background: #e0f2fe;
}
.message.system {
    align-self: center;
    background: none;
    color: var(--gray-400);
    font-size: 12px;
    padding: 4px 0;
}

.message-time {
    font-size: 11px;
    color: var(--gray-400);
    margin-top: 4px;
}

/* Chat input */
.chat-input {
    padding: 12px 16px;
    border-top: 1px solid var(--gray-200);
    background: #fff;
    display: flex;
    gap: 8px;
}
.chat-input textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    min-height: 40px;
    max-height: 120px;
}
.chat-input textarea:focus { border-color: var(--primary); }

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { background: var(--gray-300); cursor: not-allowed; }

/* Select */
select.status-select {
    padding: 4px 8px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
}

/* Banner */
.banner {
    padding: 8px 16px;
    font-size: 13px;
    text-align: center;
}
.banner-warning { background: #fef3c7; color: #92400e; }
.banner-gray { background: var(--gray-100); color: var(--gray-500); }

/* Empty state */
.empty-state {
    padding: 48px 24px;
    text-align: center;
    color: var(--gray-400);
}
.empty-state p { font-size: 15px; margin-top: 8px; }

/* Filters */
.filters {
    padding: 8px 16px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    gap: 8px;
}
.filters select {
    padding: 4px 8px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
}

/* Login / Setup page */
.auth-card {
    max-width: 400px;
    margin: 80px auto;
    padding: 32px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.auth-card h1 {
    font-size: 24px;
    margin-bottom: 24px;
    text-align: center;
}
.auth-card input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 12px;
}
.auth-card input:focus { border-color: var(--primary); outline: none; }
.auth-card .btn { width: 100%; }
.auth-card .error {
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 12px;
}

/* Progress steps */
.steps {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 24px;
}
.step {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    background: var(--gray-200);
    color: var(--gray-500);
}
.step.active { background: var(--primary); color: #fff; }
.step.done { background: var(--success); color: #fff; }

/* Loading */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Mobile */
@media (max-width: 767px) {
    .sidebar {
        width: 100%;
        max-width: none;
        min-width: auto;
    }
    .main-panel { display: none; }
    .app-container.chat-open .sidebar { display: none; }
    .app-container.chat-open .main-panel { display: flex; }

    .back-btn { display: inline-flex !important; }
}

@media (min-width: 768px) {
    .back-btn { display: none !important; }
}

/* Nav */
.bottom-nav {
    display: none;
    border-top: 1px solid var(--gray-200);
    background: #fff;
    padding: 8px 0;
}
@media (max-width: 767px) {
    .bottom-nav {
        display: flex;
        justify-content: space-around;
    }
}
.bottom-nav a {
    text-decoration: none;
    color: var(--gray-500);
    font-size: 12px;
    text-align: center;
    padding: 4px 16px;
}
.bottom-nav a.active { color: var(--primary); }
