/* ===== Reativação PDD — Glassmorphism dark ===== */

:root {
  --bg-void: #050508;
  --bg-deep: #0B0E14;
  --bg-card: rgba(22, 27, 34, 0.55);
  --border: rgba(255, 255, 255, 0.07);
  --border-bright: rgba(255, 255, 255, 0.14);
  --text: #F0F6FC;
  --text-dim: #C9D1D9;
  --text-muted: #8B949E;

  --purple: #a855f7;
  --green: #10b981;
  --red: #ef4444;
  --yellow: #f59e0b;
  --blue: #58A6FF;

  --r-card: 16px;
  --r-input: 10px;
  --shadow-soft: 0 4px 24px rgba(0,0,0,0.35);
  --shadow-glow-purple: 0 0 32px rgba(168,85,247,0.18);
  --shadow-glow-green: 0 0 32px rgba(16,185,129,0.15);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: 'Inter', system-ui, sans-serif;
  font-feature-settings: "cv02","cv03","cv04","cv11";
  color: var(--text);
  background: var(--bg-void);
  min-height: 100vh;
}

body.app-body {
  background:
    radial-gradient(at 12% 8%, rgba(168,85,247,0.10) 0%, transparent 40%),
    radial-gradient(at 88% 92%, rgba(16,185,129,0.08) 0%, transparent 35%),
    radial-gradient(at 50% 50%, #0B0E14 0%, #050508 80%);
}

.noise {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9'/></filter><rect width='200' height='200' filter='url(%23n)'/></svg>");
}

/* ===== Glass ===== */
.glass {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), var(--shadow-soft);
}

/* ===== Login ===== */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
  background: radial-gradient(at 20% 10%, rgba(168,85,247,0.15) 0%, transparent 40%),
              radial-gradient(at 80% 90%, rgba(16,185,129,0.10) 0%, transparent 35%),
              var(--bg-void);
}
.login-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.login-card {
  width: 100%; max-width: 420px; padding: 36px 32px;
  position: relative; z-index: 1;
  animation: fadeUp 0.5s ease-out;
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.login-mark {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--purple), var(--green));
  box-shadow: 0 6px 20px rgba(168,85,247,0.4);
}
.login-title { font-weight: 700; font-size: 18px; }
.login-sub { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

.login-card label {
  display: block; margin-top: 14px; font-size: 12px; font-weight: 600;
  color: var(--text-dim); letter-spacing: 0.04em; text-transform: uppercase;
}
.login-card input {
  width: 100%; margin-top: 6px; padding: 12px 14px;
  background: rgba(13,17,23,0.6); border: 1px solid var(--border);
  border-radius: var(--r-input); color: var(--text); font-size: 14px;
  font-family: inherit; transition: border 0.15s;
}
.login-card input:focus {
  outline: none; border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(168,85,247,0.15);
}
.login-foot { margin-top: 18px; font-size: 11px; color: var(--text-muted); line-height: 1.5; }

.alert {
  background: rgba(239,68,68,0.10); border: 1px solid rgba(239,68,68,0.3);
  color: #FCA5A5; padding: 10px 14px; border-radius: 10px; font-size: 13px;
  margin-bottom: 12px;
}

/* ===== Buttons ===== */
.btn-primary {
  margin-top: 20px; width: 100%; padding: 12px 16px;
  background: linear-gradient(135deg, var(--purple) 0%, #8B5CF6 100%);
  color: white; border: none; border-radius: var(--r-input);
  font-weight: 600; font-size: 14px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(168,85,247,0.3);
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(168,85,247,0.4); }
.btn-primary:active { transform: scale(0.98); }

.btn-ghost {
  padding: 8px 12px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-dim); font-size: 13px;
  cursor: pointer; transition: all 0.15s; text-decoration: none;
  font-family: inherit;
}
.btn-ghost:hover { background: rgba(255,255,255,0.08); color: var(--text); }

/* ===== Topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px; height: 56px;
  background: rgba(11,14,20,0.85);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 240px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--purple), var(--green));
  box-shadow: 0 0 16px rgba(168,85,247,0.4);
}
.brand-title { font-weight: 700; font-size: 15px; line-height: 1; }
.brand-sub { font-size: 11px; color: var(--text-muted); margin-top: 3px; letter-spacing: 0.03em; }

.tabbar { flex: 1; display: flex; gap: 0; }
.tab {
  background: transparent; color: var(--text-muted); cursor: pointer;
  padding: 10px 18px; font-weight: 600; font-size: 13px;
  border: none; border-bottom: 2px solid transparent;
  transition: all 0.15s; position: relative;
  font-family: inherit;
}
.tab:hover { color: var(--text-dim); }
.tab.active { color: var(--text); border-bottom-color: var(--purple); }
.tab-chat { display: flex; align-items: center; gap: 6px; }
.chat-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--red); animation: pulse 1.4s ease-in-out infinite;
}

.topbar-right { display: flex; align-items: center; gap: 14px; }
.sync-status { font-size: 11px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: rgba(255,255,255,0.04); border-radius: 999px; border: 1px solid var(--border); }
.user-name { font-size: 12px; font-weight: 600; }
.user-logout { font-size: 11px; color: var(--text-muted); text-decoration: none; }
.user-logout:hover { color: var(--red); }

/* ===== Tab content ===== */
.tab-content { display: none; padding: 24px; max-width: 1500px; margin: 0 auto; }
.tab-content.active { display: block; animation: fadeSlide 0.3s ease-out; }

/* ===== KPI grid ===== */
.kpi-grid {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 14px; margin-bottom: 14px;
}
.kpi-row-2 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) {
  .kpi-grid, .kpi-row-2 { grid-template-columns: repeat(2, 1fr); }
}

