/* ========== VARIABLES — CLEAN SLATE ========== */
:root {
  --bg-primary: #FFFFFF;
  --bg-secondary: #1E293B;
  --bg-card: #F1F5F9;
  --bg-card-hover: #E2E8F0;
  --bg-input: #F8FAFC;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-light: rgba(37, 99, 235, 0.08);
  --text-primary: #0F172A;
  --text-secondary: #334155;
  --text-muted: #64748B;
  --text-on-dark: #F1F5F9;
  --text-on-dark-muted: #94A3B8;
  --border: #E2E8F0;
  --border-dark: rgba(255, 255, 255, 0.1);
  --success: #16A34A;
  --warning: #D97706;
  --danger: #DC2626;
  --info: #2563EB;
  --sidebar-width: 220px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.1);
}

/* ========== RESET ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
}
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; border: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ========== SIDEBAR (escura) ========== */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
}
.sidebar-logo {
  padding: 24px 20px 16px;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.5px;
}
.sidebar-user {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border-dark);
}
.sidebar-user .user-name { font-size: 13px; color: var(--text-on-dark); font-weight: 600; }
.sidebar-user .user-role { font-size: 11px; color: var(--text-on-dark-muted); }
.sidebar-section {
  padding: 16px 20px 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-on-dark-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.sidebar-nav { flex: 1; padding: 0; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 13px;
  color: var(--text-on-dark-muted);
  transition: all 0.2s;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: var(--text-on-dark); }
.sidebar-nav a.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  border-left-color: var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-right: 12px;
}
.sidebar-nav a .icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-dark);
}
.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-on-dark-muted);
}
.sidebar-footer a:hover { color: var(--danger); }

/* ========== MAIN ========== */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-primary);
}
.view { display: none; padding: 32px; }
#view-viewer { overflow: hidden; }
.view.active { display: block; }
.view-title { font-size: 22px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.view-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 28px; }

/* ========== CATALOGS GRID ========== */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}
.catalog-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.3s;
  box-shadow: var(--shadow-sm);
}
.catalog-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.catalog-card-cover {
  height: 200px;
  background: url('../img/PortoBrasil_1.jpg') center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.catalog-card-body { padding: 16px; }
.catalog-card-body h4 { font-size: 15px; color: var(--text-primary); margin-bottom: 4px; }
.catalog-card-body .brand { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.catalog-card-body .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.catalog-card-body .deadline {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.catalog-card-body .products-count {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}
.btn-primary {
  display: block;
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  text-align: center;
  transition: background 0.2s;
}
.btn-primary:hover { background: var(--accent-hover); }
/* keep .btn-gold as alias */
.btn-gold { display: block; width: 100%; padding: 10px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 700; border-radius: var(--radius-sm); text-align: center; transition: background 0.2s; }
.btn-gold:hover { background: var(--accent-hover); }

/* ========== CATALOG VIEWER ========== */
.viewer-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}
.viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-radius: var(--radius) var(--radius) 0 0;
  flex-wrap: wrap;
  gap: 12px;
}
.viewer-header h2 { font-size: 17px; font-weight: 700; color: var(--text-on-dark); }
.viewer-header .header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.viewer-header .total-label { font-size: 12px; color: var(--text-on-dark-muted); }
.viewer-header .total-value { font-size: 16px; font-weight: 700; color: #fff; }
.btn-outline {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}
.btn-outline:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
/* on dark header */
.viewer-header .btn-outline { border-color: var(--border-dark); color: var(--text-on-dark-muted); }
.viewer-header .btn-outline:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.viewer-body {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 0;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  height: calc(100vh - 160px);
  background: var(--bg-primary);
}
.viewer-catalog {
  padding: 20px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-card);
  overflow: hidden;
}
.viewer-header .page-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}
.viewer-header .page-nav button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.viewer-header .page-nav span { font-size: 13px; color: var(--text-on-dark-muted); }
.viewer-catalog .page-image {
  max-width: 100%;
  max-height: 500px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}
