:root {
  --bg-dark: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-sidebar: rgba(15, 23, 42, 0.85);

  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --secondary: #3b82f6;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  --border-light: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

  --urgency-high: #ef4444;
  --urgency-high-bg: rgba(239, 68, 68, 0.15);

  --urgency-medium: #f59e0b;
  --urgency-medium-bg: rgba(245, 158, 11, 0.15);

  --urgency-low: #10b981;
  --urgency-low-bg: rgba(16, 185, 129, 0.15);

  --font-family: 'Outfit', sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Dynamic Background Blobs */
.blob-bg {
  position: absolute;
  filter: blur(100px);
  z-index: -1;
  opacity: 0.5;
  border-radius: 50%;
  animation: float 20s infinite ease-in-out alternate;
}

.blob-1 {
  width: 400px;
  height: 400px;
  background: var(--primary);
  top: -100px;
  left: -100px;
}

.blob-2 {
  width: 500px;
  height: 500px;
  background: var(--secondary);
  bottom: -150px;
  right: -100px;
  animation-delay: -5s;
}

.blob-3 {
  width: 300px;
  height: 300px;
  background: #ec4899;
  top: 40%;
  left: 30%;
  animation-delay: -10s;
  opacity: 0.3;
}

@keyframes float {
  0% {
    transform: translate(0, 0) scale(1);
  }

  100% {
    transform: translate(50px, 50px) scale(1.1);
  }
}

/* Layout */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  padding: 2rem 1.5rem;
  z-index: 10;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 3rem;
}

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.logo-text {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-radius: 12px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  transform: translateX(5px);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.2), transparent);
  color: var(--text-main);
  border-left: 3px solid var(--primary);
}

.nav-item ion-icon {
  font-size: 1.25rem;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-light);
}

.avatar img {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  border: 2px solid var(--primary);
}

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

.user-name {
  font-weight: 600;
  font-size: 1rem;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 2rem 3rem;
  overflow-y: auto;
  z-index: 10;
}

/* Header */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 2.5rem;
}

.header-titles h2 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

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

.header-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.search-bar {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  width: 300px;
  transition: border-color 0.3s ease;
}

.search-bar:focus-within {
  border-color: var(--primary);
}

.search-bar ion-icon {
  color: var(--text-muted);
  font-size: 1.2rem;
  margin-right: 0.5rem;
}

