/* ==========================================================================
   WHATSAPP MARKETING DASHBOARD - SHADCN UI/UX LIGHT MODE THEME DESIGN SYSTEM
   ========================================================================== */

:root {
  /* Shadcn Slate/Zinc Light Mode Color Tokens */
  --background: #ffffff;      /* white background */
  --foreground: #09090b;      /* zinc-950 text */
  --card: #ffffff;            /* white cards */
  --card-foreground: #09090b;
  --popover: #ffffff;
  --popover-foreground: #09090b;
  
  --primary: #09090b;         /* High contrast black button bg */
  --primary-foreground: #fafafa;
  
  --secondary: #f4f4f5;       /* zinc-100 button/badge bg */
  --secondary-foreground: #09090b;
  
  --muted: #f4f4f5;           /* zinc-100 */
  --muted-foreground: #71717a;/* zinc-500 text color */
  
  --accent: #f4f4f5;          /* zinc-100 active/hover */
  --accent-foreground: #09090b;
  
  --destructive: #ef4444;     /* red-500 */
  --destructive-foreground: #fafafa;
  
  --border: #e4e4e7;          /* zinc-200 border color */
  --input: #e4e4e7;
  --ring: #71717a;            /* zinc-500 */
  
  --radius: 0.5rem;           /* 8px rounded corners */
  
  /* Priority Accents */
  --urgent: #f43f5e;          /* rose-500 */
  --success: #10b981;         /* emerald-500 */
  --warning: #f59e0b;         /* amber-500 */
  --info: #3b82f6;            /* blue-500 */

  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', SFMono-Regular, Consolas, monospace;
}

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

body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* App Layout Grid */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* --------------------------------------------------------------------------
   SHADCN SIDEBAR NAVIGATION
   -------------------------------------------------------------------------- */
.sidebar {
  width: 260px;
  background-color: var(--background);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.5rem 1.5rem 0.5rem;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background-color: var(--foreground);
  color: var(--background);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
}

.brand-text h2 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand-text span {
  font-size: 10px;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-close-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--muted-foreground);
  cursor: pointer;
  font-size: 16px;
  position: absolute;
  right: 0.5rem;
  top: 0.25rem;
}

.nav-menu {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: var(--muted-foreground);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  width: 100%;
}

.nav-item:hover {
  background-color: var(--accent);
  color: var(--accent-foreground);
}

.nav-item.active {
  background-color: var(--accent);
  color: var(--accent-foreground);
  font-weight: 600;
}

.nav-item i {
  font-size: 14px;
  color: var(--muted-foreground);
}

.nav-item.active i {
  color: var(--foreground);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.4rem;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  border-radius: 9999px;
}

.badge-urgent {
  background-color: rgba(244, 63, 94, 0.1);
  color: var(--urgent);
}

.badge-success {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.connection-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: var(--radius);
  background-color: var(--card);
  border: 1px solid var(--border);
}

.status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--muted-foreground);
}

.status-indicator.online {
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.connection-info .title {
  display: block;
  font-size: 11px;
  font-weight: 600;
}

.connection-info .sub {
  display: block;
  font-size: 9px;
  color: var(--muted-foreground);
}

/* --------------------------------------------------------------------------
   MAIN CONTAINER & TOP BAR
   -------------------------------------------------------------------------- */
.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  transition: margin-left 0.3s ease;
}

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

.mobile-menu-toggle {
  display: none;
  font-size: 16px;
  padding: 0.5rem;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.75rem;
  width: 320px;
}

.search-bar i {
  color: var(--muted-foreground);
  font-size: 13px;
}

.search-bar input {
  background: transparent;
  border: none;
  color: var(--foreground);
  font-size: 12px;
  outline: none;
  width: 100%;
}

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

/* --------------------------------------------------------------------------
   SHADCN BUTTONS
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
  border: none;
  font-family: var(--font-sans);
}

.btn-primary {
  background-color: var(--primary);
  color: var(--primary-foreground);
}

.btn-primary:hover {
  background-color: #27272a; /* zinc-800 */
}

.btn-outline {
  background-color: transparent;
  color: var(--foreground);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background-color: var(--accent);
}

.btn-urgent {
  background-color: var(--urgent);
  color: white;
}

.btn-urgent:hover {
  opacity: 0.9;
}

.btn-xs {
  padding: 0.25rem 0.5rem;
  font-size: 11px;
}

/* --------------------------------------------------------------------------
   DASHBOARD STATS CARDS
   -------------------------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.stat-card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.stat-card.border-primary { border-left: 2px solid var(--foreground); }
.stat-card.border-urgent { border-left: 2px solid var(--urgent); }
.stat-card.border-warning { border-left: 2px solid var(--warning); }
.stat-card.border-success { border-left: 2px solid var(--success); }

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted-foreground);
  letter-spacing: 0.05em;
}

.stat-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.bg-primary { background-color: rgba(9, 9, 11, 0.05); color: var(--foreground); }
.bg-urgent { background-color: rgba(244, 63, 94, 0.1); color: var(--urgent); }
.bg-warning { background-color: rgba(245, 158, 11, 0.1); color: var(--warning); }
.bg-success { background-color: rgba(16, 185, 129, 0.1); color: var(--success); }

.stat-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.stat-sub {
  font-size: 10px;
  color: var(--muted-foreground);
}

/* --------------------------------------------------------------------------
   DASHBOARD GRID PANELS
   -------------------------------------------------------------------------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.dash-card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.dash-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.dash-card-header h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Urgent Action Queue */
