/* ============================================
   PCM - Sistema de Controle de Manutenção
   ============================================ */

:root {
  --sidebar-width: 265px;
  --sidebar-bg: #2e3f54;
  --sidebar-hover: #3a4f68;
  --sidebar-active: #4a6280;
  --sidebar-text: #c8d8e8;
  --sidebar-text-muted: #7a9ab8;
  --topbar-height: 62px;
  --accent: #2979ff;
  --accent-hover: #1565c0;
  --success: #00b86b;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  --card-radius: 14px;
  --bg-page: #f0f4f8;
}

/* ============ Base ============ */
body {
  background-color: var(--bg-page);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
  color: #1e293b;
}

#wrapper { min-height: 100vh; }

/* ============ Sidebar ============ */
#sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: linear-gradient(180deg, #2e3f54 0%, #354a63 60%, #2e3f54 100%);
  color: var(--sidebar-text);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: width 0.3s ease;
  scrollbar-width: thin;
  scrollbar-color: #4a6280 transparent;
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: #1e3a5f; border-radius: 2px; }

/* Brand / Logo area */
.sidebar-brand {
  color: #ffffff;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 20px 18px 16px;
}

.brand-logo-box {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent) 0%, #1565c0 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(41,121,255,0.4);
  flex-shrink: 0;
}

.brand-logo-box i { color: #fff; font-size: 18px; }

.brand-title { font-size: 15px; font-weight: 700; color: #fff; line-height: 1.2; }
.brand-subtitle { font-size: 10px; color: var(--sidebar-text-muted); letter-spacing: 0.5px; }

.sidebar-divider { border-color: rgba(255,255,255,0.06); margin: 0; }

.sidebar-section-title {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--sidebar-text-muted);
  margin-top: 12px;
  margin-bottom: 4px;
  padding: 0 18px;
}

.sidebar-link {
  color: var(--sidebar-text) !important;
  border-radius: 9px;
  padding: 9px 13px;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  margin-bottom: 2px;
  gap: 10px;
}

.sidebar-link i { font-size: 15px; flex-shrink: 0; }

.sidebar-link:hover {
  background: var(--sidebar-hover) !important;
  color: #ffffff !important;
  transform: translateX(3px);
}

.sidebar-link.active {
  background: var(--sidebar-active) !important;
  color: #ffffff !important;
  box-shadow: inset 3px 0 0 var(--accent);
  font-weight: 600;
}

.sidebar-link.active i { color: var(--accent); }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 14px 18px;
}

.sidebar-footer .version-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(41,121,255,0.12);
  color: var(--accent);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
}

/* ============ Top Navbar ============ */
.top-navbar {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  height: var(--topbar-height);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}

.page-title {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
}

.online-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #dcfce7;
  color: #16a34a;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid #bbf7d0;
}

.online-dot {
  width: 7px;
  height: 7px;
  background: #22c55e;
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.8); }
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  padding: 4px 14px 4px 5px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  white-space: nowrap;
}

