/* ============================================================
   LINEAR HP - SISTEMA DE COMPRAS
   Estilos principais
   ============================================================ */

:root {
  --primary: #667eea;
  --primary-dark: #5a67d8;
  --danger: #FF6B6B;
  --success: #51CF66;
  --warning: #FFD93D;
  --text: #2d3748;
  --text-muted: #718096;
  --border: #e2e8f0;
  --bg: #f7f8fc;
  --sidebar-w: 260px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ─── LOGIN ─────────────────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo img {
  max-height: 90px;
  max-width: 260px;
  object-fit: contain;
  margin-bottom: 8px;
}

/* ─── LAYOUT ─────────────────────────────────────────────── */
#app-screen {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #2d3748 0%, #1a202c 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .3s ease;
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  text-align: center;
}

.sidebar-logo img {
  max-height: 56px;
  max-width: 200px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
}

.sidebar-user {
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.user-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #764ba2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: rgba(255,255,255,.6); }

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,.4);
  padding: 12px 16px 4px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: rgba(255,255,255,.75);
  cursor: pointer;
  transition: all .2s;
  border-left: 3px solid transparent;
  font-size: 13px;
  text-decoration: none;
}

.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active {
  background: rgba(102,126,234,.25);
  color: #fff;
  border-left-color: var(--primary);
}

.nav-item i { width: 18px; text-align: center; }

.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,.08); }

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 24px;
  min-height: 100vh;
}

/* ─── TOPBAR ─────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ─── CARDS / STATS ─────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-title { font-weight: 700; font-size: 15px; }

.card-body { padding: 20px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
  cursor: default;
  transition: transform .2s, box-shadow .2s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.1); }

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.blue { background: rgba(102,126,234,.12); color: var(--primary); }
.stat-icon.green { background: rgba(81,207,102,.12); color: var(--success); }
.stat-icon.red { background: rgba(255,107,107,.12); color: var(--danger); }
.stat-icon.yellow { background: rgba(255,217,61,.2); color: #b7950b; }
.stat-icon.purple { background: rgba(118,75,162,.12); color: #764ba2; }

.stat-value { font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ─── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all .2s;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); box-shadow: 0 4px 15px rgba(102,126,234,.4); }

.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover:not(:disabled) { background: var(--primary); color: #fff; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.1); }

.btn-success, .btn-green { background: var(--success); color: #fff; }
.btn-secondary { background: #718096; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ─── FORMS ─────────────────────────────────────────────── */
.form-section {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}

.form-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.form-group { margin-bottom: 14px; }

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  transition: border-color .2s, box-shadow .2s;
  background: #fff;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(102,126,234,.15);
}

