:root {
    --primary: #2563eb;
    --primary-foreground: #ffffff;
    --secondary: #f8fafc;
    --muted: #f1f5f9;
    --muted-foreground: #64748b;
    --accent: #e2e8f0;
    --border: #e2e8f0;
    --input: #f1f5f9;
    --radius: 0.75rem;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

[data-theme="dark"] {
    --primary: #3b82f6;
    --secondary: #0f172a;
    --muted: #1e293b;
    --muted-foreground: #94a3b8;
    --accent: #334155;
    --border: #334155;
    --input: #1e293b;
    color: #f8fafc;
    background: #020617;
}

* { box-sizing: border-box; font-family: 'Inter', sans-serif; transition: background 0.2s, border 0.2s; }
body { margin: 0; background: hsl(var(--secondary)); color: inherit; }

.app-container { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 2rem; background: white; border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); z-index: 10;
}
[data-theme="dark"] header { background: #0f172a; border-color: #1e293b; }

.logo { display: flex; align-items: center; gap: 0.75rem; font-weight: 800; font-size: 1.5rem; color: var(--primary); letter-spacing: -0.025em; }
.logo-icon { width: 36px; height: 36px; background: var(--primary); color: white; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; margin-right: 0.25rem; }
.header-actions { display: flex; gap: 1rem; align-items: center; }

.kanban-board {
    display: flex; gap: 1.5rem; padding: 2rem; overflow-x: auto; flex: 1;
    background: var(--muted); align-items: flex-start;
}
[data-theme="dark"] .kanban-board { background: #020617; }

.column {
    min-width: 320px; max-width: 320px; background: #ebedf0; border-radius: 1rem;
    display: flex; flex-direction: column; max-height: 100%; border: 1px solid transparent;
}
[data-theme="dark"] .column { background: #0f172a; border-color: #1e293b; }

.column-header { padding: 1.25rem; display: flex; justify-content: space-between; align-items: center; }
.column-title { margin: 0; font-size: 0.95rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted-foreground); }

.badge-cold { background: var(--accent); padding: 0.2rem 0.6rem; border-radius: 2rem; font-size: 0.8rem; font-weight: 600; }

.leads-list {
    padding: 0.75rem; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 0.75rem;
    min-height: 100px; /* Essential for SortableJS */
}

.lead-card {
    background: white; padding: 1.25rem; border-radius: var(--radius); cursor: pointer;
    box-shadow: var(--shadow); border: 1px solid transparent;
}
[data-theme="dark"] .lead-card { background: #1e293b; border-color: #334155; }
.lead-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1); }

.lead-name { font-weight: 700; font-size: 1rem; margin-bottom: 0.25rem; color: var(--primary); }
.lead-phone { font-size: 0.85rem; color: var(--muted-foreground); font-weight: 500; }

/* Modal & Chat */
.chat-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(4px); }
.chat-panel { background: white; border-radius: 1.5rem; display: flex; flex-direction: column; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); border: 1px solid var(--border); overflow: hidden; }
[data-theme="dark"] .chat-panel { background: #0f172a; border-color: #1e293b; }

.chat-header { padding: 1.5rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.chat-messages { flex: 1; padding: 1.5rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; max-height: 400px; min-height: 300px; width: 500px; }
.message { padding: 0.75rem 1rem; border-radius: 1rem; max-width: 80%; font-size: 0.95rem; line-height: 1.5; }
.message.received { background: var(--muted); align-self: flex-start; border-bottom-left-radius: 0.25rem; }
.message.sent { background: var(--primary); color: white; align-self: flex-end; border-bottom-right-radius: 0.25rem; }

.chat-input-area { padding: 1.5rem; border-top: 1px solid var(--border); display: flex; gap: 1rem; }
.chat-input { flex: 1; background: var(--input); border: 1px solid var(--border); padding: 0.75rem 1rem; border-radius: var(--radius); outline: none; color: inherit; }
.chat-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1); }

