/* 
 * Leadora CRM - Main Stylesheet
 * Design System & Custom Styles
 */

/* CSS Custom Properties */
/* CSS Custom Properties */
/* CSS Custom Properties */
/* CSS Custom Properties */
/* CSS Custom Properties */
:root {
    /* Brand Colors */
    --primary: #0ea5e9;
    /* Azul Elétrico */
    --primary-dark: #1e3a8a;
    /* Azul Profundo */
    --night: #0b1726;
    /* Azul Noite (Used for dark accents/text) */
    --purple: #6d28d9;
    /* Roxo Suave */
    --gradient: linear-gradient(90deg, #0ea5e9 0%, #6d28d9 100%);

    /* Neutrals - Clean Light Theme */
    --gray-light: #f1f5f9;
    /* Background usually */
    --gray-mid: #94a3b8;
    --gray-dark: #1e293b;
    --white: #ffffff;

    /* Semantic */
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;

    /* UI Assignments */
    --bg-body: #f3f4f6;
    /* Light Gray Background */
    --bg-home: #f3f4f6;
    /* Landing on Light Gray to make Card pop */
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    /* White Sidebar to match reference */

    --text-main: #334155;
    /* Slate 700 */
    --text-light: #64748b;
    /* Slate 500 (Secondary text) */
    --text-muted: #94a3b8;
    --text-sidebar: #64748b;

    --border-color: #e2e8f0;
    --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.05);
    /* Very soft shadow */

    /* Legacy/Alias Variables */
    --leadora-primary: var(--primary);
    --leadora-deep: var(--primary-dark);
    --leadora-mid: #2563EB;
}

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

html {
    scroll-behavior: smooth;
}

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

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    line-height: 1.25;
    color: var(--night);
    /* Dark headings */
    letter-spacing: -0.02em;
}

/* Gradient Background */
.bg-gradient {
    background: var(--gradient);
}

/* Card Styles */
.card {
    background: var(--bg-card);
    border-radius: 24px;
    /* Highly rounded as per reference */
    box-shadow: var(--shadow-card);
    padding: 2rem;
    color: var(--text-main);
    border: none;
    /* Clean look */
}

/* Card Typography Overrides */
.card h1,
.card h2,
.card h3,
.card h4,
.card h5,
.card h6 {
    color: var(--night);
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 2rem;
    border-radius: 16px;
    /* Rounded buttons */
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(14, 165, 233, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #f8fafc;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    /* Ensure visibility */
    font-weight: 600;
}

.btn-secondary:hover {
    background: #f1f5f9;
    color: var(--primary);
    border-color: var(--primary);
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    backdrop-filter: blur(8px);
}

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

/* Form Inputs */
.form-input {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--white);
    color: var(--text-main);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.15);
}

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

.form-textarea {
    width: 100%;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--white);
    color: var(--text-main);
    font-family: inherit;
    line-height: 1.6;
    min-height: 100px;
    resize: vertical;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.15);
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-main);
    /* On white cards */
}

/* Radio Option Style Update */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.radio-option {
    position: relative;
}

.radio-option input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.radio-option label {
    display: block;
    padding: 1rem 1.25rem;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
}

.radio-option label:hover {
    border-color: var(--primary);
    background: rgba(14, 165, 233, 0.02);
}

.radio-option input:checked + label {
    border-color: var(--primary);
    background: rgba(14, 165, 233, 0.08);
    color: var(--primary);
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.1);
}

/* Section headers */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.section-subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    margin: 0;
}

.page-action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
}

/* Data Tables */
.data-table-wrapper {
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
}

