/* ======================================================
   Wezappi CRM — style.css
   Light mode profissional
   ====================================================== */

:root {
  --brand:        #4A3AFF;
  --brand-light:  #EEF0FF;
  --brand-dark:   #2E22CC;

  --bg:           #F5F6FA;
  --surface:      #FFFFFF;
  --surface-2:    #F0F1F8;

  --border:       #E2E4EE;
  --border-dark:  #C8CAD8;

  --text:         #1A1D2E;
  --text-2:       #5A5E7A;
  --text-3:       #9498B0;

  --success:      #18A96A;
  --success-bg:   #E8F8F1;
  --warning:      #E8930A;
  --warning-bg:   #FFF4E0;
  --danger:       #E0362C;
  --danger-bg:    #FDECEA;
  --info:         #1477E0;
  --info-bg:      #E7F1FD;

  --sidebar-w:    240px;
  --topbar-h:     58px;
  --radius:       8px;
  --radius-lg:    12px;
  --shadow:       0 1px 3px rgba(26,29,46,.08);
  --shadow-md:    0 4px 16px rgba(26,29,46,.10);

  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

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

html, body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ======================================================
   LAYOUT BASE
   ====================================================== */

.crm-wrap {
  display: flex;
  min-height: 100vh;
}

/* ======================================================
   SIDEBAR
   ====================================================== */

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-logo {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--brand);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  line-height: 1.2;
}

.sidebar-logo .logo-text strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.sidebar-logo .logo-text span {
  font-size: 11px;
  color: var(--text-3);
}

.sidebar-nav {
  flex: 1;
  padding: .75rem .75rem;
  overflow-y: auto;
}

.nav-group {
  margin-bottom: 1.25rem;
}

.nav-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-3);
  padding: 0 .5rem .4rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s, color .12s;
  margin-bottom: 1px;
}

.nav-item i {
  font-size: 17px;
  width: 20px;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--brand-light);
  color: var(--brand);
  text-decoration: none;
}

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

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 20px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

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

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: background .12s;
}

.sidebar-user:hover { background: var(--surface-2); }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-info { flex: 1; min-width: 0; }
.user-info strong { display: block; font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info span { font-size: 11px; color: var(--text-3); }

/* ======================================================
   MAIN
   ====================================================== */

.crm-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ======================================================
   TOPBAR
   ====================================================== */

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-title {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.topbar-breadcrumb {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 400;
  margin-top: 1px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s, border-color .12s;
  position: relative;
}

.icon-btn i { font-size: 18px; }
.icon-btn:hover { background: var(--brand-light); border-color: var(--brand); color: var(--brand); text-decoration: none; }

.icon-btn .dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: var(--danger);
  border-radius: 50%;
  border: 1.5px solid #fff;
}

/* ======================================================
   CONTENT
   ====================================================== */

.crm-content {
  flex: 1;
  padding: 1.5rem;
}

/* ======================================================
   CARDS / KPI
   ====================================================== */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.kpi-card .kpi-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.kpi-card .kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-3);
}

.kpi-card .kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
}

.kpi-card .kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-top: .15rem;
}

.kpi-card .kpi-delta {
  font-size: 11px;
  color: var(--text-3);
  margin-top: .1rem;
}

.kpi-card .kpi-delta.up   { color: var(--success); }
.kpi-card .kpi-delta.down { color: var(--danger); }

.kpi-icon.purple { background: #EEEEFF; color: var(--brand); }
.kpi-icon.green  { background: var(--success-bg); color: var(--success); }
.kpi-icon.amber  { background: var(--warning-bg); color: var(--warning); }
.kpi-icon.blue   { background: var(--info-bg); color: var(--info); }
.kpi-icon.red    { background: var(--danger-bg); color: var(--danger); }

/* ======================================================
   PANELS
   ====================================================== */

.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
}

.panel-header {
  display: flex;
  align-items: center;
  margin-bottom: .85rem;
  gap: .5rem;
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.panel-link {
  font-size: 11px;
  color: var(--brand);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}

.panel-link:hover { text-decoration: underline; }

/* ======================================================
   LISTAS
   ====================================================== */

.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

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

.list-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.list-name   { font-size: 12px; font-weight: 600; color: var(--text); }
.list-sub    { font-size: 11px; color: var(--text-3); }
.list-right  { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* ======================================================
   BADGES / STATUS
   ====================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  border-radius: 20px;
  padding: 2px 9px;
  white-space: nowrap;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);     color: var(--info); }
.badge-neutral { background: var(--surface-2);   color: var(--text-2); }
.badge-brand   { background: var(--brand-light);  color: var(--brand); }

/* ======================================================
   ONLINE DOT
   ====================================================== */

.dot-online  { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.dot-offline { width: 8px; height: 8px; border-radius: 50%; background: var(--border-dark); flex-shrink: 0; }

/* ======================================================
   BOTÕES
   ====================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity .12s, background .12s;
  text-decoration: none;
}

.btn:hover { opacity: .88; text-decoration: none; }
.btn i { font-size: 16px; }

.btn-primary   { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ======================================================
   FORMS
   ====================================================== */

.form-group { margin-bottom: 1rem; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: .35rem;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .12s, box-shadow .12s;
  outline: none;
  font-family: var(--font);
}

.form-control:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(74,58,255,.12);
}

.form-control::placeholder { color: var(--text-3); }

/* ======================================================
   TABELAS
   ====================================================== */

.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-3);
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface-2); }

/* ======================================================
   ALERTS
   ====================================================== */

.alert {
  padding: .85rem 1rem;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.alert i { font-size: 17px; flex-shrink: 0; margin-top: 1px; }
.alert-danger  { background: var(--danger-bg);  color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-info    { background: var(--info-bg);    color: var(--info); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }

/* ======================================================
   LOGIN PAGE
   ====================================================== */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 1.5rem;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 1.75rem;
}

.login-logo .logo-icon {
  width: 42px;
  height: 42px;
  background: var(--brand);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
}

.login-logo .logo-text strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.login-logo .logo-text span {
  font-size: 12px;
  color: var(--text-3);
}

.login-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .25rem;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 1.75rem;
}

/* PIN input */
.pin-group {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: .5rem 0 1.25rem;
}

.pin-digit {
  width: 52px;
  height: 58px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
  caret-color: var(--brand);
  -moz-appearance: textfield;
}

.pin-digit::-webkit-outer-spin-button,
.pin-digit::-webkit-inner-spin-button { -webkit-appearance: none; }

.pin-digit:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(74,58,255,.12);
}

.login-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0 .75rem;
}

.login-footer-text {
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
}

/* ======================================================
   UTILITIES
   ====================================================== */

.text-muted   { color: var(--text-3); }
.text-sm      { font-size: 12px; }
.text-xs      { font-size: 11px; }
.fw-600       { font-weight: 600; }
.fw-700       { font-weight: 700; }
.mt-1  { margin-top: .5rem; }
.mt-2  { margin-top: 1rem; }
.mb-1  { margin-bottom: .5rem; }
.mb-2  { margin-bottom: 1rem; }
.gap-1 { gap: .5rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-100 { width: 100%; }