.kpi { padding: 18px 20px; transition: transform 0.18s; }
.kpi:hover { transform: translateY(-2px); border-color: var(--border-bright); }
.kpi-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted);
}
.kpi-value {
  font-size: 28px; font-weight: 700; margin-top: 6px;
  font-feature-settings: "tnum"; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

.kpi-blue .kpi-value { color: var(--blue); }
.kpi-green .kpi-value { color: var(--green); }
.kpi-red .kpi-value { color: var(--red); }
.kpi-yellow .kpi-value { color: var(--yellow); }
.kpi-purple .kpi-value { color: var(--purple); }

.kpi-green { box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), var(--shadow-soft), var(--shadow-glow-green); }
.kpi-purple { box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), var(--shadow-soft), var(--shadow-glow-purple); }

/* Stagger entrance */
.stagger { opacity: 0; transform: translateY(8px); animation: fadeUp 0.5s ease-out forwards; animation-delay: calc(var(--i) * 60ms); }

/* ===== Card ===== */
.card { padding: 20px 22px; margin-bottom: 14px; }
.card-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.10em; color: var(--text-muted);
  margin-bottom: 14px; padding-left: 10px;
  border-left: 3px solid var(--purple);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

/* Chart containers — altura travada pra Chart.js não esticar infinito */
.chart-box { position: relative; width: 100%; height: 320px; }
.chart-box.lg { height: 240px; }
.card canvas { display: block; }

/* ===== Filters ===== */
.filters {
  padding: 14px; margin-bottom: 12px;
  display: grid; grid-template-columns: 2fr repeat(3, 1fr) auto auto; gap: 10px;
}
.filters input, .filters select {
  background: rgba(13,17,23,0.6); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; color: var(--text);
  font-family: inherit; font-size: 13px;
}
.filters input:focus, .filters select:focus {
  outline: none; border-color: var(--purple);
}

.lista-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }

/* ===== Table ===== */
.table-wrap { overflow: auto; padding: 0; max-height: calc(100vh - 320px); }
.table-clientes {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.table-clientes thead th {
  position: sticky; top: 0; z-index: 5;
  background: rgba(13,17,23,0.95); backdrop-filter: blur(12px);
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  text-align: left; padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.table-clientes tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-dim);
}
.table-clientes tbody tr { transition: background 0.12s; }
.table-clientes tbody tr:hover { background: rgba(168,85,247,0.05); }
.table-clientes .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-clientes .row-name { color: var(--text); font-weight: 500; }
.table-clientes .row-id { color: var(--text-muted); font-size: 11px; font-family: 'JetBrains Mono', monospace; }

