/* Custom Premium CSS: Glassmorphic Dark Design System */

:root {
  --bg-gradient: linear-gradient(135deg, #f0fdfa 0%, #f7fee7 50%, #f0fdfa 100%);
  --panel-bg: rgba(255, 255, 255, 0.65);
  --panel-bg-hover: rgba(255, 255, 255, 0.85);
  --panel-bg-active: rgba(255, 255, 255, 0.95);
  --panel-border: rgba(13, 148, 136, 0.09);
  --panel-border-focus: rgba(13, 148, 136, 0.35);
  
  --primary: #0d9488; /* Teal / Verde Aqua */
  --primary-hover: #0f766e;
  --secondary: #14b8a6; /* Minty Teal */
  --accent: #2dd4bf; /* Aqua Light */
  
  --text-main: #0f172a; /* Slate 900 */
  --text-muted: #334155; /* Slate 700 */
  --text-disabled: #94a3b8; /* Slate 400 */
  
  --status-online: #10b981;
  --status-offline: #94a3b8;
  --status-alert: #f59e0b;
  
  --chat-lead-bg: #f1f5f9; /* Soft grey/blue */
  --chat-bot-bg: linear-gradient(135deg, rgba(20, 184, 166, 0.08) 0%, rgba(45, 212, 191, 0.08) 100%);
  --chat-agent-bg: linear-gradient(135deg, rgba(20, 184, 166, 0.18) 0%, rgba(13, 148, 136, 0.18) 100%);
  
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --blur-radius: 20px;
}

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

body {
  font-family: var(--font-family);
  background: var(--bg-gradient);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

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

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.12);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 23, 42, 0.25);
}

/* Sidebar */
.sidebar {
  width: 360px;
  background: var(--panel-bg);
  backdrop-filter: blur(var(--blur-radius));
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
  transition: var(--transition-smooth);
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--panel-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.35);
}
.brand-logo svg {
  stroke: #ffffff;
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.status-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--status-online);
  border-radius: 50%;
  display: inline-block;
  animation: pulse 1.8s infinite ease-in-out;
}

@keyframes pulse {
  0% { transform: scale(0.85); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.85); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Navigation tabs in Sidebar */
.view-tabs {
  display: flex;
  gap: 6px;
  margin-top: 20px;
  background: rgba(15, 23, 42, 0.02);
  border: 1px solid var(--panel-border);
  padding: 4px;
  border-radius: 10px;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-smooth);
  font-family: var(--font-family);
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(15, 23, 42, 0.02);
}

.tab-btn.active {
  background: rgba(13, 148, 136, 0.12);
  color: var(--text-main);
  border: 1px solid rgba(13, 148, 136, 0.2);
}

/* Search Box */
.search-box {
  padding: 16px 24px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 36px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 12px 16px 12px 40px;
  background: rgba(15, 23, 42, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-smooth);
}

.search-box input:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.15);
}

/* Leads List */
.leads-list {
  flex-grow: 1;
  overflow-y: auto;
  padding: 0 16px 16px 16px;
}

.empty-state {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.lead-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.lead-card:hover {
  background: var(--panel-bg-hover);
  border-color: var(--panel-border);
}

.lead-card.active {
  background: var(--panel-bg-active);
  border-color: rgba(13, 148, 136, 0.2);
  box-shadow: inset 0 0 12px rgba(13, 148, 136, 0.05), 0 4px 12px rgba(15, 23, 42, 0.03);
}

.lead-card .avatar {
  width: 44px;
  height: 44px;
  background: rgba(13, 148, 136, 0.08);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--primary);
  border: 1px solid var(--panel-border);
  flex-shrink: 0;
}

.lead-card.active .avatar {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #ffffff;
  border-color: transparent;
}

.lead-card-info {
  flex-grow: 1;
  min-width: 0;
}

