/* assets/css/style.css — tema profissional e moderno */

/* ===== Reset & base ===== */
*, *::before, *::after { box-sizing: border-box; }

:root {
  /* Paleta sofisticada */
  --bg: #f3f4f6;           /* cinza muito claro */
  --panel: #ffffff;
  --text: #1f2937;         /* cinza escuro */
  --text-muted: #6b7280;   /* cinza médio */
  
  /* Cores de destaque */
  --primary: #2563eb;      /* azul vibrante */
  --primary-hover: #1d4ed8;
  --success: #10b981;      /* verde esmeralda */
  --danger: #ef4444;       /* vermelho suave */
  --warning: #f59e0b;      /* âmbar */
  
  /* Bordas e Sombras */
  --border: #e5e7eb;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --radius: 8px;
  
  /* Dimensões */
  --h-input: 42px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 16px; /* Padrão legível */
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.container {
  max-width: 1024px;
  margin: 40px auto;
  padding: 0 20px;
}

/* Centralização para Login (se container tiver apenas form) */
body:has(#form-login) {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #f0f2f5;
}
body:has(#form-login) .container {
  width: 100%;
  max-width: 400px;
  margin: 0;
}
body:has(#form-login) .title {
  text-align: center;
  margin-bottom: 32px;
  color: var(--primary);
}

/* Tipografia */
h1, h2, h3 { margin: 0; font-weight: 600; color: var(--text); }
.title { font-size: 24px; margin-bottom: 24px; letter-spacing: -0.025em; }
.text-sm { font-size: 0.875rem; }
.text-muted { color: var(--text-muted); }

/* Header & Cards */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  background: var(--panel);
  padding: 16px 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.header-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary);
}

.header .right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.list-header h2 { margin: 0; border: none; padding: 0; font-size: 1.25rem; }

.list-search-bar {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.list-search-bar input[type="search"] { 
  width: 100%; 
  max-width: 100%; 
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  padding-left: 40px;
}

.card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 24px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover {
  box-shadow: var(--shadow-md);
}

.card h2 {
  font-size: 1.25rem;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  color: var(--primary);
}

/* Formulários */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 0.95rem; font-weight: 500; margin-bottom: 6px; }

input[type="text"],
input[type="password"],
input[type="tel"],
input[type="search"] {
  width: 100%;
  height: var(--h-input);
  padding: 0 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 1rem; /* 16px evita zoom no iOS */
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Grid System */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  height: var(--h-input);
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  background: #fff;
  color: var(--text);
  border-color: #d1d5db;
  text-decoration: none; /* Remove sublinhado de links */
}

.btn:hover { background-color: #f9fafb; border-color: #9ca3af; }

.btn.primary {
  background-color: var(--primary);
  color: white;
  border-color: transparent;
}
.btn.primary:hover { background-color: var(--primary-hover); }

.btn.danger {
  background-color: var(--danger);
  color: white;
  border-color: transparent;
}
.btn.danger:hover { filter: brightness(0.9); }

.btn.small {
  height: 32px;
  padding: 0 12px;
  font-size: 0.8rem;
}

/* Tabelas */
.table-responsive {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  font-size: 0.95rem;
}

.table th {
  background: #f9fafb;
  text-align: left;
  padding: 14px 24px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table td {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background-color: #f9fafb; }

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge.on { background-color: #d1fae5; color: #065f46; }
.badge.off { background-color: #f3f4f6; color: #374151; }

/* Paginação */
.pagination { display: flex; gap: 6px; margin-top: 20px; justify-content: flex-end; }
.page {
  min-width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.875rem;
}
.page.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Alertas (Toasts) */
#alerts {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none; /* permite clicar embaixo */
}

.alert {
  pointer-events: auto;
  padding: 16px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  min-width: 300px;
  animation: slideIn 0.3s cubic-bezier(0.2, 0, 0.2, 1);
  background: white; /* fallback */
  border-left: 4px solid transparent;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateY(-10px); }
}

.alert.closing {
  animation: fadeOut 0.3s forwards;
}

.alert.info { background: #fff; border-left-color: var(--primary); color: var(--text); }
.alert.error { background: #fff; border-left-color: var(--danger); color: var(--text); }
.alert.success { background: #fff; border-left-color: var(--success); color: var(--text); }
.alert.warning { background: #fff; border-left-color: var(--warning); color: var(--text); }

/* Ícones nos alertas (pseudo-elements) */
.alert::before {
  margin-right: 12px;
  font-size: 1.2rem;
}
.alert.info::before { content: 'ℹ️'; }
.alert.error::before { content: '⚠️'; }
.alert.success::before { content: '✅'; }
.alert.warning::before { content: '⚡'; }

/* Ações na Tabela */
.actions { display: flex; gap: 8px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}
.modal-overlay:not(.hidden) {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: white;
  width: 100%; max-width: 480px;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  margin: 16px;
  transform: scale(0.95);
  opacity: 0;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s;
}

.modal-overlay:not(.hidden) .modal {
  transform: scale(1);
  opacity: 1;
}

.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 1.1rem; }
.modal-body { padding: 24px; }
.modal-actions {
  padding: 20px 24px;
  background: #f9fafb;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 12px;
}

/* Utilitários */
.hidden { display: none !important; }

/* Estado de saída para animação do modal */
.modal-overlay.hiding {
  opacity: 0 !important;
  visibility: hidden !important;
}
.modal-overlay.hiding .modal {
  transform: scale(0.95) !important;
  opacity: 0 !important;
}

.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.ml-8 { margin-left: 8px; }
.muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.small { font-size: 0.85rem; }
.small2 { font-size: 0.75rem; }

/* Inputs Disabled */
input:disabled, button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: #f3f4f6;
}

/* Estilos para Página de Perfil (Profile) */
.profile-card {
  text-align: center;
  padding: 40px 24px;
  max-width: 400px;
  margin: 40px auto;
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.profile-avatar {
  width: 80px;
  height: 80px;
  background: #eff6ff;
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  margin: 0 auto 24px;
}

.profile-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 32px;
}

.btn-large {
  width: 100%;
  height: 56px;
  font-size: 1.1rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: 12px;
}

.btn-large i { font-size: 1.4rem; }
.btn-whatsapp { background-color: #25D366; color: white; border: none; }
.btn-whatsapp:hover { background-color: #128C7E; }

.btn-call { background-color: var(--primary); color: white; border: none; }
.btn-call:hover { background-color: var(--primary-hover); }

/* Footer */
.footer-info {
  text-align: center;
  margin-top: 40px;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.footer-info a { color: var(--text-muted); text-decoration: none; }
.footer-info a:hover { color: var(--primary); }

/* Responsividade Mobile Tabela */
@media (max-width: 640px) {
  .table thead { display: none; }
  .table tr { display: block; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; padding: 12px; background: white; }
  .table td { display: flex; justify-content: space-between; padding: 8px 0; border: none; font-size: 0.9rem; }
  .table td::before { content: attr(data-label); font-weight: 600; color: var(--text-muted); margin-right: 12px; }
  .actions { width: 100%; justify-content: flex-end; margin-top: 8px; }
}

/* URLs Grid */
.urls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.btn-url {
  width: 100%;
  justify-content: center;
}
.mb-4 { margin-bottom: 16px; }
