/* ============================================
   New Pet-Cam SaaS - Estilos Globais
   ============================================ */

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

:root {
  --bg-escuro: #0f172a; --bg-escuro-2: #1e293b; --bg-escuro-3: #334155;
  --primario: #3b82f6; --primario-hover: #2563eb; --secundario: #8b5cf6;
  --sucesso: #10b981; --perigo: #ef4444; --aviso: #f59e0b;
  --texto: #f1f5f9; --texto-secundario: #94a3b8; --borda: #475569;
  --sombra: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-escuro); color: var(--texto); min-height: 100vh; line-height: 1.6;
}

.container { max-width: 1200px; margin: 0 auto; padding: 20px; }
h1, h2, h3, h4 { color: var(--texto); font-weight: 600; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.5rem; } h3 { font-size: 1.25rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border: none; border-radius: 8px; font-size: 0.95rem;
  font-weight: 500; cursor: pointer; transition: all 0.2s; text-decoration: none; color: inherit;
}
.btn-primario { background: var(--primario); color: white; }
.btn-primario:hover { background: var(--primario-hover); transform: translateY(-1px); }
.btn-secundario { background: var(--bg-escuro-3); color: var(--texto); }
.btn-secundario:hover { background: #475569; }
.btn-sucesso { background: var(--sucesso); color: white; }
.btn-perigo { background: var(--perigo); color: white; }

.btn-icone {
  padding: 8px; border-radius: 6px; background: transparent;
  border: 1px solid var(--borda); color: var(--texto-secundario);
  cursor: pointer; transition: all 0.2s;
}
.btn-icone:hover { background: var(--bg-escuro-3); color: var(--texto); }
.btn-icone.editar:hover { color: var(--primario); border-color: var(--primario); }
.btn-icone.excluir:hover { color: var(--perigo); border-color: var(--perigo); }

.form-grupo { margin-bottom: 18px; }
.form-grupo label { display: block; margin-bottom: 6px; font-weight: 500; color: var(--texto); font-size: 0.9rem; }
.form-grupo input, .form-grupo textarea, .form-grupo select {
  width: 100%; padding: 12px 14px; background: var(--bg-escuro-2);
  border: 1px solid var(--borda); border-radius: 8px; color: var(--texto);
  font-size: 0.95rem; transition: border-color 0.2s, box-shadow 0.2s;
}
.form-grupo input:focus, .form-grupo textarea:focus {
  outline: none; border-color: var(--primario);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.form-grupo input::placeholder { color: var(--texto-secundario); }
.form-grupo input:disabled { opacity: 0.5; cursor: not-allowed; }

.erro-campo { color: var(--perigo); font-size: 0.82rem; margin-top: 5px; display: block; }
.input-erro { border-color: var(--perigo) !important; }

.card {
  background: var(--bg-escuro-2); border: 1px solid var(--borda);
  border-radius: 12px; padding: 20px; box-shadow: var(--sombra);
}

.tabela {
  width: 100%; border-collapse: collapse; background: var(--bg-escuro-2);
  border-radius: 10px; overflow: hidden;
}
.tabela th, .tabela td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--borda); }
.tabela th {
  background: var(--bg-escuro-3); font-weight: 600; font-size: 0.85rem;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--texto-secundario);
}
.tabela tr:last-child td { border-bottom: none; }
.tabela tr:hover td { background: rgba(59,130,246,0.05); }

.badge {
  display: inline-block; padding: 4px 10px; border-radius: 20px;
  font-size: 0.78rem; font-weight: 500;
}
.badge-ativo { background: rgba(16,185,129,0.15); color: var(--sucesso); }
.badge-expirado { background: rgba(239,68,68,0.15); color: var(--perigo); }
.badge-pendente { background: rgba(245,158,11,0.15); color: var(--aviso); }

.abas {
  display: flex; gap: 4px; border-bottom: 2px solid var(--borda);
  margin-bottom: 24px; flex-wrap: wrap; overflow-x: auto;
}
.aba {
  padding: 12px 18px; background: none; border: none; color: var(--texto-secundario);
  font-size: 0.92rem; font-weight: 500; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; white-space: nowrap;
}
.aba:hover { color: var(--texto); }
.aba.ativa { color: var(--primario); border-bottom-color: var(--primario); }

.conteudo-aba { display: none; }
.conteudo-aba.ativo { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform: translateY(0); } }

