/* ═══════════════════════════════════════════
   COMPONENTS.CSS — Buttons, Modals, Tables,
   Sidebar, Inputs, Badges, Toasts
   ═══════════════════════════════════════════ */

/* ── Buttons ──────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border: none; border-radius: var(--radius-md);
  font-family: inherit; font-weight: 600; font-size: 0.9rem;
  cursor: pointer; transition: all 0.2s ease; line-height: 1;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(79,70,229,0.3); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--success-hover); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16,185,129,0.3); }

.btn-danger-outline { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn-danger-outline:hover:not(:disabled) { background: var(--danger); color: #fff; box-shadow: 0 4px 10px rgba(231,76,60,0.2); transform: translateY(-1px); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text-dark); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; border-radius: var(--radius-sm); }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 50%; }
.btn-block { width: 100%; }

/* ── Inputs ───────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group label { font-size: 0.85rem; font-weight: 600; color: var(--text-dark); }

.form-input {
  padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.95rem; transition: all 0.2s; background: var(--input-bg); color: var(--text-dark);
}
.form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-input::placeholder { color: var(--text-light); }

.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

select.form-input { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

/* ── Sidebar ──────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; width: var(--sidebar-width); height: 100vh;
  background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; z-index: 1000;
  transition: transform 0.3s ease, width 0.3s ease;
}

.sidebar.collapsed {
  width: 70px;
  z-index: 1000;
  overflow: hidden;
}

.sidebar:not(.collapsed) {
  z-index: 1000;
}

.sidebar.collapsed .sidebar-brand h2,
.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .sidebar-user-info,
.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .sidebar-user {
  display: none;
}

.sidebar.collapsed .sidebar-brand {
  justify-content: center;
  padding: 24px 10px;
}

.sidebar.collapsed .sidebar-brand i {
  margin: 0 auto;
}

.sidebar.collapsed .sidebar-nav {
  padding: 16px 8px;
}



.sidebar.collapsed .sidebar-footer {
  padding: 12px 8px;
}

.sidebar.collapsed .btnCollapseSidebar {
  justify-content: center;
}

.sidebar-brand {
  padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-brand i { font-size: 1.5rem; color: var(--primary); }
.sidebar-brand h2 { font-size: 1.1rem; font-weight: 700; color: #fff; }
.sidebar-brand span { color: var(--primary); }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }

.sidebar-link {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-radius: var(--radius-sm); color: var(--sidebar-text);
  font-size: 0.9rem; font-weight: 500; cursor: pointer;
  transition: all 0.15s ease; border: none; background: none;
  width: 100%; text-align: left; font-family: inherit;
}
.sidebar-link i { width: 20px; text-align: center; font-size: 1rem; }
.sidebar-link:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.sidebar-link.active { background: var(--sidebar-active); color: #fff; }

.sidebar-footer {
  padding: 16px 12px; border-top: 1px solid rgba(255,255,255,0.06);
}
.sidebar-user {
  display: flex; align-items: center; gap: 12px; padding: 8px 14px;
  margin-bottom: 8px;
}
.sidebar-user-info { flex: 1; }
.sidebar-user-info .name { color: #e2e8f0; font-size: 0.85rem; font-weight: 600; }
.sidebar-user-info .role { color: var(--sidebar-text); font-size: 0.7rem; }
.sidebar-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.9rem; }

/* ── Main Content Area ────────────────────── */
.main-content {
  margin-left: var(--sidebar-width); min-height: 100vh; padding: 0;
  transition: margin-left 0.3s ease;
  position: relative;
  z-index: 10;
}

.main-content.collapsed {
  margin-left: 70px;
}

.top-bar {
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 16px 32px; display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 40; box-shadow: var(--shadow-sm);
}
.top-bar h2 { font-size: 1.25rem; font-weight: 700; }
.top-bar-actions { display: flex; align-items: center; gap: 12px; }

.page-content { padding: 28px 32px; }

