/* =============================================
   ENCOMENDAS - DESIGN SYSTEM
   Tema: Industrial Moderno / Azul Profissional
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --bg:        #0d1117;
  --bg2:       #161b22;
  --bg3:       #21262d;
  --border:    #30363d;
  --accent:    #2563eb;
  --accent2:   #3b82f6;
  --accent-glow: rgba(37,99,235,0.25);
  --success:   #10b981;
  --warning:   #f59e0b;
  --danger:    #ef4444;
  --info:      #06b6d4;
  --text:      #e6edf3;
  --text2:     #8b949e;
  --text3:     #6e7681;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --font-head: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  min-height: 100vh;
  line-height: 1.6;
}

/* ---- LAYOUT ---- */
.layout { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  width: 260px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .3s ease;
}
.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-logo .logo-icon {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.sidebar-logo .logo-text {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -.5px;
  line-height: 1.2;
}
.sidebar-logo .logo-sub {
  font-size: 11px;
  color: var(--text2);
  font-weight: 400;
}

.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }
.nav-section { margin-bottom: 4px; }
.nav-section-title {
  padding: 8px 20px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text3);
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: 0;
  transition: all .15s;
  position: relative;
}
.nav-item:hover { color: var(--text); background: var(--bg3); }
.nav-item.active {
  color: #fff;
  background: rgba(37,99,235,0.15);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.nav-item .badge-count {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  border-radius: 20px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
}
.nav-icon { width: 18px; text-align: center; font-size: 16px; }

.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-avatar {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text2); }
.logout-btn { color: var(--text3); text-decoration: none; font-size: 16px; transition: color .2s; }
.logout-btn:hover { color: var(--danger); }

/* MAIN CONTENT */
.main { margin-left: 260px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg2);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-family: var(--font-head); font-size: 20px; font-weight: 700; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.page-content { padding: 28px; flex: 1; }

/* ---- CARDS ---- */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-family: var(--font-head); font-size: 16px; font-weight: 700; }

/* STAT CARDS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color .2s, transform .2s;
}
.stat-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 60px; height: 60px;
  border-radius: 0 var(--radius) 0 60px;
  opacity: .1;
}
.stat-card.blue::after  { background: var(--accent); }
.stat-card.green::after { background: var(--success); }
.stat-card.yellow::after{ background: var(--warning); }
.stat-card.red::after   { background: var(--danger); }
.stat-card.cyan::after  { background: var(--info); }
.stat-icon { font-size: 24px; margin-bottom: 12px; }
.stat-value { font-family: var(--font-head); font-size: 32px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text2); margin-top: 4px; font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }

/* ---- TABLE ---- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text2);
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,.02); }

/* ---- BADGES ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-success  { background: rgba(16,185,129,.15); color: var(--success); }
.badge-warning  { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-danger   { background: rgba(239,68,68,.15);  color: var(--danger); }
.badge-info     { background: rgba(6,182,212,.15);  color: var(--info); }
.badge-secondary{ background: var(--bg3); color: var(--text2); }
.badge-primary  { background: rgba(37,99,235,.2);   color: var(--accent2); }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent2); box-shadow: 0 0 20px var(--accent-glow); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: .85; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { opacity: .85; }
.btn-ghost   { background: transparent; color: var(--text2); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text2); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 6px; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 18px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.form-control {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font-body);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-control::placeholder { color: var(--text3); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ---- ALERTS ---- */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 4px solid;
}
.alert-success { background: rgba(16,185,129,.1); border-color: var(--success); color: #a7f3d0; }
.alert-danger   { background: rgba(239,68,68,.1);  border-color: var(--danger);  color: #fca5a5; }
.alert-warning  { background: rgba(245,158,11,.1); border-color: var(--warning); color: #fde68a; }
.alert-info     { background: rgba(6,182,212,.1);  border-color: var(--info);    color: #a5f3fc; }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modalIn .25s ease;
}
@keyframes modalIn { from { opacity:0; transform: scale(.95) translateY(20px); } to { opacity:1; transform: none; } }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-family: var(--font-head); font-size: 18px; font-weight: 700; }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.btn-close { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 20px; padding: 4px; transition: color .2s; }
.btn-close:hover { color: var(--danger); }

/* ---- SCANNER ---- */
.scanner-area {
  background: var(--bg3);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  margin-bottom: 16px;
}
.scanner-area:hover, .scanner-area.active {
  border-color: var(--accent);
  background: rgba(37,99,235,.05);
}
.scanner-icon { font-size: 48px; margin-bottom: 12px; display: block; }
.scanner-text { color: var(--text2); font-size: 14px; }
#camera-preview {
  width: 100%;
  max-width: 400px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--accent);
  margin: 0 auto 16px;
  display: block;
}
.scan-result {
  background: rgba(16,185,129,.1);
  border: 1px solid var(--success);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: #a7f3d0;
  word-break: break-all;
}

/* ---- NOTIFICATIONS PANEL ---- */
.notif-panel {
  position: fixed;
  top: 60px; right: 20px;
  width: 360px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 500;
  display: none;
  animation: slideDown .2s ease;
}
@keyframes slideDown { from { opacity:0; transform: translateY(-10px); } to { opacity:1; transform:none; } }
.notif-panel.open { display: block; }
.notif-panel-header { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.notif-item {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
  text-decoration: none;
  display: block;
  color: inherit;
}
.notif-item:hover { background: var(--bg3); }
.notif-item.unread { background: rgba(37,99,235,.05); border-left: 3px solid var(--accent); }
.notif-title { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.notif-msg { font-size: 12px; color: var(--text2); }
.notif-time { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* ---- LOGIN ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(37,99,235,.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(6,182,212,.05) 0%, transparent 50%);
}
.login-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.login-logo { text-align: center; margin-bottom: 36px; }
.login-logo .icon { font-size: 48px; display: block; margin-bottom: 12px; }
.login-logo h1 { font-family: var(--font-head); font-size: 24px; font-weight: 800; }
.login-logo p { color: var(--text2); font-size: 13px; margin-top: 4px; }

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text2);
}
.empty-state .icon { font-size: 48px; display: block; margin-bottom: 12px; }

/* ---- TABS ---- */
.tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.tab {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .2s;
  text-decoration: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent2); border-color: var(--accent); }

/* ---- UTILS ---- */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-0 { margin-bottom: 0; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text2); }
.text-small { font-size: 12px; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.w-100 { width: 100%; }

/* ---- MOBILE ---- */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  margin-right: 12px;
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 16px; }
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ---- PRINT ---- */
.comprovante {
  background: white;
  color: #111;
  padding: 20px;
  font-size: 13px;
  max-width: 400px;
  border: 1px solid #ddd;
  border-radius: 8px;
}