.cell-status select, .cell-result select {
  width: 100%; min-width: 130px; max-width: 170px;
  background: rgba(13,17,23,0.6); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 8px;
  color: var(--text); font-size: 12px; font-family: inherit;
}
.cell-status select:focus, .cell-result select:focus {
  outline: none; border-color: var(--purple);
}

.badge { display: inline-block; padding: 2px 7px; border-radius: 999px; font-size: 10px; font-weight: 600; letter-spacing: 0.04em; }
.badge.green { background: rgba(16,185,129,0.15); color: #6EE7B7; }
.badge.purple { background: rgba(168,85,247,0.15); color: #C4B5FD; }
.badge.yellow { background: rgba(245,158,11,0.15); color: #FCD34D; }
.badge.red { background: rgba(239,68,68,0.15); color: #FCA5A5; }
.badge.gray { background: rgba(139,148,158,0.15); color: var(--text-muted); }

.dot-online {
  display: inline-block; width: 7px; height: 7px;
  border-radius: 50%; background: #10b981;
  box-shadow: 0 0 8px rgba(16,185,129,0.7);
  animation: pulse 1.4s ease-in-out infinite;
}

.btn-detalhe {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-dim); padding: 4px 10px; border-radius: 6px;
  font-size: 11px; cursor: pointer; transition: all 0.15s;
  font-family: inherit;
}
.btn-detalhe:hover { background: rgba(168,85,247,0.10); color: var(--purple); border-color: var(--purple); }

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(5,5,8,0.70); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fadeIn 0.18s ease-out;
}
.modal-backdrop[hidden] { display: none !important; }
.modal {
  width: 100%; max-width: 720px; max-height: 90vh; overflow: auto;
  padding: 28px 30px; position: relative;
  animation: fadeUp 0.22s ease-out;
}
.modal-close {
  position: absolute; top: 14px; right: 14px;
  background: transparent; border: none; color: var(--text-muted);
  font-size: 26px; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text); }

.detalhe-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
.detalhe-item .lbl { font-size: 10px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.06em; font-weight: 600; }
.detalhe-item .val { font-size: 15px; font-weight: 500; margin-top: 3px; }

.detalhe-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.detalhe-form label { display: block; font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.detalhe-form input, .detalhe-form select, .detalhe-form textarea {
  width: 100%; margin-top: 4px; padding: 8px 10px;
  background: rgba(13,17,23,0.6); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-family: inherit; font-size: 13px;
}
.detalhe-form .full { grid-column: span 2; }
.detalhe-form textarea { min-height: 70px; resize: vertical; }

.log-list { margin-top: 16px; max-height: 200px; overflow: auto; font-size: 12px; }
.log-item { padding: 8px 10px; border-left: 2px solid var(--border); margin-bottom: 6px; color: var(--text-dim); }
.log-item .log-meta { color: var(--text-muted); font-size: 10px; margin-top: 3px; font-family: 'JetBrains Mono', monospace; }

/* ===== Calendario ===== */
.cal-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px; margin-top: 14px;
}
.cal-day {
  background: rgba(22,27,34,0.5); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; transition: all 0.15s;
}
.cal-day:hover { border-color: var(--purple); transform: translateY(-1px); }
.cal-day-data { font-weight: 700; font-size: 14px; }
.cal-day-dow { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; }
.cal-day-stats { margin-top: 8px; font-size: 12px; color: var(--text-dim); display: flex; justify-content: space-between; }
.cal-day-bar { margin-top: 6px; height: 4px; background: rgba(255,255,255,0.06); border-radius: 999px; overflow: hidden; }
.cal-day-bar-fill { height: 100%; background: var(--green); transition: width 0.4s; }

/* ===== Chat widget (floating bottom-right) ===== */
.chat-widget { position: fixed; right: 20px; bottom: 20px; z-index: 150; }

.chat-bubble {
  position: relative;
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), #8B5CF6);
  color: white; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(168,85,247,0.45), 0 0 0 1px rgba(255,255,255,0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.chat-bubble:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 12px 32px rgba(168,85,247,0.55); }
.chat-bubble:active { transform: scale(0.95); }
.chat-widget[data-open="true"] .chat-bubble { display: none; }

.chat-bubble-badge {
  position: absolute; top: -4px; right: -4px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--bg-deep);
  animation: pulse 1.4s ease-in-out infinite;
}