.modal-fundo {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.7); z-index: 1000; align-items: center; justify-content: center; padding: 20px;
}
.modal-fundo.aberto { display: flex; }
.modal {
  background: var(--bg-escuro-2); border: 1px solid var(--borda); border-radius: 14px;
  width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto;
  animation: modalSlideIn 0.3s ease;
}
@keyframes modalSlideIn { from { opacity:0; transform: translateY(-20px); } to { opacity:1; transform: translateY(0); } }
.modal-cabecalho {
  padding: 20px; border-bottom: 1px solid var(--borda);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-corpo { padding: 20px; }
.modal-rodape {
  padding: 16px 20px; border-top: 1px solid var(--borda);
  display: flex; gap: 10px; justify-content: flex-end;
}

.grid-cameras {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px; margin-top: 8px;
}
.camera-card {
  background: var(--bg-escuro-3); border: 2px solid var(--borda); border-radius: 10px;
  padding: 16px; cursor: pointer; transition: all 0.2s; text-align: center;
}
.camera-card:hover { border-color: var(--primario); transform: translateY(-2px); }
.camera-card.selecionada { border-color: var(--primario); background: rgba(59,130,246,0.15); }
.camera-card .camera-icone { font-size: 2rem; margin-bottom: 8px; color: var(--texto-secundario); }
.camera-card.selecionada .camera-icone { color: var(--primario); }
.camera-card .camera-nome { font-weight: 500; font-size: 0.95rem; }
.camera-card .camera-check { margin-top: 8px; font-size: 0.8rem; color: var(--primario); opacity: 0; }
.camera-card.selecionada .camera-check { opacity: 1; }

.cabecalho {
  background: var(--bg-escuro-2); border-bottom: 1px solid var(--borda);
  padding: 16px 24px; display: flex; justify-content: space-between;
  align-items: center; position: sticky; top: 0; z-index: 100;
}
.cabecalho-esquerda { display: flex; align-items: center; gap: 12px; font-size: 1.2rem; }
.logo {
  font-size: 1.3rem; font-weight: 700;
  background: linear-gradient(135deg, var(--primario), var(--secundario));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.cabecalho-direita { display: flex; align-items: center; gap: 12px; }
.usuario-info { color: var(--texto-secundario); font-size: 0.9rem; }

.link-gerado {
  background: var(--bg-escuro); border: 1px solid var(--borda);
  border-radius: 10px; padding: 16px; margin-top: 20px;
}
.link-gerado .link-texto {
  background: var(--bg-escuro-3); padding: 12px; border-radius: 8px;
  font-family: monospace; font-size: 0.85rem; word-break: break-all;
  margin-bottom: 12px; color: var(--primario);
}
.link-gerado .link-acoes { display: flex; gap: 10px; flex-wrap: wrap; }
.link-info { margin-top: 12px; font-size: 0.85rem; color: var(--texto-secundario); }

.barra-ferramentas {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.campo-busca { position: relative; flex: 1; max-width: 300px; }
.campo-busca input {
  width: 100%; padding: 10px 14px 10px 38px;
  background: var(--bg-escuro-2); border: 1px solid var(--borda);
  border-radius: 8px; color: var(--texto);
}
.campo-busca::before {
  content: '🔍'; position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%); opacity: 0.5;
}

.player-container {
  background: #000; border-radius: 12px; overflow: hidden;
  aspect-ratio: 16 / 9; position: relative;
}
.player-container video { width: 100%; height: 100%; object-fit: contain; }
.player-offline {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; color: var(--texto-secundario); text-align: center; padding: 20px;
}
.player-offline .icone-offline { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }

.info-acesso {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.info-item {
  background: var(--bg-escuro-2); padding: 14px; border-radius: 10px;
  border-left: 3px solid var(--primario);
}
.info-item .info-label {
  font-size: 0.78rem; color: var(--texto-secundario);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px;
}
.info-item .info-valor { font-weight: 500; font-size: 1rem; }

.players-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 20px;
}
.player-wrapper {
  background: var(--bg-escuro-2); border-radius: 12px; padding: 12px; border: 1px solid var(--borda);
}
.player-wrapper .player-titulo {
  font-weight: 500; margin-bottom: 10px; padding-left: 8px;
  border-left: 3px solid var(--primario);
}

.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.text-center { text-align: center; } .text-muted { color: var(--texto-secundario); }
.w-100 { width: 100%; }

.toast {
  position: fixed; top: 20px; right: 20px; padding: 14px 20px;
  border-radius: 10px; color: white; font-weight: 500; z-index: 2000;
  animation: toastSlide 0.3s ease; box-shadow: var(--sombra);
}
.toast-sucesso { background: var(--sucesso); }
.toast-erro { background: var(--perigo); }
.toast-aviso { background: var(--aviso); }
@keyframes toastSlide { from { opacity:0; transform: translateX(100px); } to { opacity:1; transform: translateX(0); } }

.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 3px solid rgba(255,255,255,0.3); border-radius: 50%;
  border-top-color: white; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

code {
  background: var(--bg-escuro); padding: 3px 8px;
  border-radius: 4px; font-size: 0.85rem;
}

hr { border: none; border-top: 1px solid var(--borda); margin: 20px 0; }

@media (max-width: 768px) {
  .cabecalho { flex-direction: column; gap: 12px; padding: 12px 16px; }
  .players-grid { grid-template-columns: 1fr; }
  .tabela { display: block; overflow-x: auto; }
  .barra-ferramentas { flex-direction: column; align-items: stretch; }
  .campo-busca { max-width: 100%; }
}