/* ── Cards ────────────────────────────────── */
.card {
  background: var(--card); border-radius: var(--radius-lg); border: 1px solid var(--border);
  box-shadow: var(--shadow-md); overflow: hidden; transition: box-shadow 0.3s ease;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card-header {
  padding: 20px 24px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,0.6);
  backdrop-filter: blur(10px); display: flex; justify-content: space-between; align-items: center;
}
.card-header h3 { font-size: 1.05rem; font-weight: 700; color: var(--text-dark); display: flex; align-items: center; gap: 10px; }
.card-header h3 i { color: var(--primary); }
.card-body { padding: 24px; }

/* ── Tables ───────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 14px 24px; font-weight: 700; font-size: 0.75rem;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px;
  border-bottom: 2px solid var(--border); background: transparent;
}
td { padding: 16px 24px; vertical-align: middle; border-bottom: 1px solid var(--border); font-size: 0.95rem; }
tr:last-child td { border-bottom: none; }
tr { transition: background 0.2s ease; }
tr:hover { background: #f8fafc; }

/* ── Badges ───────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #dcfce7; color: #16a34a; }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: #e67e22; }
.badge-info { background: var(--info-light); color: var(--info); }

/* ── Modal Overlay ────────────────────────── */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 100;
  display: flex; justify-content: center; align-items: center;
  background: rgba(15,23,42,0.6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.modal-glass {
  width: 90%; max-width: 500px; border-radius: var(--radius-xl); overflow: hidden;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.5); box-shadow: var(--shadow-xl);
}
.modal-header {
  padding: 20px 24px; display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; font-weight: 600; color: var(--primary); display: flex; align-items: center; gap: 10px; }
.modal-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted); padding: 4px; }
.modal-close:hover { color: var(--text-dark); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 12px; justify-content: flex-end; }

