/* Gestão de Recursos - Design System Profissional */
:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --success: #059669;
  --success-bg: #ecfdf5;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning: #d97706;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 0.75rem;
  --radius-lg: 1rem;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.08);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.08);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);
  --header-h: 64px;
  --bottom-nav-h: 72px;
}

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

html { -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ========== Layout base ========== */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 768px) {
  .app-shell { padding-bottom: 0; }
}

/* ========== Header ========== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.app-header-inner {
  max-width: 72rem;
  margin: 0 auto;
  height: 100%;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 1.05rem;
}

.app-brand-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: white;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-chip {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
}

@media (min-width: 640px) {
  .user-chip { display: flex; }
}

/* ========== Main content ========== */
.app-main {
  flex: 1;
  max-width: 72rem;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

/* ========== Cards / Hub ========== */
.hub-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.875rem;
}

@media (min-width: 640px) {
  .hub-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
}

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

.hub-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.125rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.hub-card:hover, .hub-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #c7d2fe;
  outline: none;
}

.hub-card:active { transform: translateY(0); }

.hub-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.hub-card-icon.primary { background: var(--primary-light); color: var(--primary); }
.hub-card-icon.success { background: var(--success-bg); color: var(--success); }
.hub-card-icon.warning { background: #fffbeb; color: var(--warning); }
.hub-card-icon.danger  { background: var(--danger-bg); color: var(--danger); }
.hub-card-icon.slate   { background: #f1f5f9; color: #475569; }

.hub-card-body { flex: 1; min-width: 0; }
.hub-card-title { font-weight: 600; font-size: 1rem; margin-bottom: 0.15rem; }
.hub-card-desc { font-size: 0.8rem; color: var(--text-muted); line-height: 1.35; }

.hub-card-arrow {
  color: #94a3b8;
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* ========== Rack / Equipment cards ========== */
.section-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.rack-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 480px) {
  .rack-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 768px) {
  .rack-grid { grid-template-columns: repeat(3, 1fr); gap: 1rem; }
}

.rack-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  display: block;
}

.rack-card:hover, .rack-card:focus-visible {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  outline: none;
}

.rack-card-name {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  margin-bottom: 0.35rem;
}

.rack-card-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.equip-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.625rem;
}

.equip-btn {
  min-width: 96px;
  padding: 0.65rem 1rem;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  box-shadow: var(--shadow);
}

.equip-btn.available {
  background: var(--success);
  color: white;
}
.equip-btn.available:hover { background: #047857; transform: scale(1.03); }

.equip-btn.unavailable {
  background: #cbd5e1;
  color: #64748b;
  cursor: not-allowed;
  opacity: 0.85;
}

/* ========== Bottom nav (mobile) ========== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 12px rgb(0 0 0 / 0.05);
  display: flex;
  align-items: stretch;
  justify-content: space-around;
}

@media (min-width: 768px) {
  .bottom-nav { display: none; }
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 500;
  transition: color 0.15s;
  padding: 0.5rem 0.25rem;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item i, .bottom-nav-item svg {
  font-size: 1.25rem;
  line-height: 1;
}

.bottom-nav-item.active,
.bottom-nav-item:hover {
  color: var(--primary);
}

.bottom-nav-item.qr-highlight {
  color: var(--primary);
}

.bottom-nav-item.qr-highlight .qr-circle {
  width: 48px;
  height: 48px;
  margin-top: -18px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
  border: 3px solid var(--surface);
  font-size: 1.2rem;
}

/* ========== Forms / Auth ========== */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(160deg, #eef2ff 0%, #f8fafc 50%, #f1f5f9 100%);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2rem 1.75rem;
  border: 1px solid var(--border);
}

.auth-logo {
  width: 56px;
  height: 56px;
  background: var(--primary);
  color: white;
  border-radius: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin: 0 auto 1.25rem;
}

.auth-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.auth-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.75rem;
}

.form-group { margin-bottom: 1rem; }

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 1rem;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: #f1f5f9;
  color: var(--text);
}
.btn-secondary:hover { background: #e2e8f0; }

.btn-ghost {
  background: transparent;
  color: var(--primary);
}
.btn-ghost:hover { background: var(--primary-light); }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #b91c1c; }

.alert {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  text-align: center;
}
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); }

.link {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.9rem;
}
.link:hover { text-decoration: underline; }

/* ========== Panel / lists (admin style) ========== */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.panel-body { padding: 1.25rem; }

.list-nav {
  list-style: none;
}

.list-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.list-nav a:last-child { border-bottom: none; }
.list-nav a:hover { background: var(--primary-light); color: var(--primary); }

.list-nav a i {
  width: 1.25rem;
  text-align: center;
  color: var(--text-muted);
}

/* ========== QR Reader specific ========== */
.qr-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem 2rem;
}

.qr-reader-box {
  width: 100%;
  max-width: 320px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.qr-status {
  min-height: 1.5rem;
  text-align: center;
  font-weight: 500;
  margin-top: 1rem;
  color: var(--success);
}

/* ========== Utilities ========== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-muted { background: #f1f5f9; color: var(--text-muted); }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.back-link:hover { color: var(--primary); }

.text-center { text-align: center; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.show { display: flex; }

.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 28rem;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.25rem;
  padding: 0.25rem;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.data-table th,
table.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table.data-table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
table.data-table tr:hover td { background: #f8fafc; }

/* Footer */
.app-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}


/* ========== Hamburger / side menu ========== */
.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.menu-toggle:hover { background: var(--primary-light); color: var(--primary); }

.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.menu-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.side-menu {
  position: fixed;
  top: 0;
  right: 0;
  left: auto;
  width: min(300px, 88vw);
  height: 100%;
  height: 100dvh;
  background: var(--surface);
  z-index: 1001;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  visibility: hidden;
  pointer-events: none;
}
.side-menu.open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.side-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  min-height: var(--header-h);
}
.side-menu-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.side-menu-user > i { font-size: 1.75rem; color: var(--primary); }
.side-menu-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-menu-role { font-size: 0.75rem; color: var(--text-muted); }
.side-menu-nav {
  padding: 0.75rem 0;
  display: flex;
  flex-direction: column;
}
.side-menu-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1.25rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: background 0.15s;
}
.side-menu-link i {
  width: 1.25rem;
  text-align: center;
  color: var(--text-muted);
}
.side-menu-link:hover {
  background: var(--primary-light);
  color: var(--primary);
}
.side-menu-link:hover i { color: var(--primary); }
.side-menu-link-danger { color: var(--danger); }
.side-menu-link-danger i { color: var(--danger); }
.side-menu-link-danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}