.chat-panel {
  width: 360px; height: 500px;
  position: absolute; right: 0; bottom: 0;
  display: none; flex-direction: column; overflow: hidden;
  border-radius: 18px;
  background: #0F141C;
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.chat-widget[data-open="true"] .chat-panel {
  display: flex;
}

.chat-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(135deg, rgba(168,85,247,0.10), transparent);
}
.chat-title { font-weight: 700; font-size: 13px; }
.chat-sub { font-size: 10px; color: var(--text-muted); margin-top: 2px; letter-spacing: 0.04em; }
.chat-actions { display: flex; align-items: center; gap: 4px; }
.chat-close, .chat-icon {
  background: transparent; border: none; color: var(--text-muted);
  cursor: pointer; padding: 4px 6px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.chat-close { font-size: 22px; line-height: 1; }
.chat-close:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.chat-icon:hover { color: var(--red); background: rgba(239,68,68,0.10); }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 14px 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.chat-empty {
  text-align: center; color: var(--text-muted); font-size: 12px;
  padding: 30px 10px;
}
.chat-msg {
  position: relative;
  max-width: 80%; padding: 7px 11px; border-radius: 12px;
  font-size: 12.5px; line-height: 1.4; word-break: break-word;
}
.chat-msg--enter { animation: fadeUp 0.2s ease-out; }
.chat-msg .msg-delete {
  position: absolute; top: -8px; right: -8px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(13,17,23,0.95); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 14px; line-height: 1;
  cursor: pointer; padding: 0;
  display: none; align-items: center; justify-content: center;
  transition: all 0.12s;
  font-family: inherit;
}
.chat-msg:hover .msg-delete { display: flex; }
.chat-msg .msg-delete:hover { background: var(--red); color: white; border-color: var(--red); transform: scale(1.1); }
.chat-msg.me {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--purple), #8B5CF6); color: white;
  border-bottom-right-radius: 4px;
}
.chat-msg.them {
  align-self: flex-start;
  background: rgba(255,255,255,0.06); border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-msg .msg-meta { font-size: 9px; opacity: 0.65; margin-top: 2px; font-family: 'JetBrains Mono', monospace; }
.chat-msg.apagada { opacity: 0.55; }
.chat-msg.apagada .msg-content { text-decoration: line-through; text-decoration-color: rgba(255,255,255,0.3); }
.msg-tag-apagada {
  display: inline-block; margin-left: 6px;
  font-size: 9px; padding: 1px 6px; border-radius: 4px;
  background: rgba(239,68,68,0.18); color: #FCA5A5;
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  vertical-align: middle; text-decoration: none;
}

.chat-input {
  display: flex; gap: 6px; padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: rgba(13,17,23,0.4);
}
.chat-input input {
  flex: 1; padding: 8px 12px; background: rgba(13,17,23,0.7);
  border: 1px solid var(--border); border-radius: 999px;
  color: var(--text); font-family: inherit; font-size: 12.5px;
}
.chat-input input:focus { outline: none; border-color: var(--purple); }
.chat-input button {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: var(--purple); color: white; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.12s, background 0.12s;
}
.chat-input button:hover { background: #8B5CF6; transform: scale(1.05); }
.chat-input button:active { transform: scale(0.92); }

@media (max-width: 520px) {
  .chat-panel { width: calc(100vw - 24px); height: 70vh; }
}

/* ===== Animations ===== */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeSlide { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.6; transform: scale(1.2); } }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(139,148,158,0.2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(139,148,158,0.35); }