/* ── Toast ────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--card); border-left: 4px solid var(--success); padding: 14px 20px;
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-weight: 500; font-size: 0.9rem;
  display: flex; align-items: center; gap: 10px; animation: fadeInUp 0.3s ease;
  min-width: 280px; color: var(--text-dark);
}
.toast.error { border-left-color: var(--danger); }
.toast i { font-size: 1.1rem; }

/* ── Stat Cards (Dashboard) ───────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 28px; }
.stat-card {
  background: var(--card); border-radius: var(--radius-lg); padding: 24px;
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon { width: 52px; height: 52px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; }
.stat-info { flex: 1; }
.stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--text-dark); }

/* ── WhatsApp Modal Specifics ─────────────── */
.wa-header { background: var(--wa-header); color: #fff; padding: 12px 16px; display: flex; align-items: center; gap: 12px; }
.wa-back-btn { background: none; border: none; color: #fff; font-size: 1.2rem; cursor: pointer; padding: 4px; }
.wa-contact-info { flex: 1; }
.wa-contact-info h4 { font-size: 1rem; font-weight: 500; margin: 0; }
.wa-contact-info span { font-size: 0.75rem; opacity: 0.8; }
.wa-icons { display: flex; gap: 16px; font-size: 1.1rem; }

.wa-chat-area {
  background-color: rgba(236,229,221,0.6);
  background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
  background-size: cover; background-blend-mode: overlay;
  padding: 24px 16px; min-height: 300px; display: flex; flex-direction: column;
}
.wa-date-divider { background: rgba(255,255,255,0.6); backdrop-filter: blur(4px); align-self: center; padding: 4px 12px; border-radius: 12px; font-size: 0.7rem; color: var(--text-muted); font-weight: 600; margin-bottom: 20px; }
.wa-message-container { display: flex; justify-content: flex-start; padding-right: 40px; }
.wa-message-bubble { background: #fff; padding: 10px 12px; border-radius: 0 8px 8px 8px; box-shadow: 0 1px 2px rgba(0,0,0,0.1); max-width: 100%; position: relative; }
.wa-message-bubble::before { content:''; position:absolute; top:0; left:-8px; border:8px solid transparent; border-top-color:#fff; border-right-color:#fff; }
.wa-message-sender { color: var(--primary); font-weight: 600; font-size: 0.8rem; margin-bottom: 4px; display: flex; justify-content: space-between; }
.ai-badge { background: #f1f5f9; color: var(--info); padding: 2px 6px; border-radius: 4px; font-size: 0.65rem; font-weight: 700; }
.wa-message-textarea { width: 100%; border: none; resize: none; font-size: 0.9rem; font-family: inherit; color: #111; background: transparent; line-height: 1.4; outline: none; padding: 2px 0; }
.wa-message-meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 0.65rem; color: #999; margin-top: 4px; }

.wa-intelligence-match { background: rgba(255,255,255,0.85); border-radius: 8px; padding: 12px; margin-bottom: 16px; font-size: 0.8rem; box-shadow: 0 1px 3px rgba(0,0,0,0.05); border: 1px solid rgba(0,0,0,0.05); }
.match-score, .match-address { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; color: var(--text-dark); font-weight: 500; }

.ai-insight { margin-top: auto; background: rgba(0,0,0,0.04); backdrop-filter: blur(4px); border: 1px solid rgba(255,255,255,0.3); padding: 8px 12px; border-radius: 8px; font-size: 0.8rem; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.ai-insight i { color: #8b5cf6; }
.wa-select-tactic { background: transparent; border: none; color: var(--text-dark); font-weight: 600; font-family: inherit; font-size: 0.85rem; cursor: pointer; outline: none; margin-left: 4px; }

.wa-footer-action { background: rgba(255,255,255,0.9); padding: 16px; border-top: 1px solid rgba(0,0,0,0.05); }

/* 👋 FuraFila Connect Widget Support */
.copilot-fab { position: fixed; bottom: 24px; right: 24px; width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; border: none; box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4); font-size: 1.5rem; cursor: pointer; z-index: 1000; display: flex; align-items: center; justify-content: center; transition: transform 0.2s, box-shadow 0.2s; }
.copilot-fab:hover { transform: scale(1.05); box-shadow: 0 6px 16px rgba(99, 102, 241, 0.6); }
.copilot-window { position: fixed; bottom: 90px; right: 24px; width: 360px; max-width: calc(100vw - 48px); height: 500px; max-height: calc(100vh - 120px); background: var(--bg); border-radius: var(--radius-lg); box-shadow: 0 8px 32px rgba(0,0,0,0.15); display: flex; flex-direction: column; z-index: 1001; overflow: hidden; border: 1px solid var(--border); transition: opacity 0.3s, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); transform-origin: bottom right; opacity: 1; pointer-events: all; }
.copilot-window.hidden { opacity: 0; transform: scale(0.8) translateY(20px); pointer-events: none !important; }
.copilot-header { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; padding: 16px; display: flex; justify-content: space-between; align-items: center; }
.copilot-header .ai-avatar { width: 36px; height: 36px; background: rgba(255,255,255,0.2); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.copilot-body { flex: 1; padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; background: var(--bg-card); scroll-behavior: smooth; }
.copilot-msg { max-width: 85%; padding: 10px 14px; border-radius: 12px; font-size: 0.9rem; line-height: 1.4; word-wrap: break-word; animation: modalIn 0.3s ease forwards; }
.copilot-msg.ai { align-self: flex-start; background: var(--bg); border: 1px solid var(--border); color: var(--text-dark); border-bottom-left-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.05);}
.copilot-msg.usr { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; box-shadow: 0 1px 2px rgba(99,102,241,0.2);}
.copilot-footer { padding: 12px; background: var(--bg); border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; }
#copilotInput { flex: 1; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-dark); border-radius: var(--radius-sm); padding: 10px 12px; font-family: inherit; font-size: 0.9rem; resize: none; max-height: 100px; outline: none; }
#copilotInput:focus { border-color: var(--primary); }

/* ── Empty State ──────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; margin-bottom: 16px; color: var(--text-light); }
.empty-state p { font-size: 0.95rem; }

/* ── Responsive ───────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .top-bar { padding: 12px 16px; }
  .page-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row { flex-direction: column; }
  .modal-glass { width: 95%; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
