/* ==========================================================================
   CAKRA NOC - Site Directory Styles
   ========================================================================== */

.sites-view-container {
  padding: var(--space-lg, 24px);
  height: 100%;
  overflow-y: auto;
}

/* ==========================================================================
   Grid — 3 cards per row
   ========================================================================== */
.sites-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: var(--space-md, 16px);
  width: 100%;
}

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

@media (max-width: 700px) {
  .sites-grid { grid-template-columns: 1fr; gap: 12px; }
}

/* ==========================================================================
   Site Card
   ========================================================================== */
.site-card {
  container-type: inline-size;
  container-name: site-card;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
  position: relative;
}

.site-card:hover {
  border-color: var(--border-focus);
  background-color: var(--bg-surface-hover);
}

/* ==========================================================================
   TOP ROW: Identity | Device+SLA | Status
   ========================================================================== */
.site-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 14px;
  width: 100%;
}

.site-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  min-width: 0;
}

.site-icon-box {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--brand-cyan);
}

.site-info-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.site-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-pill-type {
  background: var(--bg-panel);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  font-size: 0.68rem;
  font-family: var(--font-mono);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
}

.site-pin-icon { width: 10px; height: 10px; flex-shrink: 0; }

/* CENTER: device counts + SLA */
.site-top-center {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  flex: 1;
  min-width: 0;
  padding-left: 2px;
}

.site-device-counts {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary, #0f172a);
  cursor: pointer;
  white-space: nowrap;
  flex-wrap: nowrap;
}

