/* Sistema de Afiliados - ClikFibra */
/* style.css - Design System Completo */

:root {
  --primary: #D8177A;
  --primary-dark: #b01262;
  --sidebar-bg: #1a0a14;
  --sidebar-text: #a0aec0;
  --sidebar-active: #D8177A;
  --sidebar-width: 240px;
  --topbar-h: 60px;
  --content-bg: #f4f6fb;
  --card-shadow: 0 2px 8px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--content-bg);
  margin: 0;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
#sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: width .25s ease;
  overflow: hidden;
}

#sidebar.collapsed { width: 64px; }
#sidebar.collapsed .sidebar-logo-text,
#sidebar.collapsed .sidebar-user-info,
#sidebar.collapsed .sidebar-nav span,
#sidebar.collapsed .sidebar-footer span { display: none; }
#sidebar.collapsed .sidebar-nav a { justify-content: center; padding: 12px; }
#sidebar.collapsed .badge { display: none !important; }

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
}

.sidebar-logo img { height: 32px; flex-shrink: 0; }
.sidebar-logo-text { white-space: nowrap; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.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: 14px;
  flex-shrink: 0;
}

.sidebar-user-name { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; }
.sidebar-user-role { color: var(--sidebar-text); font-size: 11px; white-space: nowrap; }

.sidebar-nav {
  list-style: none;
  padding: 8px 0;
  margin: 0;
  flex: 1;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  border-radius: 6px;
  margin: 2px 8px;
  transition: all .2s;
  white-space: nowrap;
}

.sidebar-nav a:hover {
  background: rgba(216,23,122,.15);
  color: #fff;
}

.sidebar-nav a.active {
  background: rgba(216,23,122,.18);
  color: #fff;
  border-left: 3px solid var(--primary);
  padding-left: 13px;
}

.sidebar-nav a i { font-size: 17px; flex-shrink: 0; }
.sidebar-divider { height: 1px; background: rgba(255,255,255,.07); margin: 8px 16px; list-style: none; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid rgba(255,255,255,.07);
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  text-decoration: none;
  font-size: 14px;
  border-radius: 6px;
  transition: all .2s;
  white-space: nowrap;
}

.sidebar-footer a:hover { background: rgba(255,0,0,.1); }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
#mainContent {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .25s ease;
}

#mainContent.expanded { margin-left: 64px; }

.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e5e9f0;
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}

.content-area {
  padding: 24px;
  flex: 1;
}

/* ============================================================
   CARDS E STATS
   ============================================================ */
.stat-card {
  box-shadow: var(--card-shadow);
  border-radius: 12px;
  background: #fff;
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}

.card {
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  background: #fff;
}

.card-header {
  border-radius: 12px 12px 0 0 !important;
  border-bottom: 1px solid #f0f0f0;
  padding: 14px 20px;
  font-size: 14px;
}

/* ============================================================
   CHAT
   ============================================================ */
.chat-message {
  display: flex;
  margin-bottom: 12px;
}

.chat-message.sent {
  justify-content: flex-end;
}

.chat-message.received {
  justify-content: flex-start;
}

.chat-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 16px;
  position: relative;
}

.chat-message.sent .chat-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-message.received .chat-bubble {
  background: #fff;
  color: #1a0a14;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
}

.chat-sender {
  display: block;
  font-size: 10px;
  font-weight: 600;
  opacity: .7;
  margin-bottom: 2px;
}

.chat-text {
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-time {
  display: block;
  font-size: 10px;
  opacity: .6;
  text-align: right;
  margin-top: 4px;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a0a14 0%, #2d0d22 50%, #1a0a14 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(216,23,122,.25);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 40px rgba(216,23,122,.15);
}

.login-logo {
  margin-bottom: 16px;
}

.login-logo img {
  height: 72px;
  width: auto;
}

.login-subtitle {
  color: rgba(255,255,255,.5);
  font-size: 13px;
  margin-top: -8px;
}

.login-card .form-control {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  border-radius: 10px;
  padding: 12px 16px;
}

.login-card .form-control:focus {
  background: rgba(255,255,255,.12);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(216,23,122,.25);
  color: #fff;
}

.login-card .form-label { color: rgba(255,255,255,.7); font-size: 13px; }
.login-card .form-control::placeholder { color: rgba(255,255,255,.25); }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  border-radius: 10px;
  font-weight: 600;
}

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

/* ============================================================
   SIDEBAR OVERLAY — backdrop do drawer mobile
   ============================================================ */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 998;
  cursor: pointer;
}
body.sidebar-open #sidebar-overlay { display: block; }

/* ============================================================
   RESPONSIVO — 3 breakpoints
   ============================================================ */

/* Tablet (576px – 991px): sidebar ícone-only, sem toggle manual */
@media (max-width: 991.98px) and (min-width: 576px) {
  #sidebar {
    width: 64px !important;
  }
  #sidebar .sidebar-logo-text,
  #sidebar .sidebar-user-info,
  #sidebar .sidebar-nav span,
  #sidebar .sidebar-footer span { display: none !important; }
  #sidebar .sidebar-nav a { justify-content: center !important; padding: 12px !important; }
  #sidebar .badge { display: none !important; }
  #mainContent { margin-left: 64px !important; }
  .content-area { padding: 16px; }
  .chat-bubble { max-width: 85%; }
}

/* Mobile (<576px): drawer off-screen */
@media (max-width: 575.98px) {
  #sidebar {
    width: 240px !important;
    transform: translateX(-100%);
    transition: transform .28s ease;
    z-index: 1000;
  }
  /* Drawer aberto: desliza para dentro */
  body.sidebar-open #sidebar { transform: translateX(0); }

  /* Garante que o texto fica visível dentro do drawer */
  #sidebar .sidebar-logo-text,
  #sidebar .sidebar-user-info,
  #sidebar .sidebar-nav span,
  #sidebar .sidebar-footer span { display: block !important; white-space: nowrap; }
  #sidebar .sidebar-nav a { justify-content: flex-start !important; padding: 10px 16px !important; }
  #sidebar .badge { display: inline-flex !important; }

  /* Content: largura total sem margem lateral */
  #mainContent { margin-left: 0 !important; }
  .content-area { padding: 12px; }
  .chat-bubble { max-width: 88%; }

  /* Tabelas: scroll horizontal */
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .card .table-responsive { border-radius: 0; }
}


/* ============================================================
   BADGES DE STAGE — cores semânticas (P4)
   ============================================================ */
/* Fila / Sem contato */
.badge-stage-queue   { background: #6c757d !important; color: #fff !important; }
/* Em andamento / Contato */
.badge-stage-progress { background: #0d6efd !important; color: #fff !important; }
/* Aguardando / Pendente */
.badge-stage-pending { background: #fd7e14 !important; color: #fff !important; }
/* Ganho / Instalado */
.badge-stage-won     { background: #198754 !important; color: #fff !important; }
/* Perdido / Cancelado */
.badge-stage-lost    { background: #dc3545 !important; color: #fff !important; }
/* Qualidade / FPD / SPD / TPD */
.badge-stage-quality { background: #6f42c1 !important; color: #fff !important; }

/* === BRAND ICON ===
   Usa --primary (#D8177A) para icone de destaque */
.stat-icon-brand { background: rgba(216,23,122,.12) !important; color: var(--primary) !important; }
