/* ============================================================
   ALIANÇAS CS — DESIGN SYSTEM
   Sistema de Gestão de Produção
   ============================================================ */

:root {
  /* ===================== CORES PRINCIPAIS ===================== */
  --primary-color: #0f172a;
  --primary-hover: #1e293b;
  --accent-gold: #d97706;
  --accent-gold-hover: #b45309;

  /* ===================== BACKGROUNDS ===================== */
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-hover: #f1f5f9;
  --bg-active: #eff6ff;

  /* ===================== BORDAS ===================== */
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  --border-strong: #cbd5e1;

  /* ===================== TEXTO ===================== */
  --text-main: #334155;
  --text-strong: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;

  /* ===================== STATUS ===================== */
  --status-novo-bg: #dbeafe; --status-novo-text: #1e40af;
  --status-etiqueta-bg: #fef3c7; --status-etiqueta-text: #92400e;
  --status-producao-bg: #ffedd5; --status-producao-text: #9a3412;
  --status-concluido-bg: #dcfce7; --status-concluido-text: #166534;
  --status-atrasado-bg: #fee2e2; --status-atrasado-text: #991b1b;

  /* ===================== FONTES ===================== */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Fraunces', Georgia, serif;

  /* ===================== SOMBRAS ===================== */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.1), 0 4px 8px rgba(15, 23, 42, 0.05);

  /* ===================== RAIOS ===================== */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  /* ===================== TRANSIÇÕES ===================== */
  --transition-fast: 0.15s ease;
  --transition: 0.2s ease;
  --transition-slow: 0.3s ease;
  --theme-transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

/* ============================================================
   RESET E BASE
   ============================================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: var(--theme-transition);
}

/* Scrollbar customizada */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
  border: 2px solid var(--bg-main);
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
body.dark-mode ::-webkit-scrollbar-thumb {
  background: #475569;
  border-color: var(--bg-main);
}

/* ============================================================
   UTILITÁRIOS
   ============================================================ */
.hidden { display: none !important; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.text-muted { color: var(--text-muted); }
.text-danger { color: #dc2626; }
.text-success { color: #16a34a; }
.font-bold { font-weight: 700; }

.p-0 { padding: 0 !important; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-3 { margin-top: 1rem; }
.max-w-600 { max-width: 600px; }

/* ============================================================
   LAYOUT PRINCIPAL
   ============================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: 260px;
  background: linear-gradient(180deg, #0a0f1e 0%, #0f172a 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform var(--transition-slow);
  box-shadow: 4px 0 24px rgba(15, 23, 42, 0.08);
}

.sidebar-header {
  padding: 22px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 1.5rem;
  color: var(--accent-gold);
  filter: drop-shadow(0 2px 6px rgba(217, 119, 6, 0.35));
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}

/* ============================================================
   NAVEGAÇÃO DA SIDEBAR
   ============================================================ */
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.sidebar-nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group-title {
  padding: 16px 12px 8px;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 700;
  letter-spacing: 1px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: #cbd5e1;
  text-decoration: none;
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition), transform var(--transition-fast);
  font-size: 0.9rem;
  font-weight: 500;
  position: relative;
}

.nav-link i {
  width: 20px;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
  transition: transform var(--transition);
}

.nav-link span {
  flex: 1;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-link:hover i {
  transform: scale(1.1);
}

.nav-link.active {
  background: linear-gradient(90deg, rgba(217, 119, 6, 0.15) 0%, rgba(217, 119, 6, 0.05) 100%);
  color: #fff;
  font-weight: 600;
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent-gold);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 12px rgba(217, 119, 6, 0.6);
}

.nav-link.active i {
  color: var(--accent-gold);
}

/* Badge na sidebar */
.nav-link .badge-pill {
  background: var(--accent-gold);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: auto;
}

/* ============================================================
   FOOTER DA SIDEBAR (USUÁRIO)
   ============================================================ */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: var(--radius);
  transition: background var(--transition);
}

.user-card:hover {
  background: rgba(255, 255, 255, 0.04);
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-gold) 0%, var(--accent-gold-hover) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.3);
}

.user-info {
  flex: 1;
  overflow: hidden;
  min-width: 0;
}

