/* ===== Wine Web • Modern Theme ===== */
:root {
  /* Cores principais */
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-700: #1e40af;
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  
  /* Cores neutras */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  
  /* Cores de fundo */
  --bg-primary: #ffffff;
  --bg-secondary: var(--gray-50);
  --bg-tertiary: var(--gray-100);
  
  /* Cores de texto */
  --text-primary: var(--gray-900);
  --text-secondary: var(--gray-600);
  --text-muted: var(--gray-500);
  
  /* Cores de borda */
  --border-light: var(--gray-200);
  --border-medium: var(--gray-300);
  
  /* Sombras */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  /* Dimensões */
  --sidebar-w: 280px;
  --header-h: 64px;
  --border-radius: 8px;
  --border-radius-lg: 12px;
  --border-radius-xl: 16px;
  
  /* Transições */
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset e base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

/* Layout principal */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-primary);
  border-right: 1px solid var(--border-light);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  padding: 0 24px;
  box-shadow: var(--shadow-sm);
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 0 20px;
  border-bottom: 1px solid var(--border-light);
}

.brand .logo {
  width: 32px;
  height: 32px;
  border-radius: var(--border-radius);
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
}

.brand .name {
  font-weight: 700;
  font-size: 18px;
  color: var(--text-primary);
  letter-spacing: -0.025em;
}

/* Menu de navegação */
.menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--border-radius);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 14px;
  transition: var(--transition);
  position: relative;
}

.menu a:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.menu a.active {
  background: var(--primary-50);
  color: var(--primary);
  font-weight: 600;
}

.menu a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

/* User box */
.userbox {
  margin-top: auto;
  border-top: 1px solid var(--border-light);
  padding-top: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.userbox .avatar {
  width: 40px;
  height: 40px;
  position: relative;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-weight: 600;
  color: white;
  font-size: 16px;
}

.userbox .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.userbox .avatar span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.userbox .info {
  flex: 1;
  min-width: 0;
}

.userbox .name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.userbox .status {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.userbox .sysinfo {
  margin-top: 6px;
  line-height: 1.3;
}

.userbox .actions {
  margin-left: auto;
}

/* Conteúdo */
.content {
  flex: 1;
  padding: 32px 24px;
}

.content-inner {
  max-width: 100%;
  margin: 0 auto;
}

/* Componentes */
.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.card h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.card p {
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Tabelas */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--bg-primary);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-responsive {
  overflow-x: auto;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
}

.table th,
.table td {
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.table th {
  background: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table td {
  color: var(--text-secondary);
}

.table tbody tr:hover {
  background: var(--bg-tertiary);
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--border-radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-600);
  border-color: var(--primary-600);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.btn-outline:hover:not(:disabled) {
  background: var(--bg-tertiary);
  border-color: var(--gray-400);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 20px;
  font-size: 16px;
}

/* Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Grid system */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 24px;
}

@media (max-width: 1024px) {
  .grid {
    grid-template-columns: repeat(8, 1fr);
  }
}

@media (max-width: 768px) {
  .grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-6 { grid-column: span 6; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }

/* Página de login */
.page-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--primary-50), var(--bg-secondary));
}

.auth-card {
  width: min(400px, 100%);
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-xl);
}

.brand-login {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}

.brand-login .logo {
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius);
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 16px;
}

.brand-login .title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.brand-login .subtitle {
  color: var(--text-muted);
  font-size: 14px;
}

/* Formulários */
label {
  display: block;
  margin: 16px 0 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.field {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--border-radius);
  padding: 12px 16px;
  transition: var(--transition);
}

.field:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-100);
}

.field input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
}

.field input::placeholder {
  color: var(--text-muted);
}

.toggle {
  cursor: pointer;
  font-size: 12px;
  color: var(--primary);
  font-weight: 500;
  transition: var(--transition);
}

.toggle:hover {
  color: var(--primary-600);
}

.error {
  background: #fef2f2;
  color: #dc2626;
  padding: 12px 16px;
  border: 1px solid #fecaca;
  border-radius: var(--border-radius);
  margin: 8px 0 16px;
  font-size: 14px;
}

.foot {
  margin-top: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* Botão burger - oculto por padrão */
.burger {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border-medium);
  border-radius: var(--border-radius);
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}

.burger:hover {
  background: var(--bg-tertiary);
}

/* Scrim - oculto por padrão */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  z-index: 90;
}

.scrim.show {
  display: block;
}

/* Mobile responsivo */
@media (max-width: 1024px) {
  .topbar .title { display:none; }
  .topbar .chip { display:none; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .main {
    margin-left: 0;
  }
  
  .burger {
    display: inline-flex;
  }
  
  .content {
    padding: 24px 16px;
  }
  
  .topbar {
    padding: 0 12px;
  }
}

@media (max-width: 640px) {
  .auth-card {
    padding: 24px;
  }
  
  .brand-login {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }
  
  .grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .span-12, .span-8, .span-6, .span-4, .span-3 {
    grid-column: span 1;
  }
}

/* Utilitários */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-secondary { color: var(--text-secondary); }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.font-bold { font-weight: 700; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.mb-6 { margin-bottom: 24px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 20px; }
.mt-6 { margin-top: 24px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

/* ===================== */
/* Form elements (globais)
   Deixa inputs/selects/textarea e checkboxes com visual moderno
   sem depender de classes extras nos formulários existentes. */

/* Campos de texto, datas, selects e textarea */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="password"],
select,
textarea {
  width: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--border-radius);
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.4;
  transition: var(--transition);
  box-shadow: 0 0 0 0 transparent;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="date"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-100);
}

/* Placeholder mais sutil */
input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

/* Alinhamento mais elegante quando input está dentro do label */
label > input,
label > select,
label > textarea {
  margin-top: 6px;
}

/* Checkboxes modernos com accent-color (suporte amplo) */
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  border-radius: 4px;
  vertical-align: middle;
}

/* Espaço entre o checkbox e o texto quando dentro de label */
label > input[type="checkbox"] {
  margin-right: 8px;
  margin-top: 0;
}

/* Estados desabilitados */
input:disabled,
select:disabled,
textarea:disabled {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* Badges para permissões */
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
}

.badge-primary {
  background-color: var(--primary);
  color: white;
}

.badge-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-muted);
}

/* Estilo para módulos de configuração */
.module-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  transition: var(--transition);
}

.module-item:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Estilo para abas */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab-btn {
  background: none;
  border: none;
  padding: 12px 24px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-weight: 500;
  transition: var(--transition);
}

.tab-btn:hover {
  color: var(--text);
  background: var(--bg-secondary);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--bg-secondary);
}