/* ==========================================================================
   FARMA - DESIGN SYSTEM SOBERANO & ESTILOS GLOBAIS
   Rede Georreferenciada de Farmácias, Hospitais & Amostragem Médica
   ========================================================================== */

:root {
  --bg-main: #061114;
  --bg-card: #0b1a1f;
  --bg-card-hover: #10242b;
  --bg-subtle: #142e37;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(16, 185, 129, 0.35);

  --text-main: #f0fdf4;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-emerald: #10b981;
  --accent-teal: #14b8a6;
  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  background-image: 
    radial-gradient(circle at 10% 5%, rgba(16, 185, 129, 0.15) 0%, transparent 45%),
    radial-gradient(circle at 90% 90%, rgba(6, 182, 212, 0.12) 0%, transparent 45%);
  background-attachment: fixed;
}

/* ================= TOPBAR & ECOSYSTEM NAVIGATION ================= */
.farma-navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  background: rgba(6, 17, 20, 0.88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.farma-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.farma-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.farma-brand h1 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.farma-brand p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.farma-nav-links {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.nav-link-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-glow);
  transform: translateY(-1px);
}

.nav-link-btn.active {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.4);
}

/* ================= CONTAINER PRINCIPAL ================= */
.farma-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ================= BARRA DE LOCALIZAÇÃO GEORREFERENCIADA ================= */
.location-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  margin-bottom: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.location-info-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
}

.geo-pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 12px var(--accent-emerald);
  display: inline-block;
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.geo-coords {
  font-size: 0.75rem;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

/* ================= SELETOR DE ABAS PRINCIPAIS ================= */
.farma-tabs-bar {
  display: flex;
  gap: 8px;
  background: rgba(11, 26, 31, 0.7);
  padding: 6px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
  overflow-x: auto;
}

.farma-tab-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.farma-tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.farma-tab-btn.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25) 0%, rgba(6, 182, 212, 0.2) 100%);
  color: #fff;
  border: 1px solid rgba(16, 185, 129, 0.4);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ================= FILTROS E PESQUISA DE UNIDADES ================= */
.search-filter-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.search-bar-wrap {
  position: relative;
}

.search-input {
  width: 100%;
  padding: 14px 20px 14px 46px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.categories-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.category-filters-wrap {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.category-filter-btn {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.category-filter-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.category-filter-btn.active {
  background: rgba(16, 185, 129, 0.18);
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.4);
}

/* ================= GRID DE CARDS DAS UNIDADES ================= */
.units-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 22px;
}

.unit-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, border-color 0.2s ease;
  position: relative;
}

.unit-card:hover {
  border-color: var(--border-glow);
  transform: translateY(-2px);
  background: var(--bg-card-hover);
}

.unit-card.destaque {
  border-top: 3px solid var(--accent-emerald);
}

.unit-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.unit-id-badge {
  background: rgba(0, 0, 0, 0.4);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--accent-teal);
  border: 1px solid rgba(20, 184, 166, 0.3);
}

.unit-status-tag {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-weight: 700;
}

.unit-status-tag.open {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.unit-status-tag.closed {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.35);
}

.unit-type-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.unit-name {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.35;
}

.unit-subtitle {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.unit-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  font-size: 0.85rem;
}

.unit-rating b {
  color: #fcd34d;
}

.unit-distance b {
  color: var(--accent-emerald);
}

.unit-address, .unit-hours {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.4;
}

.unit-capacity-box {
  background: rgba(16, 185, 129, 0.08);
  border: 1px dashed rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin: 14px 0;
  font-size: 0.8rem;
}

.unit-capacity-box small {
  color: var(--accent-emerald);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.unit-capacity-box p {
  color: #e2e8f0;
  margin-top: 2px;
}

.unit-card-footer {
  display: flex;
  gap: 10px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
}

.btn-route {
  flex: 1;
}

/* ================= TABELA DE AMOSTRAS MÉDICAS ================= */
.table-responsive {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  margin-bottom: 24px;
}

.samples-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.samples-table th {
  background: rgba(0, 0, 0, 0.3);
  padding: 14px 18px;
  text-align: left;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.samples-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.samples-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.sample-id-badge {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
}

.stock-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.78rem;
}

.stock-pill.in-stock {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.stock-pill.out-of-stock {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
}

/* ================= HISTÓRICO DE REQUISIÇÕES ================= */
.requisitions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.requisition-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 0.85rem;
}

.req-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed var(--border-color);
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.tag-patient {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  padding: 2px 6px;
  border-radius: 4px;
}

/* ================= BOTÕES & FORMS ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  text-decoration: none;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 0.8rem;
}

.btn-xs {
  padding: 4px 10px;
  font-size: 0.75rem;
}

.btn-primary {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--border-glow);
}

.btn-outline-action {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: var(--accent-emerald);
}

.btn-outline-action:hover {
  background: rgba(16, 185, 129, 0.2);
}

/* ================= MODAL ================= */
dialog {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 540px;
  width: 90%;
  margin: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-control {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 0.88rem;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* ================= SPINNER ================= */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ================= RESPONSIVIDADE ================= */
@media (max-width: 768px) {
  .farma-navbar {
    padding: 12px 16px;
    flex-direction: column;
    gap: 12px;
  }
  .units-grid {
    grid-template-columns: 1fr;
  }
  .location-status-bar {
    flex-direction: column;
    align-items: flex-start;
  }
}