.data-table thead th {
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: left;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody td {
    padding: 1.15rem 1.25rem;
    border-bottom: 1px solid #eef2f6;
    color: var(--text-main);
    font-size: 1rem;
}

.data-table tbody tr:hover {
    background: #f8fbff;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
}

.badge-role.agent {
    background: rgba(14, 165, 233, 0.1);
    color: #0369a1;
}

.badge-role.company_admin {
    background: rgba(109, 40, 217, 0.1);
    color: #5b21b6;
}

.badge-role.super_admin {
    background: rgba(15, 118, 110, 0.12);
    color: #0f766e;
}

.badge-company {
    background: rgba(226, 232, 240, 0.5);
    color: #1e293b;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

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

.modal-card {
    background: var(--bg-card);
    border-radius: 18px;
    padding: 1.5rem;
    width: 100%;
    max-width: 560px;
    box-shadow: 0 25px 60px -20px rgba(0, 0, 0, 0.35);
    position: relative;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.modal-title {
    margin: 0;
    font-size: 1.25rem;
    color: var(--night);
}

.modal-subtitle {
    margin: 0.15rem 0 0;
    color: var(--text-muted);
}

.btn-icon {
    border: none;
    background: #f1f5f9;
    color: #475569;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: #e2e8f0;
    color: var(--primary);
}

/* Override modal for users page to ensure visibility */
.modal-overlay.user-modal {
    z-index: 3000;
    display: flex;
    opacity: 0;
    visibility: hidden;
}

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

.user-modal .modal-card {
    max-width: 560px;
}

.password-strength {
    margin-top: 0.4rem;
}

.password-strength-bar {
    position: relative;
    height: 6px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.password-strength-bar::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--strength, 0%);
    background: var(--strength-color, #ef4444);
    transition: width 0.2s ease, background 0.2s ease;
}

.password-strength-text {
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.badge-status-active {
    background: rgba(34, 197, 94, 0.15);
    color: #15803d;
}

.badge-status-inactive {
    background: rgba(148, 163, 184, 0.2);
    color: #475569;
}

/* ========== QUIZ STYLES ========== */

.quiz-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-body);
}

.quiz-header {
    background: var(--bg-card);
    padding: 1.5rem 2rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
}

.quiz-logo {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.quiz-progress-container {
    margin-top: 1rem;
}

.quiz-progress-bar {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: var(--leadora-primary);
    border-radius: 3px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.quiz-progress-text {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    opacity: 0.9;
    color: var(--text-muted);
}

.quiz-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.quiz-question-container {
    width: 100%;
    max-width: 500px;
}

.quiz-question {
    display: none;
    animation: fadeSlideIn 0.4s ease forwards;
}

.quiz-question.active {
    display: block;
}

.quiz-question.exit {
    animation: fadeSlideOut 0.3s ease forwards;
}

.quiz-question-number {
    font-size: 0.875rem;
    color: var(--leadora-primary);
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.quiz-question-text {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--leadora-deep);
    margin-bottom: 2rem;
    line-height: 1.4;
}

@media (min-width: 640px) {
    .quiz-question-text {
        font-size: 1.75rem;
    }
}

.quiz-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.quiz-btn-back {
    padding: 0.875rem 1.5rem;
    border-radius: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 2px solid #E2E8F0;
    background: transparent;
    color: #64748B;
    transition: all 0.25s ease;
}

.quiz-btn-back:hover:not(:disabled) {
    border-color: var(--leadora-primary);
    color: var(--leadora-primary);
}

.quiz-btn-back:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.quiz-btn-next {
    flex: 1;
    padding: 0.875rem 2rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: var(--gradient);
    color: white;
    box-shadow: 0 4px 14px rgba(14, 165, 233, 0.35);
    transition: all 0.3s ease;
}

.quiz-btn-next:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(14, 165, 233, 0.45);
}

.quiz-btn-next:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Quiz Animations */
@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(-30px);
    }
}

.quiz-footer {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 100;
}

.quiz-footer a {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    background: rgba(255, 255, 255, 0.8);
    padding: 0.5rem 0.75rem;
    border-radius: 99px;
    backdrop-filter: blur(4px);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.quiz-footer a:hover {
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.quiz-footer a strong {
    color: var(--primary);
    font-weight: 700;
}

/* Conversion Modal Styles */
.conversion-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
    animation: fadeIn 0.2s ease;
}

.conversion-modal {
    background: white;
    border-radius: 20px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.conversion-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.conversion-modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
    color: #111827;
    letter-spacing: -0.03em;
}

.conversion-modal-close {
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.conversion-modal-close:hover {
    background: #fee2e2;
    color: #ef4444;
    border-color: #fecaca;
}

.conversion-modal-body {
    padding: 1.5rem;
}

.conversion-modal-description {
    color: var(--text-muted);
    font-size: 0.9375rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.conversion-form-group {
    margin-bottom: 1.25rem;
}

.conversion-form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 0.5rem;
}

.conversion-input,
.conversion-textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    outline: none;
    transition: all 0.2s;
    font-family: inherit;
}

.conversion-input:focus,
.conversion-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(3, 112, 254, 0.1);
}

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

.conversion-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 600;
}

