/* AmoCRM AI Copilot Styling */
:root {
    --bg-main: #f1f5f9;
    --bg-header: #ffffff;
    --border-color: #cbd5e1;
    --border-light: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --primary-blue: #1d4ed8;
    --primary-blue-hover: #1e40af;
    --accent-green: #059669;
    --accent-orange: #d97706;
    --card-bg: #ffffff;
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --radius-md: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.crm-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.crm-header {
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-light);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.crm-logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.amocrm-badge {
    background: #0284c7;
    color: white;
    font-weight: 700;
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 6px;
    letter-spacing: 0.5px;
}

.pipeline-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.stage-tag {
    background: #e0f2fe;
    color: #0369a1;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid #bae6fd;
}

.deal-meta {
    display: flex;
    gap: 20px;
    font-size: 13px;
}

.meta-item {
    display: flex;
    gap: 6px;
    align-items: center;
}

.meta-label {
    color: var(--text-muted);
}

.meta-value {
    font-weight: 600;
    color: var(--text-primary);
}

.meta-value.highlight {
    color: var(--accent-green);
    font-weight: 700;
}

/* Guide Banner */
.guide-banner {
    background: #ffffff;
    border-bottom: 1px solid var(--border-light);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: linear-gradient(90deg, #f8fafc 0%, #eff6ff 100%);
}

.guide-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #1e3a8a;
    white-space: nowrap;
}

.guide-icon {
    font-size: 16px;
}

.guide-steps {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.guide-step {
    display: flex;
    align-items: center;
    gap: 6px;
}

.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #2563eb;
    color: white;
    font-weight: 700;
    font-size: 11px;
    border-radius: 50%;
}

.guide-arrow {
    color: #94a3b8;
    font-weight: bold;
}

/* Main Workspace */
.crm-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 20px 24px;
    flex: 1;
}

/* Left Pane: Dialog */
.dialog-pane {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.lead-card {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
}

.lead-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #2563eb, #1e40af);
    color: white;
    font-weight: 700;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.lead-info {
    display: flex;
    flex-direction: column;
}

.lead-name {
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lead-source {
    font-size: 11px;
    font-weight: 500;
    background: #f1f5f9;
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 4px;
}

.lead-sub {
    font-size: 12px;
    color: var(--text-muted);
}

/* Presets */
.presets-section {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
}

.section-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.presets-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.preset-btn {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px 14px;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.preset-btn:hover {
    background: #eff6ff;
    border-color: #3b82f6;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.1);
}

.preset-btn.active {
    background: #eff6ff;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.preset-icon {
    font-size: 20px;
    line-height: 1;
    margin-top: 2px;
}

.preset-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.preset-title {
    font-size: 13px;
    font-weight: 700;
    color: #1e3a8a;
}

.preset-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Chat & Input */
.chat-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-form-container {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 14px;
    box-shadow: var(--shadow-sm);
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

textarea#clientInput {
    width: 100%;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.15s ease;
    color: var(--text-primary);
}

textarea#clientInput:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.primary-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 18px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease;
    box-shadow: 0 2px 4px rgba(29, 78, 216, 0.2);
}

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

.primary-btn:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    box-shadow: none;
}

/* Loading Block */
.loading-state {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #eff6ff;
    border: 1.5px solid #93c5fd;
    border-radius: var(--radius-md);
    padding: 16px 20px;
    animation: fadeIn 0.2s ease;
}

.loading-state.hidden {
    display: none;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #bfdbfe;
    border-top: 3px solid var(--primary-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

.loading-text-group {
    display: flex;
    flex-direction: column;
}

.loading-title {
    font-size: 14px;
    font-weight: 700;
    color: #1e3a8a;
}

.loading-sub {
    font-size: 12px;
    color: #2563eb;
    font-weight: 500;
}

/* Right Pane: AI Copilot */
.copilot-pane {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.copilot-header {
    background: #f8fafc;
    border-bottom: 1px solid var(--border-light);
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.copilot-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}

.badge-rag {
    background: #e2e8f0;
    color: #334155;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
}

.copilot-status {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-green);
    display: flex;
    align-items: center;
    gap: 6px;
}

.copilot-status::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--accent-green);
    border-radius: 50%;
}

.copilot-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

/* AI Cards */
.ai-card {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.client-response-card {
    background: #ffffff;
    border-left: 5px solid #059669;
}

.manager-tip-card {
    background: #fffbeb;
    border-left: 5px solid #d97706;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
}

.manager-tip-card .card-header {
    background: #fef3c7;
    border-bottom: 1px solid #fde68a;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
}

.copy-btn {
    background: white;
    border: 1.5px solid #cbd5e1;
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.copy-btn:hover {
    background: #f1f5f9;
    color: var(--text-primary);
    border-color: #94a3b8;
}

.copy-btn.copied {
    background: #dcfce7;
    border-color: #86efac;
    color: #15803d;
}

.badge-internal {
    background: #fee2e2;
    color: #991b1b;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
}

.card-body {
    padding: 16px;
}

.response-text, .tip-text {
    font-size: 14px;
    line-height: 1.6;
    color: #1e293b;
    white-space: pre-wrap;
    word-break: break-word;
}

.tip-text {
    color: #78350f;
}

/* Footer Execution Stats */
.execution-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    font-size: 12px;
    margin-top: auto;
}

.stat-item {
    display: flex;
    gap: 6px;
}

.stat-name {
    color: var(--text-muted);
}

.stat-val {
    font-weight: 600;
    color: var(--text-secondary);
}

.text-success {
    color: var(--accent-green);
    font-weight: 700;
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
    .crm-main {
        grid-template-columns: 1fr;
    }
    .guide-banner {
        flex-direction: column;
        align-items: flex-start;
    }
}

.demo-video-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #059669;
    color: white;
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 6px;
    transition: background 0.15s ease;
    box-shadow: 0 1px 3px rgba(5, 150, 105, 0.3);
}

.demo-video-btn:hover {
    background: #047857;
}
