/* =====================================================================
   EXSAT CRM STARLINK — DESIGN SYSTEM OBSIDIAN & ELECTRIC EMERALD
   Inspirado em interfaces fintech/analytics modernas de alto padrão
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  --bg-deep: #050806;
  --bg-surface: #0a0f0c;
  --bg-card: rgba(14, 20, 16, 0.78);
  --bg-card-hover: rgba(20, 30, 24, 0.9);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-emerald: rgba(16, 185, 129, 0.22);
  --border-emerald-glow: rgba(0, 255, 135, 0.45);
  --emerald-primary: #10b981;
  --emerald-neon: #00ff87;
  --emerald-dark: #047857;
}

* { box-sizing: border-box; }

body {
  background: var(--bg-deep);
  color: #e5e7eb;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background-image: 
    radial-gradient(ellipse 90% 60% at 50% -20%, rgba(16, 185, 129, 0.12), transparent 70%),
    radial-gradient(circle at 100% 100%, rgba(5, 150, 105, 0.06), transparent 50%),
    radial-gradient(rgba(16, 185, 129, 0.08) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 32px 32px;
  background-attachment: fixed;
}

body.app-loading > *:not(#boot-loader) { visibility: hidden; }
#boot-loader {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
  z-index: 1000;
}
body:not(.app-loading) #boot-loader { display: none; }

.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(16, 185, 129, 0.15);
  border-top-color: var(--emerald-neon);
  border-radius: 50%;
  animation: spin 0.75s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  box-shadow: 0 0 20px rgba(0, 255, 135, 0.25);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* SCROLLBAR MODERNA */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #050806; }
::-webkit-scrollbar-thumb { background: #16241c; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--emerald-primary); }

/* CARDS GLASSMORPHISM & REALISMO */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: 1.25rem;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6), 0 0 1px 1px rgba(255, 255, 255, 0.03);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.25s, box-shadow 0.25s;
}

.card:hover {
  border-color: rgba(16, 185, 129, 0.3);
}

.card-glow {
  position: relative;
  overflow: hidden;
}
.card-glow::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 255, 135, 0.4), transparent);
  pointer-events: none;
}

/* INPUTS COM TOQUE PROFISSIONAL */
.input {
  width: 100%;
  background: rgba(9, 14, 11, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.75rem;
  padding: 0.65rem 0.9rem;
  font-size: 0.85rem;
  color: #fff;
  outline: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
}
.input:focus {
  border-color: var(--emerald-primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18), inset 0 1px 2px rgba(0,0,0,0.5);
  background: rgba(11, 18, 14, 0.95);
}
.input::placeholder { color: #64748b; }
select.input option { background: #0c120e; color: #fff; }

.label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
  font-family: 'JetBrains Mono', monospace;
}

/* BOTÕES ESTILO PREDITIVO / FINTECH */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.15rem;
  border-radius: 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  border: 1px solid transparent;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, #059669 0%, #10b981 60%, #00ff87 100%);
  color: #02140b;
  font-weight: 700;
  box-shadow: 0 4px 18px rgba(16, 185, 129, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow: 0 6px 24px rgba(0, 255, 135, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

.btn-ghost {
  background: rgba(18, 26, 21, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
}
.btn-ghost:hover:not(:disabled) {
  background: rgba(28, 42, 34, 0.8);
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--emerald-neon);
  transform: translateY(-1px);
}

.btn-danger {
  background: rgba(220, 38, 38, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}
.btn-danger:hover:not(:disabled) {
  background: rgba(220, 38, 38, 0.3);
  color: #fff;
  border-color: rgba(239, 68, 68, 0.6);
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.74rem;
  border-radius: 0.55rem;
}

.btn-pill {
  border-radius: 9999px;
  padding: 0.45rem 1rem;
}

/* PILLS & SEGMENTED CONTROLS (ESTILO STOVEST) */
.segmented-control {
  display: inline-flex;
  align-items: center;
  background: rgba(8, 12, 10, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  padding: 0.25rem;
  gap: 0.2rem;
}

.segmented-pill {
  padding: 0.4rem 0.9rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #94a3b8;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  border: 1px solid transparent;
  user-select: none;
}
.segmented-pill:hover { color: #fff; }
.segmented-pill.active {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #02140b;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.4);
}

/* NAVEGAÇÃO LATERAL (SIDEBAR) */
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.65rem 0.95rem;
  border-radius: 0.85rem;
  font-size: 0.84rem;
  font-weight: 500;
  color: #94a3b8;
  transition: all 0.2s;
  position: relative;
}
.nav-link:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  transform: translateX(2px);
}
.nav-link.active {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.18), rgba(16, 185, 129, 0.04));
  color: var(--emerald-neon);
  font-weight: 700;
  border-left: 3px solid var(--emerald-neon);
  box-shadow: inset 0 0 15px rgba(0, 255, 135, 0.06);
}

/* BADGES ESTILO GLOW PILL */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border: 1px solid transparent;
  font-family: 'JetBrains Mono', monospace;
}
.dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 9999px;
  display: inline-block;
  box-shadow: 0 0 8px currentColor;
}

/* TABELAS OPERACIONAIS */
table.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8rem;
}
table.tbl th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #94a3b8;
  background: rgba(8, 12, 10, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}
