/* ==========================================================================
   GLOBAL COMPONENT DESIGN SYSTEM (STAGE 10 POLISH)
   ========================================================================== */

/* 1. Stat Grid & Cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  text-decoration: none;
}

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-icon {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
}

.stat-icon.primary { background: var(--primary-light); color: #60a5fa; }
.stat-icon.success { background: var(--success-light); color: #34d399; }
.stat-icon.danger { background: var(--danger-light); color: #f87171; }
.stat-icon.warning { background: var(--warning-light); color: #fbbf24; }
.stat-icon.info { background: var(--info-light); color: #22d3ee; }

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* 2. Panels & Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 1100px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.panel-header {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: rgba(255, 255, 255, 0.01);
}

.panel-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-title svg {
  color: var(--primary);
  width: 1.125rem;
  height: 1.125rem;
}

.panel-body {
  padding: 1.25rem;
  flex: 1;
}

.panel-body.no-padding {
  padding: 0;
}

/* 3. Tables & Responsive Wrapping */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.8125rem;
}

.table th {
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background-color: rgba(15, 23, 42, 0.5);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table td {
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.table tbody tr {
  transition: var(--transition-fast);
}

.table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* 4. Unified Status & Severity Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.badge-success, .badge-up, .badge-online, .badge-connected {
  background: var(--success-light);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-danger, .badge-down, .badge-offline, .badge-disconnected, .badge-critical {
  background: var(--danger-light);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.badge-warning, .badge-degraded {
  background: var(--warning-light);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-info, .badge-acknowledged {
  background: var(--info-light);
  color: #22d3ee;
  border: 1px solid rgba(6, 182, 212, 0.25);
}

.badge-primary {
  background: var(--primary-light);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.badge-resolved {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-muted, .badge-unknown {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

/* 5. Button System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
  line-height: 1.25;
}

.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover {
  background: var(--success-hover);
}

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

.btn-warning {
  background: var(--warning);
  color: #fff;
}
.btn-warning:hover {
  background: var(--warning-hover);
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--text-secondary);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  color: #fff;
  border-color: var(--border-light);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-secondary);
}
.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
}

/* 6. Form Controls */
.form-group {
  margin-bottom: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-label .required {
  color: #f87171;
  margin-left: 0.15rem;
}

.form-control, .form-select {
  width: 100%;
  padding: 0.55rem 0.85rem;
  font-size: 0.8125rem;
  color: #fff;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  outline: none;
  transition: var(--transition-fast);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-control::placeholder {
  color: var(--text-dark);
}

.form-error {
  font-size: 0.75rem;
  color: #f87171;
  margin-top: 0.25rem;
}

.form-help {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* 7. Empty & Error States */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
}

.empty-icon {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.875rem;
  color: var(--text-dark);
}

.empty-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.empty-description {
  font-size: 0.8125rem;
  color: var(--text-muted);
  max-width: 340px;
}

/* 8. Toast Notifications */
.toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 400px;
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.8125rem;
  color: #fff;
  animation: toastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-success { border-color: rgba(16, 185, 129, 0.4); background: #064e3b; }
.toast-error { border-color: rgba(239, 68, 68, 0.4); background: #7f1d1d; }
.toast-warning { border-color: rgba(245, 158, 11, 0.4); background: #78350f; }
.toast-info { border-color: rgba(6, 182, 212, 0.4); background: #164e63; }

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  margin-left: auto;
  font-size: 1.1rem;
  line-height: 1;
}

.toast-close:hover {
  color: #fff;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

/* 9. Skeleton Shimmer Loading */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.08) 37%, rgba(255,255,255,0.03) 63%);
  background-size: 400% 100%;
  animation: skeletonShimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeletonShimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* 10. Unified Pagination Component */
.pagination-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border-color);
  background-color: rgba(255, 255, 255, 0.01);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.pagination-info {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
}

.page-btn:hover:not(.disabled):not(.active) {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: var(--border-light);
}

.page-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  cursor: default;
}

.page-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* 11. Responsive Overrides for Breakpoints 360px - 768px */
@media (max-width: 768px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  .stat-card {
    padding: 0.85rem;
  }
  .stat-value {
    font-size: 1.3rem;
  }
  .panel-header {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .panel-body {
    padding: 1rem;
  }
  .table th, .table td {
    padding: 0.6rem 0.75rem;
    font-size: 0.75rem;
  }
}

@media (max-width: 640px) {
  .pagination-wrapper {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    text-align: center;
  }
  .pagination-desktop {
    display: none !important;
  }
  .pagination-mobile {
    display: flex !important;
  }
}

@media (min-width: 641px) {
  .pagination-desktop {
    display: flex !important;
  }
  .pagination-mobile {
    display: none !important;
  }
}

@media (max-width: 480px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
  .stat-card {
    padding: 0.75rem 0.6rem;
  }
  .stat-title {
    font-size: 0.6875rem;
  }
  .stat-value {
    font-size: 1.15rem;
  }
  .stat-sub {
    font-size: 0.6875rem;
  }
  .btn {
    padding: 0.45rem 0.75rem;
    font-size: 0.75rem;
  }
}

/* 11. NOC Operational Visual Dashboard Components */
@keyframes softPulseDanger {
  0%, 100% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  50% { transform: scale(1.15); opacity: 0.85; box-shadow: 0 0 0 4px rgba(239, 68, 68, 0); }
}

@keyframes softPulseWarning {
  0%, 100% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  50% { transform: scale(1.1); opacity: 0.85; box-shadow: 0 0 0 3px rgba(245, 158, 11, 0); }
}

.pulse-danger {
  animation: softPulseDanger 2s infinite ease-in-out;
}

.pulse-warning {
  animation: softPulseWarning 2.5s infinite ease-in-out;
}

.noc-score-circle {
  position: relative;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, rgba(15, 23, 42, 0.9) 60%, transparent 100%);
}

.port-status-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
  gap: 0.45rem;
}

.port-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  text-decoration: none;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.port-chip:hover {
  border-color: #38bdf8;
  color: #fff;
  transform: translateY(-1px);
}

.severity-stacked-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
}

.timeline-feed {
  display: flex;
  flex-direction: column;
}

.timeline-feed-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8125rem;
  transition: background 0.12s ease;
}

.timeline-feed-item:hover {
  background: rgba(255, 255, 255, 0.02);
}

.timeline-feed-item:last-child {
  border-bottom: none;
}

/* 12. Router Card & NOC Visual Refinement */
.router-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.router-card:hover {
  border-color: rgba(56, 189, 248, 0.45);
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.35);
}

.router-health-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.45rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 600;
  color: #cbd5e1;
}

.router-health-chip.temp-ok {
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.25);
  background: rgba(52, 211, 153, 0.08);
}

.router-health-chip.temp-warn {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.25);
  background: rgba(251, 191, 36, 0.08);
}

.router-health-chip.temp-crit {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.08);
}

/* 13. Interactive Latency Rankings & Soft Animations */
.ranking-clickable-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.8rem 0.95rem;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.ranking-clickable-card:hover {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.04);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.ranking-bar-fill {
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.4s ease;
}

.soft-updated-val {
  animation: softHighlight 0.6s ease-out;
}

@keyframes softHighlight {
  0% {
    background-color: rgba(56, 189, 248, 0.3);
    color: #38bdf8;
  }
  100% {
    background-color: transparent;
  }
}

/* 14. Responsive Grid for Fleet Routers */
@media (max-width: 768px) {
  #nocFleetCardsContainer {
    grid-template-columns: 1fr !important;
  }
}

@media (min-width: 769px) and (max-width: 1200px) {
  #nocFleetCardsContainer {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (min-width: 1201px) {
  #nocFleetCardsContainer {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)) !important;
  }
}

/* 15. Smokeping & MRTG Modal System */
.observability-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(4px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.observability-modal-backdrop.open {
  display: flex;
  opacity: 1;
}

.observability-modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 920px;
  max-height: 92vh;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.observability-modal-backdrop.open .observability-modal-dialog {
  transform: translateY(0) scale(1);
}

.table-row-updated {
  animation: rowSoftFlash 0.6s ease-out;
}

@keyframes rowSoftFlash {
  0% {
    background-color: rgba(56, 189, 248, 0.12);
  }
  100% {
    background-color: transparent;
  }
}

/* 15. NOC Operational Quad Cards Layout */
.noc-quad-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  align-items: stretch;
  margin-bottom: 1.5rem;
}

@media (max-width: 1200px) {
  .noc-quad-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .noc-quad-grid {
    grid-template-columns: 1fr;
  }
}

.noc-quad-card {
  min-height: 330px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin-bottom: 0;
  padding: 1.15rem;
  box-sizing: border-box;
}

.noc-quad-header {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border-color);
}

.noc-quad-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 0.5rem 0;
  gap: 0.35rem;
  overflow: hidden;
}

.noc-quad-footer {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border-color);
  padding-top: 0.5rem;
  margin-top: auto;
}