.search-bar input {
  background: transparent;
  border: none;
  color: var(--text-main);
  outline: none;
  width: 100%;
  font-family: inherit;
  font-size: 0.9rem;
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: 12px;
  font-family: inherit;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

/* Kanban Board */
.kanban-board {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  height: calc(100vh - 160px);
  overflow-x: auto;
  padding-bottom: 1rem;
}

.kanban-board::-webkit-scrollbar {
  height: 8px;
}

.kanban-board::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.kanban-board::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.kanban-column {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  width: 350px;
  min-width: 350px;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.column-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.column-title {
  font-weight: 600;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot-new {
  background: var(--secondary);
}

.dot-pending {
  background: var(--urgency-medium);
}

.dot-contact {
  background: var(--primary);
}

.dot-won {
  background: var(--urgency-low);
}

.column-count {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.column-content {
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

.column-content::-webkit-scrollbar {
  width: 6px;
}

.column-content::-webkit-scrollbar-track {
  background: transparent;
}

.column-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

/* Chat Card (Lead Item) */
.lead-card {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 1.25rem;
  cursor: grab;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.lead-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--secondary);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.lead-card:hover {
  transform: translateY(-2px);
  background: rgba(15, 23, 42, 0.8);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.lead-card:hover::before {
  opacity: 1;
}

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

.lead-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.lead-avatar {
  background: linear-gradient(135deg, #1e293b, #334155);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
  border: 1px solid var(--border-light);
}

.lead-username {
  font-weight: 600;
  font-size: 0.95rem;
}

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

.lead-ig-icon {
  color: #ec4899;
  font-size: 1.2rem;
}

.card-body {
  margin-bottom: 1rem;
}

.lead-message {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ai-analysis {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 0.75rem;
  border: 1px solid rgba(139, 92, 246, 0.2);
}

.ai-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.ai-data-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.ai-data-row ion-icon {
  color: var(--text-muted);
  font-size: 1rem;
}

.badge {
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  display: inline-block;
}

/* Urgency Badges */
.badge-urgency-alta {
  background: var(--urgency-high-bg);
  color: var(--urgency-high);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-urgency-media {
  background: var(--urgency-medium-bg);
  color: var(--urgency-medium);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-urgency-baja {
  background: var(--urgency-low-bg);
  color: var(--urgency-low);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Location Badges */
.badge-location {
  background: rgba(59, 130, 246, 0.15);
  color: var(--secondary);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-pending {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
  border: 1px dashed rgba(148, 163, 184, 0.5);
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-light);
  padding-top: 0.75rem;
  margin-top: 0.5rem;
}

.interest-tag {
  font-size: 0.75rem;
  color: white;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.3rem 0.6rem;
  border-radius: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

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

.action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-btn:hover {
  color: var(--text-main);
}

.btn-whatsapp:hover {
  color: #25D366;
}

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

/* Model Badges */
.badge-age {
  background: rgba(236, 72, 153, 0.15);
  color: #ec4899;
  border: 1px solid rgba(236, 72, 153, 0.3);
}

.badge-height {
  background: rgba(139, 92, 246, 0.15);
  color: var(--primary);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.badge-complete {
  background: var(--urgency-low-bg);
  color: var(--urgency-low);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-incomplete {
  background: rgba(245, 158, 11, 0.15);
  color: var(--urgency-medium);
  border: 1px dashed rgba(245, 158, 11, 0.5);
}

/* Country Tabs */
.country-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 1rem;
  overflow-x: auto;
}

.country-tabs::-webkit-scrollbar {
  height: 4px;
}

.tab-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.tab-btn.active {
  background: var(--primary);
  color: white;
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

/* ========================================= */
/*               MESSAGE MODAL               */
/* ========================================= */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  width: 90%;
  max-width: 500px;
  overflow: hidden;
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.5);
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

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

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 600;
}

.highlight-text {
  color: var(--primary);
}

.close-modal-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.close-modal-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.modal-body {
  padding: 1.5rem;
}

.modal-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
}

.quick-templates {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.template-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  border-radius: 20px;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.template-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

textarea#modal-message-text {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-light);
  color: white;
  border-radius: 12px;
  padding: 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
}

textarea#modal-message-text:focus {
  border-color: var(--primary);
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

.secondary-btn {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border-light);
  padding: 0.8rem 1.5rem;
  border-radius: 12px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.dot-error {
  background: var(--urgency-high);
}


/* ========================================= */
/*       RESPONSIVE DESIGN (MOBILE)          */
/* ========================================= */

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }

  /* Transform Sidebar into Bottom Navigation Bar */
  .sidebar {
    width: 100%;
    height: 70px;
    flex-direction: row;
    padding: 0 1rem;
    align-items: center;
    border-right: none;
    border-top: 1px solid var(--border-light);
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 100;
  }

  .logo-container,
  .user-profile {
    display: none;
    /* Hide heavy elements in mobile nav */
  }

  .sidebar-nav {
    flex-direction: row;
    width: 100%;
    justify-content: space-around;
    gap: 0;
  }

  .nav-item {
    flex-direction: column;
    padding: 0.5rem;
    gap: 0.2rem;
    flex: 1;
    justify-content: center;
  }

  .nav-item span {
    font-size: 0.65rem;
  }

  .nav-item.active {
    border-left: none;
    border-bottom: 3px solid var(--primary);
    background: linear-gradient(0deg, rgba(139, 92, 246, 0.2), transparent);
  }

  /* Main Content Adjustments */
  .main-content {
    padding: 1.5rem 1rem calc(70px + 1.5rem);
    /* Extra padding for bottom nav */
  }

  .top-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    margin-bottom: 1rem;
  }

  .header-titles h2 {
    font-size: 1.5rem;
  }

  .header-actions {
    flex-direction: column;
    width: 100%;
    gap: 0.8rem;
  }

  .search-bar {
    width: 100%;
  }

  .primary-btn {
    width: 100%;
    justify-content: center;
  }

  /* Mobile Kanban specific adaptations */
  .kanban-board {
    height: calc(100vh - 350px);
    scroll-snap-type: x mandatory;
    gap: 1rem;
    padding-bottom: 0;
  }

  .kanban-column {
    min-width: 85vw;
    width: 85vw;
    scroll-snap-align: center;
  }
}