.conversion-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.conversion-modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.conversion-modal-footer .btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 700;
}

/* Loading Spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Success Screen */
.quiz-success {
    text-align: center;
    padding: 3rem;
}

.quiz-success-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    animation: successPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.quiz-success-icon svg {
    width: 40px;
    height: 40px;
    color: white;
}

@keyframes successPop {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========== ADMIN STYLES ========== */

.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* ========== SIDEBAR DESKTOP ========== */
.admin-sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    padding: 1.5rem;
    flex-shrink: 0;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transition: width 0.3s ease, min-width 0.3s ease, padding 0.3s ease, transform 0.3s ease;
}

/* Spacer to push main content - this is the key! */
.sidebar-spacer {
    width: 280px;
    min-width: 280px;
    flex-shrink: 0;
    transition: width 0.3s ease, min-width 0.3s ease;
}

.sidebar-spacer.collapsed {
    width: 80px;
    min-width: 80px;
}

/* Mobile Header & Expand Button Styles */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    z-index: 1001;
    padding: 0 1rem;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.mobile-menu-btn {
    background: none;
    border: none;
    color: #1e293b !important;
    cursor: pointer;
    padding: 0.5rem;
}

.desktop-expand-btn {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 999;
    width: 44px;
    height: 44px;
    background: #1e293b;
    color: #fff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.2s;
    display: none;
}

.desktop-expand-btn:hover {
    background: #3b82f6;
}

.desktop-expand-btn.visible {
    display: flex;
}

/* ========== SIDEBAR COLLAPSED STATE ========== */
.admin-sidebar.collapsed {
    width: 80px;
    min-width: 80px;
    padding: 1rem 0.5rem;
}

.admin-sidebar.collapsed .admin-nav-item span {
    display: none;
}

.admin-sidebar.collapsed .admin-nav-item {
    justify-content: center;
    padding: 0.875rem;
    width: 100%;
}

.admin-sidebar.collapsed .admin-nav-item svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    margin: 0 auto;
}

.admin-sidebar.collapsed .sidebar-logo {
    display: none;
}

.admin-sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 0.75rem;
    min-height: 60px;
}

.admin-sidebar.collapsed .sidebar-toggle-btn {
    display: flex;
    margin: 0 auto;
    width: 40px;
    height: 40px;
}

.admin-sidebar.collapsed .sidebar-toggle-btn svg {
    transform: rotate(180deg);
}

.admin-sidebar.collapsed .sidebar-nav {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.admin-sidebar-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    color: #475569;
    /* Force Slate 600 for visibility */
    text-decoration: none;
    transition: all 0.2s ease;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.admin-nav-item:hover {
    background: #f1f5f9;
    color: var(--primary);
}

.admin-nav-item.active {
    background: var(--gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(118, 56, 250, 0.2);
    /* Soft purple/blue shadow */
}

.admin-main {
    flex: 1;
    padding: 2rem;
    overflow-x: auto;
    background: var(--bg-body);
    /* #1f2937 */
}

.admin-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-light);
    /* On dark body */
    margin-bottom: 0.5rem;
}

