/* =============================================
   assets/css/admin.css — Layout do painel administrativo
   Adaptado de formularios.cy3.com.br para CY3 CRM
   ============================================= */

/* --- Layout principal: sidebar + conteúdo --- */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: linear-gradient(160deg, #1E1E2E 0%, #2D2B55 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
}

/* Logo no topo da sidebar */
.sidebar-logo {
  padding: 28px 24px 20px;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo span { color: var(--primary); }

/* Itens de navegação */
.sidebar-nav { flex: 1; padding: 16px 0; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: rgba(255,255,255,.65);
  font-size: .9rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(108,99,255,.18);
  color: #fff;
  border-left-color: var(--primary);
  text-decoration: none;
}
.sidebar-nav a svg { opacity: .7; width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-nav a.active svg { opacity: 1; }

/* Rodapé da sidebar: info do admin */
.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: .8rem;
  color: rgba(255,255,255,.45);
}
.sidebar-footer a { color: var(--secondary); }

/* --- Conteúdo principal --- */
.admin-content {
  flex: 1;
  margin-left: 240px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Topbar */
.admin-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 8px rgba(0,0,0,.05);
}
.admin-topbar h1 {
  font-size: 1.25rem;
  font-weight: 700;
}
.topbar-actions { display: flex; gap: 10px; align-items: center; }

/* Área de conteúdo */
.admin-body {
  padding: 32px;
  flex: 1;
}

/* --- Tabela --- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: .9rem;
}
thead th {
  padding: 14px 18px;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

/* --- Cards de stats no dashboard --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat-card .stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 8px;
}
.stat-card .stat-value { font-size: 2rem; font-weight: 800; }
.stat-card .stat-label { font-size: .8rem; color: var(--text-muted); font-weight: 600; }

/* --- Cliente Detail View --- */
.cliente-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 24px;
}
.cliente-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.cliente-section h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}
.cliente-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cliente-info-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.cliente-info-item:last-child {
  border-bottom: none;
}
.cliente-info-label {
  font-weight: 600;
  color: var(--text-muted);
}
.cliente-info-value {
  color: var(--text);
}

/* --- Lista de Pedidos/Assinaturas --- */
.lista-item {
  background: var(--surface2);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.lista-item:last-child {
  margin-bottom: 0;
}
.lista-item-info h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.lista-item-info p {
  font-size: .875rem;
  color: var(--text-muted);
}
.lista-item-valor {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}

/* --- Botões de ação --- */
.action-buttons {
  display: flex;
  gap: 8px;
}
.btn-icon {
  background: var(--surface2);
  border: none;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover {
  background: var(--primary);
  color: #fff;
}

/* --- Página de login --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1E1E2E 0%, #2D2B55 60%, #6C63FF 100%);
}
.login-card {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 44px 40px;
  width: 100%;
  max-width: 400px;
}
.login-card .login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-card .login-logo h1 {
  font-size: 2rem; font-weight: 900;
  color: var(--primary);
  letter-spacing: -.04em;
}
.login-card .login-logo p { font-size: .85rem; color: var(--text-muted); margin-top: 4px; }

/* --- Loading Spinner --- */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255,255,255,.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s ease-in-out infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Destaque de Novos Registros --- */
.novo-registro {
  animation: highlightRegistro 5s ease-out;
  position: relative;
  border-left: 4px solid #F59E0B;
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.1) 0%, rgba(245, 158, 11, 0.05) 50%, transparent 100%);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

.novo-registro::before {
  content: '✨ NOVO';
  position: absolute;
  top: 8px;
  right: 8px;
  background: linear-gradient(135deg, #FCD34D, #F59E0B);
  color: #7C2D12;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  z-index: 10;
  animation: pulseBadge 5s ease-out;
  box-shadow: 0 2px 4px rgba(245, 158, 11, 0.3);
}

@keyframes highlightRegistro {
  0% { 
    background: linear-gradient(90deg, rgba(252, 211, 77, 0.3) 0%, rgba(252, 211, 77, 0.15) 50%, rgba(252, 211, 77, 0.05) 100%);
    border-left: 4px solid #F59E0B;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
  }
  50% { 
    background: linear-gradient(90deg, rgba(252, 211, 77, 0.2) 0%, rgba(252, 211, 77, 0.1) 50%, rgba(252, 211, 77, 0.02) 100%);
    border-left: 3px solid #F59E0B;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.2);
  }
  100% { 
    background: transparent;
    border-left: none;
    box-shadow: none;
  }
}

@keyframes pulseBadge {
  0% { 
    opacity: 1;
    transform: scale(1);
  }
  25% { 
    opacity: 1;
    transform: scale(1.05);
  }
  75% { 
    opacity: 0.8;
    transform: scale(1);
  }
  100% { 
    opacity: 0;
    transform: scale(0.9);
  }
}

/* --- Responsivo admin (mobile: topbar hamburger) --- */
.sidebar-toggle { display: none; background: none; border: none; cursor: pointer; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .admin-content { margin-left: 0; }
  .admin-body { padding: 20px 14px; }
  .sidebar-toggle { display: flex; }
  
  .cliente-detail {
    grid-template-columns: 1fr;
  }
  
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  /* Overlay para fechar a sidebar */
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
  }
  .sidebar-overlay.open { display: block; }
}