.user-avatar {
  width: 26px;
  height: 26px;
  min-width: 26px;
  background: linear-gradient(135deg, var(--accent), #1565c0);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}

/* ============ Page Content ============ */
#page-content-wrapper { min-width: 0; }

main { min-height: calc(100vh - var(--topbar-height) - 48px); }

/* ============ Cards ============ */
.card {
  border-radius: var(--card-radius);
  border: 1px solid #e2e8f0;
}

.card-header {
  border-radius: var(--card-radius) var(--card-radius) 0 0 !important;
  padding: 14px 20px;
}

/* ============ Stat Cards ============ */
.stat-card {
  border: none !important;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1) !important;
}

.stat-card .card-body { padding: 22px 20px 16px; }

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

.stat-card-blue   { background: linear-gradient(135deg, #cce4ff 0%, #e8f4ff 100%); border-left: 4px solid var(--accent) !important; border: 1px solid #99c9ff !important; }
.stat-card-green  { background: linear-gradient(135deg, #bbf0d8 0%, #e0faf0 100%); border-left: 4px solid var(--success) !important; border: 1px solid #86e8bf !important; }
.stat-card-orange { background: linear-gradient(135deg, #fde896 0%, #fff7d6 100%); border-left: 4px solid var(--warning) !important; border: 1px solid #fbd34d !important; }
.stat-card-red    { background: linear-gradient(135deg, #ffc5c5 0%, #ffeded 100%); border-left: 4px solid var(--danger) !important; border: 1px solid #ff9999 !important; }
.stat-card-teal   { background: linear-gradient(135deg, #a5f3fc 0%, #e0fafd 100%); border-left: 4px solid var(--info) !important; border: 1px solid #67e8f9 !important; }
.stat-card-indigo { background: linear-gradient(135deg, #c7d2fe 0%, #eef2ff 100%); border-left: 4px solid #4f46e5 !important; border: 1px solid #a5b4fc !important; }

.stat-value {
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1;
  color: #0f172a;
}

.stat-label {
  font-size: 12.5px;
  color: #64748b;
  margin-top: 4px;
  font-weight: 500;
}

.stat-footer-link {
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  opacity: 0.8;
  transition: opacity 0.15s;
}

.stat-footer-link:hover { opacity: 1; }

/* ============ Chart Cards ============ */
.chart-card {
  background: #fff;
  border-radius: var(--card-radius);
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}

.chart-card .card-header {
  background: #fff;
  border-bottom: 1px solid #f1f5f9;
}

.chart-title {
  font-size: 14px;
  font-weight: 700;
  color: #1e293b;
}

/* ============ Section Header ============ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #fff;
  border-bottom: 1px solid #f1f5f9;
  border-radius: var(--card-radius) var(--card-radius) 0 0;
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

/* ============ Tables ============ */
.table th {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
  color: #64748b;
  background: #f8fafc;
}

.table td { vertical-align: middle; font-size: 13.5px; }

.table-hover tbody tr:hover { background: #f8fafc; }

.table-dark th {
  background: #2e3f54 !important;
  border-color: #4a6280;
}

/* Priority bar indicator */
.priority-indicator {
  width: 4px;
  height: 100%;
  border-radius: 2px;
  display: inline-block;
}

/* ============ Badges ============ */
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 6px;
  letter-spacing: 0.3px;
}

.badge-status-open      { background: #dbeafe; color: #1d4ed8; }
.badge-status-progress  { background: #fef3c7; color: #92400e; }
.badge-status-closed    { background: #dcfce7; color: #15803d; }
.badge-status-cancelled { background: #fee2e2; color: #991b1b; }

.badge-priority-critical { background: #fee2e2; color: #991b1b; }
.badge-priority-high     { background: #fef3c7; color: #92400e; }
.badge-priority-normal   { background: #dbeafe; color: #1e40af; }
.badge-priority-low      { background: #f1f5f9; color: #475569; }

/* ============ Buttons ============ */
.btn-xs {
  padding: 2px 8px;
  font-size: 12px;
  border-radius: 6px;
  line-height: 1.5;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-action {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #64748b;
  font-size: 13px;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-action:hover {
  background: #f1f5f9;
  color: #1e293b;
  border-color: #cbd5e1;
}

/* ============ Quick Actions ============ */
.quick-action-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  text-decoration: none;
  color: #374151;
  transition: all 0.2s;
  display: block;
}

.quick-action-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(41,121,255,0.12);
  transform: translateY(-2px);
  color: var(--accent);
}

.quick-action-icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin: 0 auto 10px;
}

.quick-action-label {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}

/* ============ Progress bars ============ */
.progress {
  height: 6px;
  border-radius: 3px;
  background: #f1f5f9;
}

.progress-bar { border-radius: 3px; }

/* ============ Component Tree ============ */
.component-tree {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}

.component-item {
  border-bottom: 1px solid #f0f4f8;
  transition: background 0.15s;
}

.component-item:hover { background: #f8fafc; }
.component-item:last-child { border-bottom: none; }
.component-child { background: #fafbfc; }
.component-node:last-child .component-item { border-bottom: none; }

/* ============ Timeline ============ */
.timeline { position: relative; padding-left: 8px; }

.timeline-item {
  display: flex;
  align-items: flex-start;
  padding: 10px 0;
  position: relative;
}

.timeline-item + .timeline-item::before {
  content: '';
  position: absolute;
  left: 7px;
  top: -10px;
  width: 2px;
  height: 10px;
  background: #e2e8f0;
}

.timeline-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ============ Forms ============ */
.form-control:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.2rem rgba(41,121,255,0.15);
}

.form-label {
  font-weight: 600;
  font-size: 13.5px;
  color: #374151;
  margin-bottom: 5px;
}

/* ============ Alerts ============ */
.alert { border-radius: 10px; border: none; }

/* ============ Navigation Tabs ============ */
.nav-tabs .nav-link {
  color: #64748b;
  font-weight: 500;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  font-size: 13.5px;
}

.nav-tabs .nav-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.nav-tabs .nav-link.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 700;
  background: transparent;
}

/* ============ Overdue / alert row ============ */
.row-overdue { background: #fff7ed !important; }
.row-overdue:hover { background: #fef3c7 !important; }

/* ============ Empty state ============ */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: #94a3b8;
}

.empty-state i { font-size: 2.8rem; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 14px; margin: 0; }

/* ============ Footer ============ */
footer {
  background: #fff;
  border-top: 1px solid #e2e8f0;
  font-size: 12px;
  color: #94a3b8;
}

/* ============ Shadows ============ */
.shadow-sm { box-shadow: 0 1px 8px rgba(0,0,0,0.07) !important; }
.shadow-card { box-shadow: 0 2px 12px rgba(0,0,0,0.08) !important; }

/* ============ Misc ============ */
.text-muted-light { color: var(--sidebar-text-muted); }

/* ============ Responsive ============ */
@media (max-width: 991.98px) {
  #sidebar {
    position: fixed;
    left: -var(--sidebar-width);
    z-index: 1000;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  #sidebar.show { transform: translateX(0); }
  #page-content-wrapper { width: 100%; }
}

@media (max-width: 575.98px) {
  main { padding: 16px !important; }
  .stat-value { font-size: 1.6rem; }
}

/* ============ Loading spinner ============ */
.spinner-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.7);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