.user-name {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  display: block;
  font-size: 0.7rem;
  color: #64748b;
  text-transform: capitalize;
  font-weight: 500;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  height: 68px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
  transition: var(--theme-transition);
  backdrop-filter: blur(8px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.page-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   INDICADOR SHOPIFY
   ============================================================ */
.status-indicator {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.status-indicator.success {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  color: #065f46;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  display: inline-block;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25); }
  50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.1); }
}

/* ============================================================
   CONTENT CONTAINER
   ============================================================ */
.content-container {
  padding: 28px 32px;
  flex: 1;
  max-width: 100%;
  overflow-x: hidden;
}

.view-page {
  display: none;
  animation: fadeIn 0.2s ease;
}

.view-page.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   RESPONSIVO
   ============================================================ */
.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .mobile-only {
    display: inline-flex;
  }
  .topbar {
    padding: 0 20px;
    height: 60px;
  }
  .page-title {
    font-size: 1.15rem;
  }
  .content-container {
    padding: 20px 16px;
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 90;
  }
  .sidebar-overlay.active {
    display: block;
  }
}

/* ============================================================
   TABELAS
   ============================================================ */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
}

.data-table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table th:first-child {
  border-top-left-radius: var(--radius);
}

.data-table th:last-child {
  border-top-right-radius: var(--radius);
}

.data-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
  vertical-align: middle;
  font-size: 0.875rem;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: var(--radius);
}

.data-table tbody tr:last-child td:last-child {
  border-bottom-right-radius: var(--radius);
}

/* ============================================================
   DARK MODE
   ============================================================ */
body.dark-mode {
  --primary-color: #e2e8f0;
  --primary-hover: #cbd5e1;
  --accent-gold: #f59e0b;
  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --bg-active: #1e3a8a33;
  --border-color: #334155;
  --border-light: #263449;
  --border-strong: #475569;
  --text-main: #e2e8f0;
  --text-strong: #f1f5f9;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;

  --status-novo-bg: #1e3a8a; --status-novo-text: #bfdbfe;
  --status-etiqueta-bg: #78350f; --status-etiqueta-text: #fde68a;
  --status-producao-bg: #7c2d12; --status-producao-text: #fed7aa;
  --status-concluido-bg: #14532d; --status-concluido-text: #bbf7d0;
  --status-atrasado-bg: #7f1d1d; --status-atrasado-text: #fecaca;

  background-color: var(--bg-main);
  color: var(--text-main);
}

/* Topbar, cards, tabelas no modo escuro */
body.dark-mode .topbar {
  background: rgba(30, 41, 59, 0.85);
  border-bottom-color: var(--border-color);
  backdrop-filter: blur(12px);
}

body.dark-mode .page-title {
  color: var(--text-strong);
}

body.dark-mode .card,
body.dark-mode .kpi-card,
body.dark-mode .modal-card,
body.dark-mode .actions-bar,
body.dark-mode .config-actions {
  background-color: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-main);
}

body.dark-mode .card-header {
  border-bottom-color: var(--border-color);
}

body.dark-mode .card-header h3,
body.dark-mode .card-body h4 {
  color: var(--text-strong);
}

body.dark-mode .data-table th {
  background: #0f172a;
  color: #94a3b8;
  border-bottom-color: var(--border-color);
}

body.dark-mode .data-table th,
body.dark-mode .data-table td {
  border-bottom-color: var(--border-color);
  color: var(--text-main);
}

body.dark-mode .data-table tbody tr:hover {
  background: #334155;
}

body.dark-mode .form-control {
  background-color: #0f172a;
  border-color: var(--border-color);
  color: var(--text-main);
}

body.dark-mode .form-control:focus {
  border-color: var(--accent-gold);
}

body.dark-mode .form-group label {
  color: #cbd5e1;
}

body.dark-mode .btn-secondary {
  background: #334155;
  color: #e2e8f0;
}

body.dark-mode .btn-secondary:hover {
  background: #475569;
}

body.dark-mode .item-piece-card {
  background: #1e293b;
  border-color: var(--border-color);
}

body.dark-mode .tag-custom {
  background: #334155;
  color: #e2e8f0;
}

body.dark-mode .callout-info {
  background: #1e3a8a;
  border-color: #1e40af;
  color: #bfdbfe;
}

body.dark-mode .toast {
  background: #1e293b;
  color: #e2e8f0;
  border-left-color: var(--accent-gold);
}

body.dark-mode .timeline::before {
  background: var(--border-color);
}

body.dark-mode .timeline-item::before {
  border-color: #1e293b;
}

body.dark-mode .timeline-date {
  color: var(--text-muted);
}

body.dark-mode .modal-header,
body.dark-mode .modal-footer {
  border-color: var(--border-color);
}

body.dark-mode .modal-header h3 {
  color: var(--text-strong);
}

body.dark-mode .input-icon input {
  background: #0f172a;
  color: var(--text-main);
}

body.dark-mode .sidebar-overlay {
  background: rgba(0, 0, 0, 0.75);
}

body.dark-mode ::-webkit-scrollbar-thumb {
  background: #475569;
}

/* ============================================================
   ANIMAÇÕES
   ============================================================ */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: slideUp 0.3s ease;
}