/* ??????????????????????????????????????????????????????????????
   MONITOR MODULE - Control Center Aesthetics
   Dark-themed, premium dashboard for system monitoring
   ?????????????????????????????????????????????????????????????? */

/* ?? Override sidebar for monitor ??????????????????????????? */
.monitor-page .sidebar {
  background: linear-gradient(195deg, #0a0f1a 0%, #111827 50%, #0d1321 100%);
}
.monitor-page .sidebar .nav-item.active {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border-left-color: #818cf8;
}
.monitor-page .sidebar .nav-item:hover {
  background: rgba(99, 102, 241, 0.08);
}
.monitor-page .module-tag {
  background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(139,92,246,0.15));
  color: #a5b4fc;
}
.monitor-page .module-tag .module-tag-dot {
  background: #818cf8;
  box-shadow: 0 0 6px rgba(129, 140, 248, 0.5);
}

/* ?? Page background ???????????????????????????????????????? */
.monitor-page .main-content {
  background: #0f172a;
}
.monitor-page .topbar {
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(99, 102, 241, 0.1);
}
.monitor-page .topbar-title {
  color: #e2e8f0;
}
.monitor-page .page-content {
  padding: 20px;
}

/* ?? Section tabs ??????????????????????????????????????????? */
.monitor-tabs {
  display: flex;
  gap: 4px;
  background: rgba(30, 41, 59, 0.5);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  border: 1px solid rgba(99, 102, 241, 0.1);
}
.monitor-tab {
  padding: 10px 18px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.monitor-tab:hover {
  background: rgba(99, 102, 241, 0.1);
  color: #c7d2fe;
}
.monitor-tab.active {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}
.monitor-tab i {
  font-size: 0.85rem;
}

/* ?? KPI cards grid ????????????????????????????????????????? */
.monitor-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.m-kpi {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(30, 41, 59, 0.5));
  border: 1px solid rgba(99, 102, 241, 0.1);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}
.m-kpi:hover {
  border-color: rgba(99, 102, 241, 0.25);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}