.form-group input:read-only {
  background: #f0f4ff;
  color: var(--primary);
  font-weight: 600;
  cursor: not-allowed;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ─── TABLES ─────────────────────────────────────────────── */
.table-container { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead tr { background: #f8f9ff; }
th {
  padding: 12px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}

tbody tr { transition: background .15s; }
tbody tr:hover { background: #f8f9ff; }
tbody tr:last-child td { border-bottom: none; }

/* ─── BADGES ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-cotacao { background: #fef3c7; color: #92400e; }
.badge-negociacao { background: #fee2e2; color: #991b1b; }
.badge-comprado { background: #d1fae5; color: #065f46; }
.badge-baixa { background: #d1fae5; color: #065f46; }
.badge-media { background: #fef3c7; color: #92400e; }
.badge-alta { background: #fed7aa; color: #9a3412; }
.badge-urgente { background: #fee2e2; color: #991b1b; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  background: #f0f4ff;
  color: var(--primary);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

/* ─── MODAIS ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn .2s ease;
}

.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.modal-xl { max-width: 780px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.modal-header h3 { font-size: 17px; font-weight: 700; }

.modal-body { padding: 20px 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #f8f9ff;
}

.btn-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
}

.btn-close:hover { background: #f0f4ff; color: var(--text); }

/* ─── MATERIAL ITEM ─────────────────────────────────────── */
.material-item {
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
  transition: border-color .2s;
}

.material-item:focus-within { border-color: var(--primary); }

.material-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.material-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
  font-size: 13px;
  margin-right: 8px;
}

.mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  padding: 4px;
  background: #f0f4ff;
  border-radius: 10px;
  width: fit-content;
}

.mode-btn {
  padding: 6px 16px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  background: transparent;
  color: var(--text-muted);
  transition: all .2s;
}

.mode-btn.active { background: #fff; color: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,.1); }

/* ─── PHOTO UPLOAD ─────────────────────────────────────── */
.photo-upload {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
}

.photo-upload:hover { border-color: var(--primary); background: #f8f9ff; }

.photo-preview {
  max-width: 100%;
  max-height: 120px;
  border-radius: 8px;
  object-fit: cover;
  margin-top: 8px;
}

/* ─── FILTER BAR ─────────────────────────────────────── */
.filter-bar {
  background: #fff;
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}

.filter-bar .form-group { margin-bottom: 0; flex: 1; min-width: 140px; }

/* ─── DETAIL GRID ─────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.detail-item {
  background: #f8f9ff;
  border-radius: 10px;
  padding: 12px 14px;
}

.detail-item label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
}

.detail-item span { font-size: 14px; font-weight: 600; }

.item-card {
  background: #f8f9ff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
}

/* ─── REPORT ─────────────────────────────────────────── */
.report-summary {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.report-summary-item {
  background: #fff;
  border-radius: 12px;
  padding: 14px 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
  text-align: center;
  min-width: 120px;
}

.report-summary-item .val { font-size: 22px; font-weight: 800; }
.report-summary-item .lbl { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.report-actions {
  display: flex;
  gap: 10px;
  margin-left: auto;
  align-items: center;
  flex-wrap: wrap;
}

.reduction-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

.reduction-high { background: #d1fae5; color: #065f46; }
.reduction-low { background: #fee2e2; color: #991b1b; }

.total-row td { background: #f0f4ff !important; font-weight: 700; }
.good { background: rgba(81,207,102,.06) !important; }

/* ─── TOAST ─────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  font-size: 13px;
  font-weight: 500;
  animation: slideIn .3s ease;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--primary); }

.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-msg { flex: 1; }
.toast-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 14px; padding: 0; margin-left: 4px; }

/* ─── LOADING ─────────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(4px);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.spinner {
  width: 42px; height: 42px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ─── EMPTY STATE ─────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 18px; color: var(--text); margin-bottom: 8px; }

/* ─── HAMBURGER ─────────────────────────────────────── */
.hamburger {
  display: none;
  position: fixed;
  top: 14px; left: 14px;
  z-index: 200;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  width: 40px; height: 40px;
  cursor: pointer;
  font-size: 16px;
  align-items: center;
  justify-content: center;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}

/* ─── MISC ─────────────────────────────────────────── */
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

code {
  background: #f0f4ff;
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

/* ─── ANIMATIONS ─────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.fade-in { animation: fadeIn .3s ease; }

/* ─── RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
  }
  .sidebar-overlay.show { display: block; }
  .hamburger { display: flex; }
  .main-content { margin-left: 0; padding: 16px; padding-top: 60px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .report-summary { flex-direction: column; }
  .report-actions { margin-left: 0; width: 100%; }
  table { font-size: 12px; }
  th, td { padding: 8px 10px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .modal { max-width: 100%; margin: 10px; }
}

/* ─── PRINT STYLES ─────────────────────────────────────── */
@media print {
  .sidebar, .hamburger, .topbar .btn, .filter-bar,
  .modal-footer .btn, #loading-overlay, .toast-container,
  .no-print { display: none !important; }

  .main-content { margin: 0; padding: 0; }
  body { background: #fff; font-size: 12px; }

  .card { box-shadow: none; border: 1px solid #ddd; }

  table { page-break-inside: auto; }
  tr { page-break-inside: avoid; }
  thead { display: table-header-group; }

  .report-print-header { border-bottom: 2px solid #667eea; }
}