.admin-header.with-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--bg-home);
    /* Night Blue */
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--white);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    /* Stronger shadow on dark bg */
    border: none;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo h1 {
    font-size: 2rem;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-error {
    background: #FEF2F2;
    border: 1px solid #FCA5A5;
    color: #DC2626;
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

/* ========== KANBAN STYLES ========== */

.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    min-height: calc(100vh - 180px);
    align-items: start;
    /* Prevent columns from stretching */
}

@media (max-width: 1200px) {
    .kanban-board {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .kanban-board {
        grid-template-columns: 1fr;
    }
}

.kanban-column {
    background: #f8fafc;
    /* Very light cool gray */
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1rem;
    min-height: auto;
    /* Allow natural height */
}

.kanban-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: 12px;
    font-weight: 600;
    color: var(--text-main);
    background: white;
    /* Header on white card style */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.kanban-column.cold .kanban-column-header {
    border-left: 4px solid #94a3b8;
}

.kanban-column.morno .kanban-column-header {
    border-left: 4px solid var(--info);
}

.kanban-column.quente .kanban-column-header {
    border-left: 4px solid var(--primary);
}

/* Ultra Quente removed from logic but if present: gradient */

.kanban-column-count {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    font-size: 0.75rem;
}

.kanban-cards {
    min-height: 300px;
}

.kanban-card {
    background: var(--white);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: grab;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    /* Ready for accent */
}

/* Accent on hover or active? User said "Branco com detalhes em azul elétrico" */
.kanban-card:hover {
    border-left-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.kanban-card.sortable-ghost {
    opacity: 0.4;
}

.kanban-card.sortable-chosen {
    box-shadow: 0 12px 30px rgba(14, 165, 233, 0.3);
}

.kanban-card-name {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.kanban-card-info {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0 !important;
}

.kanban-card-info span {
    display: block;
    margin-bottom: 0 !important;
}

/* Semantic Status Classes */
.status-box {
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* ... status colors skipped ... */

.kanban-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 0.25rem;
    /* Tight spacing */
}

/* Labels/Badges */
.kanban-tag {
    font-size: 0.8rem;
    padding: 0.3rem 0.75rem;
    border-radius: 99px;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* ... tag colors skipped ... */

/* For legacy or special */

.kanban-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.5rem;
    /* Reduced */
    border-top: 1px solid #E2E8F0;
    margin-top: 0.125rem;
    /* Minimal margin */
}

.kanban-score {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-weight: 600;
    font-size: 1rem;
}

.kanban-score.high {
    color: #059669;
}

.kanban-score.medium {
    color: #D97706;
}

.kanban-score.low {
    color: #DC2626;
}

.kanban-card-link {
    color: var(--leadora-primary);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
}

.kanban-card-link:hover {
    text-decoration: underline;
}

/* ========== LEAD DETAIL STYLES ========== */

.lead-detail-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 1.5rem;
}

@media (max-width: 1200px) {
    .lead-detail-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 900px) {
    .lead-detail-grid {
        grid-template-columns: 1fr;
    }
}

.lead-info-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 12px var(--shadow);
    min-width: 0; /* allow flex/grid children to shrink */
}

.lead-info-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #E2E8F0;
}

.lead-info-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
}

.lead-info-row {
    display: flex;
    flex-wrap: wrap; /* prevent long values from forcing overflow */
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #F1F5F9;
}

.lead-info-label {
    width: 140px;
    font-weight: 500;
    color: var(--text-muted);
    flex-shrink: 0;
}

.lead-info-value {
    flex: 1;
    color: var(--text-main);
    min-width: 0; /* allow content to wrap inside flex row */
    overflow-wrap: anywhere;
    word-break: break-word;
}

.lead-ai-card {
    background: linear-gradient(135deg, #F0F9FF 0%, #E0F2FE 100%);
    border: 1px solid #BAE6FD;
    min-width: 280px;
    overflow: visible;
    min-width: 0; /* avoid overflow when used in flex layouts */
}

#lastMessageBody {
    overflow-wrap: anywhere; /* break long URLs */
    word-break: break-word;
}