.lead-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.lead-card-top h4 {
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.lead-card-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.lead-card-msg {
  font-size: 0.825rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lead-badges {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.badge-bot {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 600;
}

.badge-bot.active {
  background: rgba(13, 148, 136, 0.12);
  color: #0d9488;
  border: 1px solid rgba(13, 148, 136, 0.2);
}

.badge-bot.paused {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Chat Area */
.chat-area {
  flex-grow: 1;
  background: radial-gradient(circle at top right, rgba(13, 148, 136, 0.05) 0%, transparent 60%);
  display: flex;
  flex-direction: column;
  position: relative;
}

.chat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-grow: 1;
  padding: 48px;
  text-align: center;
}

.empty-icon {
  width: 96px;
  height: 96px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  margin-bottom: 24px;
}

.chat-empty-state h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.chat-empty-state p {
  color: var(--text-muted);
  max-width: 420px;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Chat Header */
.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 81px;
}

.chat-active-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-active-info .avatar {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #ffffff;
  font-weight: 600;
  font-size: 1.1rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-active-info h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.phone-number {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bot-badge {
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 600;
}

.bot-badge.active {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.bot-badge.paused {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Chat Messages */
.chat-messages {
  flex-grow: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.msg-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 70%;
}

.msg-wrapper.lead {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-wrapper.bot, .msg-wrapper.agent {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-bubble {
  padding: 12px 18px;
  border-radius: 20px;
  font-size: 0.95rem;
  line-height: 1.45;
  position: relative;
  word-break: break-word;
}

.msg-wrapper.lead .msg-bubble {
  background: var(--chat-lead-bg);
  color: var(--text-main);
  border: 1px solid var(--panel-border);
  border-bottom-left-radius: 4px;
}

.msg-wrapper.bot .msg-bubble {
  background: var(--chat-bot-bg);
  color: var(--text-main);
  border: 1px solid rgba(13, 148, 136, 0.15);
  border-bottom-right-radius: 4px;
}

.msg-wrapper.agent .msg-bubble {
  background: var(--chat-agent-bg);
  color: var(--text-main);
  border: 1px solid rgba(13, 148, 136, 0.25);
  border-bottom-right-radius: 4px;
}

.msg-meta {
  font-size: 0.725rem;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.msg-sender-tag {
  font-size: 0.65rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 1px 4px;
  border-radius: 4px;
}

.msg-wrapper.bot .msg-sender-tag {
  background: rgba(13, 148, 136, 0.12);
  color: #0d9488;
}

.msg-wrapper.agent .msg-sender-tag {
  background: rgba(13, 148, 136, 0.2);
  color: #0f766e;
}

/* Chat Input Area */
.chat-input-area {
  padding: 20px 24px;
  border-top: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.005);
}

.message-form {
  display: flex;
  gap: 12px;
}

.message-form input {
  flex-grow: 1;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition-smooth);
}

.message-form input:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.15);
}

.btn-send {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
}

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

/* Details Panel */
.details-panel {
  width: 320px;
  background: var(--panel-bg);
  backdrop-filter: blur(var(--blur-radius));
  border-left: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
}

.details-header {
  padding: 24px;
  border-bottom: 1px solid var(--panel-border);
  height: 81px;
  display: flex;
  align-items: center;
}

.details-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.details-content {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
  flex-grow: 1;
}

.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.5rem;
  margin-bottom: 12px;
  color: #ffffff;
}

.profile-card h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.section-divider {
  height: 1px;
  background: var(--panel-border);
}

.control-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  background: rgba(15, 23, 42, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
}

.control-text h5 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.control-text p {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Switch styling */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  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: rgba(15, 23, 42, 0.08);
  transition: .4s;
  border: 1px solid var(--panel-border);
}

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

input:checked + .slider {
  background-color: var(--status-online);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--status-online);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

.info-guide h5 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.info-guide ul {
  list-style: none;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
  line-height: 1.4;
}

/* KANBAN BOARD VIEW STYLES */
.kanban-area {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  padding: 32px;
  height: 100vh;
  overflow: hidden;
  background: radial-gradient(circle at top right, rgba(13, 148, 136, 0.03) 0%, transparent 60%);
}

.kanban-header {
  margin-bottom: 24px;
  flex-shrink: 0;
}

.kanban-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.kanban-header p {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.kanban-board {
  display: flex;
  gap: 16px;
  flex-grow: 1;
  height: 0; /* Important: constraints height to fill remaining viewport, enabling internal column scroll */
  min-height: 0;
  overflow-x: auto;
  align-items: stretch; /* Notion style: Columns stretch to the full height */
  padding-bottom: 16px;
}

.kanban-column {
  flex: 1;
  min-width: 270px;
  max-width: 320px;
  height: 100%; /* Columns are full height */
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  backdrop-filter: blur(var(--blur-radius));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: var(--transition-smooth);
}

.kanban-column.drag-over {
  border-color: var(--primary);
  background: rgba(13, 148, 136, 0.04);
  box-shadow: 0 0 16px rgba(13, 148, 136, 0.1);
}

.kanban-column-header {
  padding: 16px 14px;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.005);
  flex-shrink: 0; /* Keep header static */
}

.kanban-column-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kanban-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.kanban-dot.contato_inicial { background-color: var(--primary); }
.kanban-dot.qualificacao { background-color: var(--secondary); }
.kanban-dot.agendamento { background-color: var(--accent); }
.kanban-dot.negocio_fechado { background-color: var(--status-online); }

.kanban-column-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.column-count {
  font-size: 0.75rem;
  padding: 1px 6px;
  background: rgba(15, 23, 42, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text-muted);
}

.kanban-column-cards {
  padding: 12px 10px;
  flex-grow: 1;
  overflow-y: auto; /* Enable vertical scroll inside each column like Notion */
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 50px;
}

.kanban-card {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 14px;
  cursor: grab;
  transition: var(--transition-smooth);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.02);
}

.kanban-card:hover {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(13, 148, 136, 0.2);
  transform: translateY(-2.5px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.kanban-card:active {
  cursor: grabbing;
}

.kanban-card.dragging {
  opacity: 0.35;
  border-style: dashed;
  border-color: var(--primary);
  background: rgba(13, 148, 136, 0.02);
}

.kanban-card h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kanban-card-phone {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: block;
}

.kanban-card-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.kanban-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.btn-kanban-chat {
  background: rgba(15, 23, 42, 0.03);
  color: var(--text-main);
  border: 1px solid var(--panel-border);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-family);
  transition: var(--transition-smooth);
}

.btn-kanban-chat:hover {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.35);
}

/* Back button on mobile */
.btn-back {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  padding: 4px;
  margin-right: 8px;
  transition: var(--transition-smooth);
}

.btn-back:hover {
  color: var(--primary);
}

/* Helper classes */
.hidden {
  display: none !important;
}

/* Responsive design */
@media (max-width: 1024px) {
  .details-panel {
    display: none; /* Hide details on small screens or make toggleable */
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
  }
  
  .chat-area, .kanban-area {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    z-index: 20;
    background: var(--bg-gradient);
  }
  
  /* When chat is active on mobile, show it and show back button */
  .app-container.chat-active .chat-area {
    display: flex;
  }
  .app-container.chat-active .sidebar {
    transform: translateX(-100%);
  }
  .app-container.chat-active .btn-back {
    display: block;
  }
}