.urgent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
}

.urgent-item:last-child {
  border-bottom: none;
}

.urgent-info h4 {
  font-size: 12px;
  font-weight: 600;
}

.urgent-info p {
  font-size: 11px;
  color: var(--muted-foreground);
  margin-top: 0.15rem;
}

.urgent-info .time {
  font-size: 9px;
  color: var(--muted-foreground);
  margin-top: 0.25rem;
  display: block;
}

/* Funnel & Goals Progress Bars */
.funnel-progress-bars {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.funnel-bar-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.funnel-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}

.progress-track {
  height: 6px;
  background-color: var(--border);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-color: var(--foreground);
  border-radius: 9999px;
  transition: width 0.3s ease;
}

.daily-target-widget {
  margin-top: 1.5rem;
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
}

.target-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* Activity Log */
.activity-log-list {
  list-style: none;
}

.activity-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-icon {
  font-size: 12px;
}

.activity-content p {
  font-size: 12px;
}

.activity-content .time {
  font-size: 9px;
  color: var(--muted-foreground);
}

/* --------------------------------------------------------------------------
   DIRECTORY TABLE VIEW
   -------------------------------------------------------------------------- */
.tab-view {
  display: none;
}

.tab-view.active {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

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

.section-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.section-header p {
  font-size: 11px;
  color: var(--muted-foreground);
}

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

.table-container {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.leads-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.leads-table th {
  background-color: rgba(9, 9, 11, 0.02);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.leads-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  font-size: 12px;
}

.leads-table tr:hover {
  background-color: rgba(9, 9, 11, 0.01);
}

.stage-select {
  background-color: var(--background);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.25rem 0.5rem;
  font-size: 11px;
  outline: none;
}

/* --------------------------------------------------------------------------
   MESSAGE TEMPLATES
   -------------------------------------------------------------------------- */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.template-card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.template-header {
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.template-body {
  font-size: 11px;
  color: var(--muted-foreground);
  white-space: pre-line;
  line-height: 1.4;
  flex: 1;
}

/* --------------------------------------------------------------------------
   HERMES / AGY PANEL
   -------------------------------------------------------------------------- */
.hermes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.form-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted-foreground);
}

.form-group input, .form-group select, .form-group textarea {
  background-color: var(--background);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  font-size: 12px;
  outline: none;
  font-family: var(--font-sans);
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--ring);
}

.input-copy-group {
  display: flex;
  gap: 0.5rem;
}

.input-copy-group input {
  flex: 1;
}

.code-block {
  background-color: #f4f4f5;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 11px;
  overflow-x: auto;
  color: #71717a;
}

/* --------------------------------------------------------------------------
   MODALS
   -------------------------------------------------------------------------- */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(9, 9, 11, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 500px;
  max-width: 95%;
  padding: 1.5rem;
}

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

.modal-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--muted-foreground);
  cursor: pointer;
  font-size: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.full-width {
  grid-column: span 2;
}

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

/* --------------------------------------------------------------------------
   RESPONSIVE DESIGN (MOBILE FRIENDLY & SIDEBAR COLLAPSE)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  /* Sidebar responsive setup */
  .sidebar {
    left: -260px;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.1);
  }

  .sidebar.active {
    left: 0;
  }

  .sidebar-close-btn {
    display: flex;
  }

  /* Main content layout adjust */
  .main-content {
    margin-left: 0;
    padding: 1.25rem;
  }

  .topbar {
    padding-bottom: 0.75rem;
  }

  .mobile-menu-toggle {
    display: inline-flex;
    background-color: var(--accent);
    color: var(--foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  .search-bar {
    width: 100%;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
    gap: 0.35rem;
  }

  .topbar-actions .btn, .topbar-actions a {
    flex: 1;
    font-size: 10px;
    padding: 0.5rem 0.25rem;
    text-align: center;
    white-space: nowrap;
  }

  /* Table Mobile-Friendly Card Transformations */
  .leads-table thead {
    display: none;
  }

  .leads-table, .leads-table tbody, .leads-table tr, .leads-table td {
    display: block;
    width: 100%;
  }

  .leads-table tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background-color: var(--card);
  }

  .leads-table td {
    border-bottom: none;
    padding: 0.35rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: right;
  }

  .leads-table td::before {
    font-weight: 600;
    color: var(--muted-foreground);
    font-size: 11px;
    text-transform: uppercase;
    float: left;
    text-align: left;
  }

  .leads-table td:nth-of-type(1) {
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    text-align: left;
    display: block;
  }

  .leads-table td:nth-of-type(1)::before {
    content: "";
  }

  .leads-table td:nth-of-type(2)::before { content: "Phone:"; }
  .leads-table td:nth-of-type(3)::before { content: "Region:"; }
  .leads-table td:nth-of-type(4)::before { content: "Stage:"; }
  .leads-table td:nth-of-type(5)::before { content: "Priority:"; }
  .leads-table td:nth-of-type(6)::before { content: "Activity:"; }
  .leads-table td:nth-of-type(7)::before { content: "Action:"; }

  /* Dashboard Panels wrap */
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .hermes-grid {
    grid-template-columns: 1fr;
  }

  /* Adjust Modal layout */
  .form-grid {
    grid-template-columns: 1fr;
  }
  .full-width {
    grid-column: span 1;
  }
}

@media (max-width: 480px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}