.viewer-catalog .pdf-wrapper {
  width: 100%;
  flex: 1;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  position: relative;
}
.viewer-catalog .page-pdf {
  width: 100%;
  height: calc(100% + 40px);
  border: none;
}
.viewer-body.fullwidth { grid-template-columns: 1fr; }
.viewer-body.fullwidth .viewer-catalog { display: none; }
.viewer-body.fullwidth .product-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.viewer-body.fullwidth .product-item {
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px;
}
.viewer-body.fullwidth .product-item img {
  width: 120px;
  height: 120px;
  margin-bottom: 8px;
}
.viewer-body.fullwidth .product-item .product-name {
  white-space: normal;
}
.viewer-body.fullwidth .product-item .product-info {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.viewer-body.fullwidth .product-item .qty-controls {
  justify-content: center;
}
.btn-layout { font-size: 14px; letter-spacing: 2px; }
.viewer-products { padding: 20px; overflow-y: auto; min-height: 0; }
.viewer-products h3 {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.viewer-products .filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}
.filter-btn {
  padding: 5px 12px;
  font-size: 11px;
  border-radius: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all 0.2s;
}
.filter-btn:hover, .filter-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.product-list { display: flex; flex-direction: column; gap: 12px; }
.product-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}
.product-item:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.product-item img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--border);
}
.product-item .product-info { flex: 1; min-width: 0; }
.product-item .product-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.product-item .product-code { font-size: 10px; color: var(--text-muted); }
.product-item .product-dim { font-size: 10px; color: var(--text-muted); margin-bottom: 6px; }
.product-item .product-price { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.product-item .qty-controls {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: 6px;
}
.qty-btn {
  width: 26px;
  height: 26px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.qty-btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.qty-btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.qty-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.qty-input {
  width: 36px;
  height: 26px;
  text-align: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-left: none;
  border-right: none;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
}
.qty-input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ========== ORDERS TABLE ========== */
.orders-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.orders-table thead { background: var(--bg-card); }
.orders-table th {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.orders-table td {
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}
.orders-table tr:last-child td { border-bottom: none; }
.orders-table tr:hover td { background: var(--accent-light); }
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-success { background: rgba(22,163,74,0.1); color: var(--success); }
.badge-warning { background: rgba(217,119,6,0.1); color: var(--warning); }
.badge-danger { background: rgba(220,38,38,0.1); color: var(--danger); }
.badge-info { background: rgba(37,99,235,0.1); color: var(--info); }
.btn-detail {
  padding: 6px 14px;
  font-size: 11px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}
.btn-detail:hover { border-color: var(--accent); color: var(--accent); }

/* ========== ORDER DETAIL ========== */
.order-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.btn-back {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-back:hover { border-color: var(--accent); color: var(--accent); }
.detail-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.detail-card h3 {
  font-size: 15px;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.detail-field label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.detail-field .value { font-size: 14px; color: var(--text-primary); font-weight: 500; }
.detail-field .value.gold { color: var(--accent); }
.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-muted);
}
.summary-row.total {
  border-top: 2px solid var(--border);
  padding-top: 12px;
  margin-top: 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.detail-products-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}
.detail-products-table th {
  padding: 8px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.detail-products-table td {
  padding: 10px 8px;
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.detail-products-table img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.payment-option {
  padding: 14px 16px;
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  margin-top: 12px;
}
.payment-option .label { font-size: 13px; color: var(--text-primary); font-weight: 600; }
.payment-option .desc { font-size: 11px; color: var(--text-muted); }

/* ========== PROFILE FORM ========== */
.profile-section {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.profile-section h3 {
  font-size: 15px;
  color: var(--text-primary);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-group { display: flex; flex-direction: column; }
.form-group label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.form-group input, .form-group select {
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-group select { appearance: none; }
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
}
.toggle {
  width: 40px;
  height: 22px;
  background: var(--accent);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
}
.toggle::after {
  content: '';
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  right: 2px;
  transition: 0.2s;
}
.toggle-label { font-size: 13px; color: var(--text-secondary); }
.toggle-desc { font-size: 11px; color: var(--text-muted); }
.btn-save {
  padding: 12px 32px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  float: right;
  margin-top: 16px;
  transition: background 0.2s;
}
.btn-save:hover { background: var(--accent-hover); }

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 13px; margin-bottom: 20px; }

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