#rawAiResponse {
    white-space: pre-wrap; /* wrap long lines while keeping formatting */
    overflow-x: auto; /* keep horizontal scroll if needed */
    overflow-wrap: anywhere;
}

.lead-score-circle {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.lead-score-value {
    font-size: 2rem;
    font-weight: 700;
    color: white;
}

.lead-urgency-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.875rem;
}

.lead-urgency-badge.alta {
    background: #FEE2E2;
    color: #B91C1C;
}

.lead-urgency-badge.média {
    background: #FEF3C7;
    color: #B45309;
}

.lead-urgency-badge.baixa {
    background: #DCFCE7;
    color: #166534;
}

/* ========== QUIZ QUESTIONS EDITOR ========== */

.questions-list {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 12px var(--shadow);
    overflow: hidden;
}

.question-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #E2E8F0;
    cursor: grab;
    transition: background 0.2s ease;
}

.question-item:hover {
    background: #F8FAFC;
}

.question-item.sortable-ghost {
    opacity: 0.4;
}

.question-drag-handle {
    color: #94A3B8;
    cursor: grab;
}

.question-info {
    flex: 1;
}

.question-label {
    font-weight: 500;
    color: var(--leadora-deep);
}

.question-meta {
    font-size: 0.8125rem;
    color: #64748B;
    margin-top: 0.25rem;
}

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

.question-btn {
    padding: 0.5rem;
    border: none;
    background: transparent;
    color: #64748B;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.question-btn:hover {
    background: #F1F5F9;
    color: var(--leadora-primary);
}

.question-btn.delete:hover {
    background: #FEE2E2;
    color: #DC2626;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.modal {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

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

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

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: #F1F5F9;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.modal-close:hover {
    background: #E2E8F0;
}

.form-group {
    margin-bottom: 1.25rem;
}

/* Utilities */
.text-center {
    text-align: center;
}