.m-kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}
.m-kpi-icon.green  { background: rgba(34, 197, 94, 0.12); color: #4ade80; }
.m-kpi-icon.red    { background: rgba(239, 68, 68, 0.12); color: #f87171; }
.m-kpi-icon.blue   { background: rgba(99, 102, 241, 0.12); color: #818cf8; }
.m-kpi-icon.amber  { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }
.m-kpi-icon.purple { background: rgba(168, 85, 247, 0.12); color: #c084fc; }
.m-kpi-icon.cyan   { background: rgba(6, 182, 212, 0.12); color: #22d3ee; }
.m-kpi-info { flex: 1; min-width: 0; }
.m-kpi-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: #f1f5f9;
  line-height: 1.2;
}
.m-kpi-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

/* ?? Cards ?????????????????????????????????????????????????? */
.m-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(30, 41, 59, 0.5));
  border: 1px solid rgba(99, 102, 241, 0.1);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 20px;
  backdrop-filter: blur(10px);
}
.m-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(99, 102, 241, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.m-card-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.m-card-title i {
  color: #818cf8;
  font-size: 0.95rem;
}
.m-card-body {
  padding: 16px 20px;
}

/* ?? Tables ????????????????????????????????????????????????? */
.m-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.m-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.m-table th {
  text-align: left;
  padding: 10px 14px;
  color: #94a3b8;
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid rgba(99, 102, 241, 0.1);
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: rgba(30, 41, 59, 0.95);
  z-index: 1;
}
.m-table td {
  padding: 10px 14px;
  color: #cbd5e1;
  border-bottom: 1px solid rgba(51, 65, 85, 0.4);
  vertical-align: middle;
}
.m-table tr:hover td {
  background: rgba(99, 102, 241, 0.04);
}
.m-table .scrollable-body {
  max-height: 400px;
  overflow-y: auto;
}

/* ?? Action Buttons ????????????????????????????????????????? */
.m-action-btn {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(100, 116, 139, 0.3);
  color: #e2e8f0;
  padding: 10px 14px;
  border-radius: 8px;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}
.m-action-btn i { font-size: 0.9rem; width: 16px; text-align: center; }
.m-action-btn:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  color: #fff;
}

/* ?? Status badges ?????????????????????????????????????????? */
.m-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}
.m-badge.success { background: rgba(34, 197, 94, 0.12); color: #4ade80; }
.m-badge.danger  { background: rgba(239, 68, 68, 0.12); color: #f87171; }
.m-badge.warn    { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }
.m-badge.info    { background: rgba(99, 102, 241, 0.12); color: #818cf8; }
.m-badge.neutral { background: rgba(100, 116, 139, 0.15); color: #94a3b8; }

/* ?? LED dot ???????????????????????????????????????????????? */
.led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.led.green  { background: #4ade80; box-shadow: 0 0 6px rgba(74, 222, 128, 0.5); }
.led.red    { background: #f87171; box-shadow: 0 0 6px rgba(248, 113, 113, 0.5); }
.led.amber  { background: #fbbf24; box-shadow: 0 0 6px rgba(251, 191, 36, 0.5); }
.led.pulse  { animation: ledPulse 2s ease-in-out infinite; }

@keyframes ledPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ?? Filter bar ????????????????????????????????????????????? */
.m-filters {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.m-filter-input {
  padding: 7px 14px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 8px;
  color: #e2e8f0;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.78rem;
  outline: none;
  transition: border-color 0.2s;
}
.m-filter-input:focus {
  border-color: rgba(99, 102, 241, 0.5);
}
.m-filter-input::placeholder {
  color: #64748b;
}
.m-filter-select {
  padding: 7px 14px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 8px;
  color: #e2e8f0;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.78rem;
  outline: none;
  cursor: pointer;
}
.m-filter-select option {
  background: #1e293b;
  color: #e2e8f0;
}

/* ?? Refresh indicator ?????????????????????????????????????? */
.m-refresh-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(99, 102, 241, 0.08);
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 0.72rem;
  color: #64748b;
}
.m-refresh-bar .led { margin-right: 2px; }
.m-refresh-btn {
  margin-left: auto;
  padding: 4px 12px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.2);
  color: #818cf8;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
  transition: all 0.2s;
}
.m-refresh-btn:hover {
  background: rgba(99, 102, 241, 0.2);
}
.m-refresh-btn.spinning i {
  animation: spin 1s linear infinite;
}

/* ?? Charts ????????????????????????????????????????????????? */
.m-charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.m-chart-box {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(30, 41, 59, 0.5));
  border: 1px solid rgba(99, 102, 241, 0.1);
  border-radius: 14px;
  padding: 20px;
}
.m-chart-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #e2e8f0;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.m-chart-title i { color: #818cf8; }

/* ?? Section panels ????????????????????????????????????????? */
.m-section {
  display: none;
}
.m-section.active {
  display: block;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ?? Memory bar ????????????????????????????????????????????? */
.m-mem-bar {
  height: 8px;
  border-radius: 4px;
  background: rgba(51, 65, 85, 0.5);
  overflow: hidden;
  margin-top: 8px;
}
.m-mem-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* ?? Server info grid ??????????????????????????????????????? */
.m-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.m-info-item {
  padding: 14px 16px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(51, 65, 85, 0.4);
  border-radius: 10px;
}
.m-info-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.m-info-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f1f5f9;
  word-break: break-all;
}

/* ?? Responsive ????????????????????????????????????????????? */
@media (max-width: 768px) {
  .monitor-kpis { grid-template-columns: repeat(2, 1fr); }
  .m-charts-grid { grid-template-columns: 1fr; }
  .monitor-tabs { gap: 2px; }
  .monitor-tab { padding: 8px 12px; font-size: 0.72rem; }
  .monitor-tab span { display: none; }
  .m-kpi-value { font-size: 1.2rem; }
  .m-info-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .monitor-kpis { grid-template-columns: 1fr; }
}

/* ?? Scrollbar dark theme ??????????????????????????????????? */
.monitor-page ::-webkit-scrollbar { width: 6px; height: 6px; }
.monitor-page ::-webkit-scrollbar-track { background: rgba(15, 23, 42, 0.5); }
.monitor-page ::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.3); border-radius: 3px; }
.monitor-page ::-webkit-scrollbar-thumb:hover { background: rgba(99, 102, 241, 0.5); }

/* ?? User active dot ???????????????????????????????????????? */
.m-user-row { display: flex; align-items: center; gap: 10px; }
.m-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700;
  flex-shrink: 0;
}
.m-user-info { min-width: 0; }
.m-user-name { color: #e2e8f0; font-weight: 600; font-size: 0.8rem; }
.m-user-email { color: #64748b; font-size: 0.7rem; }

/* ?? Spin animation ????????????????????????????????????????? */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Custom Tooltip Fixes */
.m-kpi, .m-info-item, .m-chart-box {
  position: relative;
  z-index: 1;
}
.m-kpi:hover, .m-info-item:hover, .m-chart-box:hover {
  z-index: 100;
}

/* Custom Tooltip */
.m-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  color: #818cf8;
  margin-left: 6px;
  font-size: 1.1em;
}
.m-tooltip .m-tooltip-text {
  visibility: hidden;
  opacity: 0;
  width: 240px;
  background: #0f172a;
  color: #f8fafc;
  text-align: center;
  border-radius: 8px;
  padding: 10px 12px;
  position: absolute;
  z-index: 999;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  font-size: 0.75rem;
  font-family: 'Montserrat', sans-serif;
  font-weight: normal;
  border: 1px solid rgba(129, 140, 248, 0.3);
  box-shadow: 0 10px 25px rgba(0,0,0,0.7);
  pointer-events: none;
  line-height: 1.4;
  text-transform: none;
  letter-spacing: normal;
}
.m-tooltip .m-tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -6px;
  border-width: 6px;
  border-style: solid;
  border-color: #0f172a transparent transparent transparent;
}
.m-tooltip:hover .m-tooltip-text {
  visibility: visible;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Modificador para tooltips en el borde derecho */
.m-tooltip.m-tooltip-left .m-tooltip-text {
  left: auto;
  right: -10px;
  transform: translateY(10px);
}
.m-tooltip.m-tooltip-left:hover .m-tooltip-text {
  transform: translateY(0);
}
.m-tooltip.m-tooltip-left .m-tooltip-text::after {
  left: auto;
  right: 14px;
  margin-left: 0;
}