[data-theme="dark"] .site-device-counts,
body.dark-mode .site-device-counts { color: #cbd5e1; }

.site-device-sep { color: #d1d5db; font-weight: 300; }
[data-theme="dark"] .site-device-sep,
body.dark-mode .site-device-sep { color: #334155; }

.site-device-count-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.site-count-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.item-online { color: #16a34a; }
.dot-online { background: #16a34a; box-shadow: 0 0 5px rgba(22,163,74,0.4); }
[data-theme="dark"] .item-online,
body.dark-mode .item-online { color: #4ade80; }
[data-theme="dark"] .dot-online,
body.dark-mode .dot-online { background: #4ade80; }

.item-offline { color: #64748b; }
.dot-offline { background: #94a3b8; }
[data-theme="dark"] .item-offline,
body.dark-mode .item-offline { color: #94a3b8; }

.site-sla-pill {
  background: var(--status-warning-bg);
  border: 1px solid var(--status-warning-border);
  color: var(--status-warning);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  white-space: nowrap;
}

/* RIGHT: Status pill */
.site-status-pill {
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-mono);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  letter-spacing: 0.02em;
  align-self: center;
  border: 1px solid transparent;
}

.site-status-pill-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.site-status-pill.up { background: var(--status-up-bg); color: var(--status-up); border-color: var(--status-up-border); }
.site-status-pill.warning { background: var(--status-warning-bg); color: var(--status-warning); border-color: var(--status-warning-border); }
.site-status-pill.down { background: var(--status-down-bg); color: var(--status-down); border-color: var(--status-down-border); }

.site-status-pill.down { background: #fee2e2; color: #b91c1c; }
[data-theme="dark"] .site-status-pill.down,
body.dark-mode .site-status-pill.down { background: rgba(239,68,68,0.18); color: #f87171; }

.site-status-pill.warning { background: #fef3c7; color: #b45309; }
[data-theme="dark"] .site-status-pill.warning,
body.dark-mode .site-status-pill.warning { background: rgba(245,158,11,0.18); color: #fbbf24; }

.site-status-pill.empty { background: rgba(148,163,184,0.12); color: #64748b; }

/* ==========================================================================
   STATS BAR — 2 Explicit Rows
   Row 1: ISP/WAN | Subnet | Latency
   Row 2: Download | Upload | Speedtest (NEVER WRAP, ALWAYS 1 LINE)
   ========================================================================== */
.site-card-stats-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border-subtle, #f0f2f5);
  border-bottom: 1px solid var(--border-subtle, #f0f2f5);
  padding: 10px 0;
  width: 100%;
}

[data-theme="dark"] .site-card-stats-bar,
body.dark-mode .site-card-stats-bar {
  border-top-color: #1e2d45;
  border-bottom-color: #1e2d45;
}

/* Horizontal separator between Row 1 and Row 2 */
.site-stat-row-sep {
  height: 1px;
  background: var(--border-subtle, #f1f5f9);
  width: 100%;
}

[data-theme="dark"] .site-stat-row-sep,
body.dark-mode .site-stat-row-sep {
  background: #1e2d45;
}

/* Each row: Flex, NO WRAP, Download and Upload never separate! */
.site-stat-row {
  display: flex;
  align-items: center;
  width: 100%;
  flex-wrap: nowrap !important;
  min-width: 0;
}

.site-stat-col {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
}

.site-stat-col.btn-action-view-site-traffic {
  cursor: pointer;
}

.site-stat-col.btn-action-view-site-traffic:hover .site-stat-value {
  text-decoration: underline;
  text-decoration-style: dotted;
}

.site-stat-divider {
  width: 1px;
  height: 26px;
  background: var(--border-subtle, #e9ecef);
  margin: 0 8px;
  flex-shrink: 0;
}

[data-theme="dark"] .site-stat-divider,
body.dark-mode .site-stat-divider {
  background: #1e2d45;
}

.site-stat-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #64748b;
}

[data-theme="dark"] .site-stat-icon-wrapper,
body.dark-mode .site-stat-icon-wrapper {
  color: #94a3b8;
}

.site-stat-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  overflow: hidden;
}

.site-stat-label {
  font-size: 0.67rem;
  color: var(--text-muted, #64748b);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

[data-theme="dark"] .site-stat-label,
body.dark-mode .site-stat-label {
  color: #94a3b8;
}

.site-stat-value {
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--text-primary, #0f172a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

[data-theme="dark"] .site-stat-value,
body.dark-mode .site-stat-value {
  color: #f1f5f9;
}

/* Speedtest cell & button (Compact Amber badge) */
.site-stat-speedtest-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  min-width: 0;
}

.btn-stat-speedtest {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 7px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #d97706;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-family: inherit;
  width: 100%;
  max-width: 96px;
  height: 28px;
  line-height: 1;
}

.btn-stat-speedtest:hover {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #b45309;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.2);
}

[data-theme="dark"] .btn-stat-speedtest,
body.dark-mode .btn-stat-speedtest {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .btn-stat-speedtest:hover,
body.dark-mode .btn-stat-speedtest:hover {
  background: rgba(245, 158, 11, 0.22);
  border-color: #f59e0b;
}

.site-stat-na {
  font-size: 0.72rem;
  color: var(--text-muted, #94a3b8);
  font-style: italic;
  display: inline-block;
  text-align: center;
  width: 100%;
}

/* ==========================================================================
   ACTION BUTTONS — 1 Single Row, Compact, Equal Size, Never Stretched
   ========================================================================== */
.site-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding-top: 12px;
  flex-wrap: nowrap;
}

.btn-card-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  line-height: 1.2;
  white-space: nowrap;
  font-family: inherit;
  flex: 1 1 0;
  min-width: 0;
  height: 33px;
  box-sizing: border-box;
}

.btn-card-action span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-card-action:hover {
  transform: translateY(-1px);
}

/* Topologi */
.btn-card-topo {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.btn-card-topo:hover {
  background: #1d4ed8;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}

/* Neutral: MikroTik, UniFi, Edit */
.btn-card-neutral {
  background: #f8fafc;
  color: #1e293b;
  border-color: #e2e8f0;
}

.btn-card-neutral:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

[data-theme="dark"] .btn-card-neutral,
body.dark-mode .btn-card-neutral {
  background: #1e293b;
  color: #f8fafc;
  border-color: #334155;
}

[data-theme="dark"] .btn-card-neutral:hover,
body.dark-mode .btn-card-neutral:hover {
  background: #273549;
  border-color: #475569;
}

/* Hapus: Compact, Equal width with other buttons, NEVER 100% full width */
.btn-card-danger {
  background: #fff5f5;
  color: #ef4444;
  border-color: #fecaca;
  margin-left: 0;
  width: auto;
  max-width: none;
}

.btn-card-danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

[data-theme="dark"] .btn-card-danger,
body.dark-mode .btn-card-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.25);
}

[data-theme="dark"] .btn-card-danger:hover,
body.dark-mode .btn-card-danger:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: #ef4444;
}

/* ==========================================================================
   RESPONSIVE Container Queries & Media Queries
   ========================================================================== */

@container site-card (max-width: 390px) {
  .site-card {
    padding: 14px 14px 12px;
  }
  .site-stat-col {
    gap: 5px;
  }
  .site-stat-divider {
    margin: 0 5px;
  }
  .site-stat-label {
    font-size: 0.63rem;
  }
  .site-stat-value {
    font-size: 0.80rem;
  }
  .btn-stat-speedtest {
    padding: 3px 6px;
    font-size: 0.70rem;
    height: 25px;
    max-width: 85px;
  }
  .btn-card-action {
    padding: 6px 6px;
    font-size: 0.74rem;
    gap: 4px;
    height: 31px;
  }
}

@container site-card (max-width: 320px) {
  .site-card-actions {
    flex-wrap: wrap;
  }
  .btn-card-action {
    flex: 1 1 calc(50% - 4px);
  }
}

/* ==========================================================================
   COMPANY FILTER BAR & PILLS
   ========================================================================== */
.company-filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.company-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-muted);
  transition: all 0.15s ease;
  user-select: none;
}

.company-filter-btn:hover {
  border-color: var(--color-primary);
  color: var(--text-primary);
  background: var(--bg-surface-hover, rgba(59, 130, 246, 0.08));
}

.company-filter-btn.active {
  background: var(--color-primary, #0284c7);
  border-color: var(--color-primary, #0284c7);
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.28);
}

.company-filter-count {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.08);
  font-weight: 800;
}

.company-filter-btn.active .company-filter-count {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

[data-theme="dark"] .company-filter-btn {
  background: #1e3347;
  border-color: #3d5870;
  color: #A4C8E1;
}

[data-theme="dark"] .company-filter-btn:hover {
  background: #2C3E50;
  color: #F0F0F0;
  border-color: #4A6E8D;
}

[data-theme="dark"] .company-filter-btn.active {
  background: #4A6E8D;
  border-color: #A4C8E1;
  color: #F0F0F0 !important;
}

[data-theme="dark"] .company-filter-count {
  background: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   ZONE BREAKDOWN SECTION (Multi-Zone Sites, e.g. Core + Sub-Areas)
   ========================================================================== */
.site-zones-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-surface-subtle, rgba(248, 250, 252, 0.7));
  border: 1px solid var(--border-subtle, #e2e8f0);
  border-radius: var(--radius-sm, 10px);
  padding: 8px 12px;
  margin: 4px 0 2px 0;
  transition: all 0.2s ease;
}

[data-theme="dark"] .site-zones-section,
body.dark-mode .site-zones-section {
  background: rgba(15, 23, 42, 0.45);
  border-color: rgba(51, 65, 85, 0.6);
}

.site-zones-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.site-zones-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary, #64748b);
}

.site-zones-hint {
  font-size: 0.7rem;
  color: var(--text-muted, #94a3b8);
  font-weight: 500;
}

.site-zones-chip-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* Zone Chip Button */
.site-zone-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 9999px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary, #0f172a);
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .site-zone-chip,
body.dark-mode .site-zone-chip {
  background: rgba(30, 41, 59, 0.7);
  border-color: rgba(51, 65, 85, 0.8);
  color: #f1f5f9;
}

.site-zone-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
  border-color: var(--color-primary, #0284c7);
}

.site-zone-chip-icon {
  font-size: 0.82rem;
  line-height: 1;
}

.site-zone-chip-title {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-zone-chip-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 9999px;
  font-size: 0.68rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.04);
}

/* Status variants */
.site-zone-chip.up {
  border-color: rgba(16, 185, 129, 0.35);
}
.site-zone-chip.up:hover {
  border-color: #10b981;
}
.site-zone-chip.up .site-zone-chip-pill {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}
[data-theme="dark"] .site-zone-chip.up .site-zone-chip-pill {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.site-zone-chip.down {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(254, 242, 242, 0.8);
}
[data-theme="dark"] .site-zone-chip.down {
  background: rgba(69, 10, 10, 0.4);
  border-color: rgba(239, 68, 68, 0.5);
}
.site-zone-chip.down:hover {
  border-color: #ef4444;
}
.site-zone-chip.down .site-zone-chip-pill {
  background: rgba(239, 68, 68, 0.18);
  color: #dc2626;
}
[data-theme="dark"] .site-zone-chip.down .site-zone-chip-pill {
  background: rgba(239, 68, 68, 0.25);
  color: #f87171;
}

.site-zone-chip.warning {
  border-color: rgba(245, 158, 11, 0.4);
}
.site-zone-chip.warning .site-zone-chip-pill {
  background: rgba(245, 158, 11, 0.14);
  color: #d97706;
}
[data-theme="dark"] .site-zone-chip.warning .site-zone-chip-pill {
  background: rgba(245, 158, 11, 0.22);
  color: #fbbf24;
}

/* Zone Dot indicator */
.site-zone-chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.site-zone-chip.up .site-zone-chip-dot {
  background: #10b981;
  box-shadow: 0 0 4px rgba(16, 185, 129, 0.5);
}
.site-zone-chip.down .site-zone-chip-dot {
  background: #ef4444;
  box-shadow: 0 0 5px rgba(239, 68, 68, 0.6);
  animation: pulse-dot 1.8s infinite ease-in-out;
}
.site-zone-chip.warning .site-zone-chip-dot {
  background: #f59e0b;
  box-shadow: 0 0 4px rgba(245, 158, 11, 0.5);
}

/* Multi-Router Dropdown on Site Card */
.site-router-dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.site-router-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-sm, 8px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  padding: 5px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: routerMenuFadeIn 0.15s ease-out;
}

[data-theme="dark"] .site-router-menu,
body.dark-mode .site-router-menu {
  background: #1e3347;
  border-color: #3d5870;
  box-shadow: 0 10px 25px -5px rgba(15, 28, 40, 0.6);
}

@keyframes routerMenuFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.site-router-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  color: var(--text-primary);
  font-family: inherit;
  transition: background 0.12s ease;
}

.site-router-menu-item:hover {
  background: var(--bg-surface-hover, rgba(59, 130, 246, 0.08));
}

[data-theme="dark"] .site-router-menu-item:hover {
  background: #2C3E50;
}

.site-router-menu-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.site-router-menu-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.site-router-menu-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-router-menu-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono, monospace);
}