.mt-1 {
    margin-top: 0.25rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

.mt-6 {
    margin-top: 1.5rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

/* Responsive adjustments */
/* Mobile Media Queries - ROBUST */
@media (max-width: 1024px) {
    .mobile-header {
        display: flex !important;
        background: white !important;
        border-bottom: 1px solid #e2e8f0;
        z-index: 2000;
        height: 60px;
        position: fixed;
        width: 100%;
        top: 0;
    }

    /* Hide spacer on mobile */
    .sidebar-spacer {
        display: none !important;
    }

    .admin-sidebar {
        display: flex;
        flex-direction: column;
        transform: translateX(-100%);
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 3000;
        height: 100% !important;
        background: white !important;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
        width: 280px !important;
        min-width: 280px !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding-top: 1rem;
    }

    .admin-sidebar.visible {
        transform: translateX(0);
    }

    .sidebar-overlay {
        z-index: 2500;
    }

    .admin-main {
        padding-top: 80px !important;
        margin-left: 0 !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .kanban-board {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .desktop-expand-btn {
        display: none !important;
    }

    .lead-detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .admin-main {
        padding: 1rem;
        padding-top: 70px;
    }

    .kanban-column {
        min-height: auto;
    }
}

/* ========================================
   WhatsApp Chat Modal
   ======================================== */

.wa-chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
}

.wa-chat-modal {
    background: #fff;
    border-radius: 20px;
    width: 100%;
    max-width: 580px; 
    height: 750px; 
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-color);
}

.wa-chat-header {
    background: white;
    color: var(--text-main);
    padding: 2.25rem 1.5rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    flex-shrink: 0;
    text-align: center;
}

.wa-chat-header-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.wa-chat-header-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.wa-chat-ai-toggle {
    background: #f0fdf4;
    border: 1px solid #10b981;
    color: #10b981;
    padding: 0.5rem 0.875rem;
    border-radius: 99px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.wa-chat-ai-toggle:hover {
    background: #dcfce7;
}

.wa-chat-ai-toggle:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.wa-chat-ai-toggle.ai-mode {
    background: #f0fdf4;
}

.wa-chat-ai-toggle.human-mode {
    background: #fff7ed;
    border-color: #f59e0b;
    color: #f59e0b;
}

.wa-chat-ai-toggle.human-mode:hover {
    background: #ffedd5;
}

.wa-chat-notification {
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    font-size: 0.8125rem;
    text-align: center;
    margin: 0.5rem auto;
    max-width: fit-content;
    animation: fadeInUp 0.3s ease;
}

.wa-chat-notification.error {
    background: rgba(239, 68, 68, 0.9);
}

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

.wa-chat-avatar {
    width: 44px;
    height: 44px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.wa-chat-name {
    font-weight: 800;
    font-size: 1.125rem;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.wa-chat-phone {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 500;
}

.wa-chat-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.wa-chat-close:hover {
    background: #fee2e2;
    color: #ef4444;
    border-color: #fecaca;
}

.wa-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: #f8fafc;
    background-image: radial-gradient(#e2e8f0 1px, transparent 1px);
    background-size: 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.wa-chat-loading,
.wa-chat-empty,
.wa-chat-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #667781;
    text-align: center;
    gap: 0.5rem;
}

.wa-chat-empty-icon {
    font-size: 3rem;
    opacity: 0.5;
}

.wa-chat-empty-hint {
    font-size: 0.8125rem;
    opacity: 0.7;
}

.wa-chat-retry {
    margin-top: 0.5rem;
    padding: 0.5rem 1rem;
    background: #25D366;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.wa-chat-bubble {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 16px;
    position: relative;
    word-wrap: break-word;
    box-shadow: var(--shadow-sm);
}

.wa-chat-bubble.incoming {
    background: white;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

.wa-chat-bubble.outgoing {
    background: #e0f2fe;
    color: #075985;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    border: 1px solid #bae6fd;
}

.wa-chat-bubble.sending {
    opacity: 0.7;
}

.wa-chat-bubble.failed {
    background: #fee2e2;
    cursor: pointer;
}

.wa-msg-copy-btn {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.75rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.wa-msg-copy-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.2);
}

.wa-chat-bubble-text {
    font-size: 1.05rem;
    color: #111b21;
    line-height: 1.5;
    white-space: pre-wrap;
}

.wa-chat-bubble-time {
    font-size: 0.8rem;
    color: #667781;
    text-align: right;
    margin-top: 0.35rem;
}

.wa-chat-input-area {
    padding: 1.25rem;
    background: white;
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
}

.wa-chat-input-area input {
    flex: 1;
    padding: 0.875rem 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 1.05rem;
    outline: none;
    background: #f8fafc;
    transition: all 0.2s;
}

.wa-chat-input-area input:focus {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(3, 112, 254, 0.1);
}

/* Temperature Picker Dropdown */
.temp-picker-menu {
    position: fixed;
    z-index: 11000;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    min-width: 140px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: fadeInScale 0.2s ease;
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.temp-picker-item {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    border: 1px solid transparent;
}

.temp-picker-item.q-frio { background: #eff6ff; color: #3b82f6; border-color: #dbeafe; }
.temp-picker-item.q-frio:hover { background: #dbeafe; transform: translateX(4px); }

.temp-picker-item.q-morno { background: #fffbeb; color: #f59e0b; border-color: #fef3c7; }
.temp-picker-item.q-morno:hover { background: #fef3c7; transform: translateX(4px); }

.temp-picker-item.q-quente { background: #fef2f2; color: #ef4444; border-color: #fee2e2; }
.temp-picker-item.q-quente:hover { background: #fee2e2; transform: translateX(4px); }

.wa-chat-send {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.wa-chat-send:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(3, 112, 254, 0.3);
}

.wa-chat-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Chat button style for cards */
.btn-chat {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #25D366;
    color: white;
    border-radius: 50%;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-chat:hover {
    background: #128C7E;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}

@media (max-width: 480px) {
    .wa-chat-modal {
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    
    .wa-chat-overlay {
        padding: 0;
    }
}