table.tbl td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
  transition: background 0.15s;
}
table.tbl tbody tr {
  transition: background 0.15s;
}
table.tbl tbody tr:hover td {
  background: rgba(20, 32, 25, 0.5);
}

/* MODAIS COM BACKDROP BLUR REALISTA */
.modal-bg {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(2, 5, 3, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  animation: fadeIn 0.2s ease-out;
}
.modal-box {
  background: #090e0b;
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 1.5rem;
  width: 100%;
  max-height: 94vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.85), 0 0 35px rgba(0, 255, 135, 0.12);
  animation: slideUpScale 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUpScale {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* CAMERA VIEWFINDER & SHUTTER */
.camera-viewfinder {
  position: relative;
  background: #000;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.4), 0 10px 30px rgba(0,0,0,0.8);
}
.camera-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(255,255,255,0.08) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.08) 1px, transparent 1px);
  background-size: 33.33% 33.33%;
}
.camera-target {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 180px;
  height: 180px;
  border: 2px dashed rgba(0, 255, 135, 0.6);
  border-radius: 1rem;
  pointer-events: none;
}
.btn-shutter {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: #fff;
  border: 5px solid #000;
  box-shadow: 0 0 0 4px var(--emerald-neon), 0 0 25px rgba(0, 255, 135, 0.6);
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-shutter:hover { transform: scale(1.06); filter: brightness(1.1); }
.btn-shutter:active { transform: scale(0.92); }

/* BARCODE SCANNER BEEP GLOW EFFECT */
.scanner-active-ring {
  box-shadow: 0 0 0 3px rgba(0, 255, 135, 0.4), 0 0 25px rgba(0, 255, 135, 0.2);
  border-color: var(--emerald-neon) !important;
}

/* CHIPS DE SERIAIS */
.serial-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 0.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: #fff;
  animation: slideUpScale 0.2s ease-out;
}
.serial-chip button {
  color: #94a3b8;
  cursor: pointer;
  border-radius: 9999px;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}
.serial-chip button:hover { color: #f87171; background: rgba(239, 68, 68, 0.2); }

/* LEAFLET DARK EMERALD THEME */
.leaflet-container {
  background: #060907 !important;
  font-family: inherit;
}
.leaflet-popup-content-wrapper {
  background: #090e0b !important;
  color: #fff !important;
  border: 1px solid rgba(16, 185, 129, 0.4) !important;
  border-radius: 0.9rem !important;
  box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.9), 0 0 20px rgba(0, 255, 135, 0.2) !important;
}
.leaflet-popup-tip {
  background: #090e0b !important;
  border: 1px solid rgba(16, 185, 129, 0.4) !important;
}
.leaflet-popup-content {
  margin: 10px 12px !important;
  line-height: 1.4 !important;
}
.leaflet-control-zoom a {
  background: #0d130f !important;
  color: #fff !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}
.leaflet-control-zoom a:hover {
  background: #16241c !important;
  color: #00ff87 !important;
}

/* VECTOR MAP BAHIA SILHOUETTE GLOW */
.bahia-vector-path {
  filter: drop-shadow(0 0 12px rgba(0, 255, 135, 0.45));
}
.leaflet-interactive.bahia-vector-outline {
  stroke-dasharray: none;
  filter: drop-shadow(0 0 8px rgba(0, 255, 135, 0.5));
}

@media print { .no-print { display: none !important; } }