.btn-primary { background: var(--primary); color: white; border: none; padding: 0.6rem 1.2rem; border-radius: var(--radius); cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.btn-ghost { background: none; border: none; padding: 0.5rem; border-radius: var(--radius); cursor: pointer; color: var(--muted-foreground); }
.btn-ghost:hover { background: var(--muted); color: var(--primary); }

.select-company { background: var(--muted); border: 1px solid var(--border); padding: 0.4rem 1rem; border-radius: var(--radius); font-weight: 600; color: inherit; }

.btn-delete-lead { opacity: 0; background: none; border: none; color: #ef4444; cursor: pointer; padding: 4px; border-radius: 4px; transition: opacity 0.2s; }
.lead-card:hover .btn-delete-lead { opacity: 1; }
.btn-delete-lead:hover { background: #fee2e2; }

/* Tabs */
.tab { padding: 0.5rem 1rem; border: none; background: none; cursor: pointer; color: var(--muted-foreground); font-weight: 600; border-bottom: 2px solid transparent; }
.tab-active { color: var(--primary); border-bottom-color: var(--primary); }

.webhook-box { background: var(--muted); padding: 1rem; border-radius: var(--radius); border: 1px dashed var(--primary); font-size: 0.8rem; }
.webhook-box code { color: var(--primary); font-weight: 700; word-break: break-all; }

.cols-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1rem; }
.col-item-settings { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem; background: var(--muted); border-radius: 0.5rem; font-weight: 600; }

/* Modo Tela Cheia Ultra Potente */
body .chat-overlay .chat-panel.chat-full {
    position: fixed !important;
    top: 2vh !important;
    left: 2vw !important;
    width: 96vw !important;
    height: 96vh !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    z-index: 9999 !important;
}

body .chat-overlay .chat-panel.chat-full .chat-messages {
    width: 100% !important;
    max-height: none !important;
    height: auto !important;
    flex: 1 !important;
}

body .chat-overlay .chat-panel.chat-full .message {
    max-width: 70% !important;
}

/* Zoom da Imagem (Lightbox) */
.zoom-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: zoom-out;
    backdrop-filter: blur(10px);
}
.zoom-overlay img {
    max-height: 95vh;
    max-width: 95vw;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.8);
    transition: transform 0.3s ease;
}
.zoom-overlay:hover img {
    transform: scale(1.02);
}
.btn-close-zoom {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background: rgba(255,255,255,0.1);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-close-zoom:hover { background: rgba(255,255,255,0.2); }

/* Player de Áudio Estilo WhatsApp */
.wa-audio-player {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0,0,0,0.05);
    padding: 10px 15px;
    border-radius: 12px;
    min-width: 240px;
    margin-top: 5px;
}
[data-theme="dark"] .wa-audio-player { background: rgba(255,255,255,0.1); }

.wa-audio-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #ccc;
    position: relative;
    overflow: hidden;
}
.wa-audio-avatar img { width: 100%; height: 100%; object-fit: cover; }
.wa-audio-mic-icon {
    position: absolute;
    bottom: 0;
    right: 0;
    background: #53bdeb;
    color: white;
    border-radius: 50%;
    padding: 2px;
    font-size: 8px;
}

.wa-audio-controls {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wa-audio-play-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--primary);
    padding: 0;
    display: flex;
    align-items: center;
}

.wa-audio-wave {
    height: 20px;
    display: flex;
    align-items: center;
    gap: 2px;
}
.wa-audio-bar {
    width: 2px;
    height: 100%;
    background: #adb5bd;
    border-radius: 1px;
}
.wa-audio-bar.active { background: var(--primary); }

.wa-audio-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    opacity: 0.7;
}
.message.sent .wa-audio-play-btn { color: white !important; }
.message.sent .wa-audio-bar.active { background: white !important; }
.message.sent .wa-audio-bar { background: rgba(255,255,255,0.3); }
.message.sent .wa-audio-info { color: white; }

.message-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.65rem;
    color: #94a3b8;
    margin-top: 4px;
    opacity: 0.7;
}

.message.sent .message-footer { color: white; }

.btn-delete-msg {
    background: none;
    border: none;
    padding: 2px;
    color: inherit;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
}

.message:hover .btn-delete-msg {
    opacity: 0.6;
}

.btn-delete-msg:hover {
    opacity: 1 !important;
    color: #ef4444 !important;
}
