/* ==========================================================================
   switch.css — Switch list page
   ========================================================================== */

/* ==========================================================================
   TOOLBAR
   ========================================================================== */

.switch-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 16px 20px;
  box-sizing: border-box;
}

/* ==========================================================================
   SEARCH
   ========================================================================== */

.switch-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 295px;
  min-width: 295px;
}

.switch-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  color: #64748b;
  pointer-events: none;
  z-index: 2;
}

.switch-search input {
  width: 100%;
  height: 38px;
  box-sizing: border-box;

  padding: 0 12px 0 40px;

  border: 1px solid var(--border);
  border-radius: 8px;

  background: var(--surface);
  color: var(--text);

  font-family: var(--font-body);
  font-size: 13px;

  outline: none;

  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.switch-search input::placeholder {
  color: var(--text-muted);
}

.switch-search input:hover {
  border-color: var(--border-strong);
}

.switch-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ==========================================================================
   FILTERS
   ========================================================================== */

.switch-filters {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-left: auto;
}

.switch-filters .filter-select {
  width: 135px;
  height: 38px;
  box-sizing: border-box;

  padding: 0 34px 0 12px;

  border: 1px solid var(--border);
  border-radius: 8px;

  background: var(--surface);
  color: var(--text);

  font-family: var(--font-body);
  font-size: 13px;

  outline: none;
  cursor: pointer;
}

.switch-filters .filter-select:last-child {
  width: 160px;
}

.switch-filters .filter-select:hover {
  border-color: var(--border-strong);
}

.switch-filters .filter-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ==========================================================================
   SWITCH NAME CELL
   ========================================================================== */

.switch-name-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
}

.switch-icon {
  flex: 0 0 40px;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 40px;
  height: 40px;

  margin: 0;

  border-radius: 9px;

  background: var(--accent-soft);
  color: var(--accent);

  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;

  line-height: 1;
}

.switch-name-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  line-height: 1.35;
}

.switch-name-text strong {
  display: block;

  color: var(--text);

  font-size: 13px;
  font-weight: 600;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.switch-code-inline {
  display: block;

  margin-top: 3px;

  color: var(--text-muted);

  font-family: var(--font-mono);
  font-size: 10.5px;

  line-height: 1.2;
}

/* ==========================================================================
   HOSTNAME
   ========================================================================== */

.switch-hostname {
  display: flex;
  flex-direction: column;
  gap: 3px;

  font-family: var(--font-mono);
  font-size: 12px;

  line-height: 1.35;
}

.switch-hostname-main {
  color: var(--text);
}

.switch-hostname-role {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 12px;
}

/* ==========================================================================
   OPERATIONAL STATUS
   ========================================================================== */

.switch-operational {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;

  white-space: nowrap;
}

.switch-operational::before {
  content: "";

  width: 6px;
  height: 6px;

  flex: 0 0 6px;

  border-radius: 50%;
}

.switch-operational-up {
  color: #067647;
}

.switch-operational-up::before {
  background: var(--success);
}

.switch-operational-down {
  color: #b42318;
}

.switch-operational-down::before {
  background: var(--danger);
}

.switch-operational-degraded {
  color: #b54708;
}

.switch-operational-degraded::before {
  background: var(--warning);
}

/* ==========================================================================
   SUMMARY
   ========================================================================== */

.switch-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));

  width: 100%;

  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.switch-summary-item {
  min-width: 0;

  padding: 16px 22px;

  border-right: 1px solid var(--border);
}

.switch-summary-item:last-child {
  border-right: none;
}

.switch-summary-label {
  display: block;

  color: var(--text-muted);

  font-size: 11px;
  font-weight: 500;

  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.switch-summary-value {
  display: block;

  margin-top: 5px;

  color: var(--text);

  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;

  line-height: 1;
}

/* ==========================================================================
   TABLE
   ========================================================================== */

.switch-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.switch-table-wrap th,
.switch-table-wrap td {
  vertical-align: middle;
}

.switch-table-wrap th {
  white-space: nowrap;
}

.switch-table-wrap tbody tr {
  min-height: 74px;
}

/* ==========================================================================
   FORM / MODAL
   ========================================================================== */

#switchModal {
  width: min(900px, calc(100vw - 32px));
  max-width: 900px;
  max-height: min(88vh, 850px);

  padding: 0;

  border: none;
  border-radius: 12px;

  background: var(--surface);

  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.25);

  overflow: hidden;
}

#switchModal::backdrop {
  background: rgba(15, 23, 42, 0.52);
}

#switchModal form {
  display: flex;
  flex-direction: column;

  width: 100%;
  height: 100%;
  max-height: 88vh;

  margin: 0;
}

#switchModal .modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;

  flex: 0 0 auto;

  padding: 18px 22px;

  border-bottom: 1px solid var(--border);
}

#switchModal .modal-head h3 {
  margin: 0;

  color: var(--text);

  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
}

#switchModal .modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 34px;
  height: 34px;

  padding: 0;

  border: 1px solid var(--border);
  border-radius: 7px;

  background: var(--surface);
  color: var(--text);

  font-size: 16px;

  cursor: pointer;
}

#switchModal .modal-close:hover {
  background: var(--bg);
}

/* ==========================================================================
   MODAL BODY
   ========================================================================== */

#switchModal .modal-body {
  flex: 1 1 auto;

  min-height: 0;

  padding: 20px 22px;

  overflow-y: auto;
  overflow-x: hidden;
}

/* ==========================================================================
   FORM SECTIONS
   ========================================================================== */

#switchModal .form-section-label {
  margin: 4px 0 12px;

  color: var(--text);

  font-size: 13px;
  font-weight: 600;
}

#switchModal .form-section-label:not(:first-child) {
  margin-top: 24px;

  padding-top: 18px;

  border-top: 1px solid var(--border);
}

/* ==========================================================================
   FORM GRID
   ========================================================================== */

#switchModal .form-grid {
  display: grid;

  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);

  gap: 14px 16px;

  width: 100%;
}

#switchModal .form-field {
  min-width: 0;
}

#switchModal .form-field.full {
  grid-column: 1 / -1;
}

#switchModal .form-field label {
  display: block;

  margin-bottom: 6px;

  color: var(--text);

  font-size: 12px;
  font-weight: 600;

  line-height: 1.3;
}

#switchModal .form-field .hint {
  color: var(--text-muted);
  font-weight: 400;
}

/* ==========================================================================
   FORM CONTROLS
   ========================================================================== */

#switchModal .form-field input,
#switchModal .form-field select {
  display: block;

  width: 100%;
  height: 42px;

  box-sizing: border-box;

  padding: 0 12px;

  border: 1px solid var(--border);
  border-radius: 8px;

  background: var(--surface);
  color: var(--text);

  font-family: var(--font-body);
  font-size: 13px;

  outline: none;
}

#switchModal .form-field input:focus,
#switchModal .form-field select:focus {
  border-color: var(--accent);

  box-shadow: 0 0 0 3px var(--accent-soft);
}

#switchModal .form-field input::placeholder {
  color: var(--text-muted);
}

#switchModal .form-field input:disabled {
  background: var(--bg);
  color: var(--text-muted);
  cursor: not-allowed;
}

#switchModal .form-field .mono-input {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ==========================================================================
   FORM NOTE
   ========================================================================== */

#switchModal .switch-form-note {
  margin-top: 20px;

  padding: 11px 13px;

  border: 1px solid var(--border);
  border-radius: 8px;

  background: var(--bg);

  color: var(--text-muted);

  font-size: 11.5px;
  line-height: 1.5;
}

/* ==========================================================================
   MODAL FOOTER
   ========================================================================== */

#switchModal .modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;

  gap: 10px;

  flex: 0 0 auto;

  padding: 14px 22px;

  border-top: 1px solid var(--border);

  background: var(--surface);
}

#switchModal .modal-foot .btn {
  min-width: 100px;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 1000px) {
  .switch-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .switch-search {
    width: 100%;
    min-width: 0;
  }

  .switch-filters {
    width: 100%;
    margin-left: 0;
  }

  .switch-filters .filter-select {
    flex: 1;
    width: auto;
  }

  .switch-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .switch-summary-item:nth-child(2) {
    border-right: none;
  }

  .switch-summary-item:nth-child(-n + 2) {
    border-bottom: 1px solid var(--border);
  }

  #switchModal {
    width: calc(100vw - 20px);
    max-height: 92vh;
  }

  #switchModal form {
    max-height: 92vh;
  }

  #switchModal .form-grid {
    grid-template-columns: 1fr;
  }

  #switchModal .form-field.full {
    grid-column: auto;
  }
}

@media (max-width: 600px) {
  .switch-filters {
    flex-direction: column;
  }

  .switch-filters .filter-select,
  .switch-filters .filter-select:last-child {
    width: 100%;
  }

  .switch-summary {
    grid-template-columns: 1fr;
  }

  .switch-summary-item {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .switch-summary-item:last-child {
    border-bottom: none;
  }

  #switchModal .modal-head,
  #switchModal .modal-body,
  #switchModal .modal-foot {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* ==========================================================================
   SWITCH TABLE — FINAL LAYOUT FIX
   ========================================================================== */

.switch-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.switch-table-wrap table {
  width: 100%;
  min-width: 1120px;

  border-collapse: collapse;
  border-spacing: 0;

  /* IMPORTANT:
     Jangan pakai fixed karena isi kolom Switch cukup panjang. */
  table-layout: auto;
}

/* --------------------------------------------------------------------------
   HEADER
   -------------------------------------------------------------------------- */

.switch-table-wrap thead th {
  height: 46px;
  padding: 0 18px;

  background: var(--bg);

  border-bottom: 1px solid var(--border);

  color: var(--text-muted);

  font-size: 10px;
  font-weight: 700;

  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;

  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   BODY
   -------------------------------------------------------------------------- */

.switch-table-wrap tbody td {
  height: 76px;
  padding: 10px 18px;

  border-bottom: 1px solid var(--border);

  vertical-align: middle;

  box-sizing: border-box;
}

.switch-table-wrap tbody tr {
  transition: background 120ms ease;
}

.switch-table-wrap tbody tr:hover {
  background: #fbfcfd;
}

.switch-table-wrap tbody tr:last-child td {
  border-bottom: none;
}

/* --------------------------------------------------------------------------
   COLUMN WIDTHS
   -------------------------------------------------------------------------- */

/* Switch */
.switch-table-wrap th:nth-child(1),
.switch-table-wrap td:nth-child(1) {
  width: 25%;
  min-width: 280px;
}

/* Hostname / Role */
.switch-table-wrap th:nth-child(2),
.switch-table-wrap td:nth-child(2) {
  width: 15%;
  min-width: 175px;
}

/* Management IP */
.switch-table-wrap th:nth-child(3),
.switch-table-wrap td:nth-child(3) {
  width: 12%;
  min-width: 125px;
}

/* Location */
.switch-table-wrap th:nth-child(4),
.switch-table-wrap td:nth-child(4) {
  width: 15%;
  min-width: 165px;
}

/* Provider */
.switch-table-wrap th:nth-child(5),
.switch-table-wrap td:nth-child(5) {
  width: 10%;
  min-width: 110px;
}

/* Lifecycle */
.switch-table-wrap th:nth-child(6),
.switch-table-wrap td:nth-child(6) {
  width: 9%;
  min-width: 105px;
}

/* Operational */
.switch-table-wrap th:nth-child(7),
.switch-table-wrap td:nth-child(7) {
  width: 9%;
  min-width: 105px;
}

/* Actions */
.switch-table-wrap th:nth-child(8),
.switch-table-wrap td:nth-child(8) {
  width: 100px;
  min-width: 100px;
}

/* ==========================================================================
   SWITCH NAME
   ========================================================================== */

.switch-name-cell {
  display: flex;
  align-items: center;
  gap: 12px;

  width: 100%;
  min-width: 0;
}

.switch-icon {
  flex: 0 0 40px;

  width: 40px;
  height: 40px;

  display: flex;
  align-items: center;
  justify-content: center;

  margin: 0;

  border-radius: 9px;

  background: var(--accent-soft);
  color: var(--accent);

  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
}

.switch-name-text {
  display: flex;
  flex-direction: column;

  min-width: 0;

  line-height: 1.3;
}

.switch-name-text .cell-primary {
  display: block;

  color: var(--text);

  font-size: 13px;
  font-weight: 600;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  text-decoration: none;
}

.switch-name-text .cell-primary:hover {
  color: var(--accent);
}

.switch-code-inline {
  display: block;

  margin-top: 3px;

  color: var(--text-muted);

  font-family: var(--font-mono);
  font-size: 10.5px;

  white-space: nowrap;
}

/* ==========================================================================
   HOSTNAME / ROLE
   ========================================================================== */

.switch-hostname {
  display: block;

  color: var(--text);

  font-family: var(--font-mono);
  font-size: 12px;

  line-height: 1.35;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Role yang berada di bawah hostname */
.switch-table-wrap td:nth-child(2) .cell-muted {
  display: block;

  margin-top: 2px;

  color: var(--text);

  font-family: var(--font-body);
  font-size: 12px;

  line-height: 1.3;
}

/* ==========================================================================
   MANAGEMENT IP
   ========================================================================== */

.switch-table-wrap td:nth-child(3) {
  white-space: nowrap;
}

.switch-table-wrap td.cell-mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ==========================================================================
   LOCATION
   ========================================================================== */

.switch-table-wrap td:nth-child(4) {
  line-height: 1.4;
}

.switch-table-wrap td:nth-child(4) .cell-muted {
  display: block;

  margin-top: 2px;

  color: var(--text);

  font-size: 12px;
}

/* ==========================================================================
   PROVIDER
   ========================================================================== */

.switch-table-wrap td:nth-child(5) {
  white-space: nowrap;
}

/* ==========================================================================
   LIFECYCLE
   ========================================================================== */

.switch-table-wrap td:nth-child(6) {
  white-space: nowrap;
}

/* ==========================================================================
   OPERATIONAL
   ========================================================================== */

.switch-operational {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  white-space: nowrap;

  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

.switch-operational::before {
  content: "";

  width: 6px;
  height: 6px;

  flex: 0 0 6px;

  border-radius: 50%;
}

.switch-operational-up {
  color: #067647;
}

.switch-operational-up::before {
  background: var(--success);
}

.switch-operational-down {
  color: #b42318;
}

.switch-operational-down::before {
  background: var(--danger);
}

.switch-operational-degraded {
  color: #b54708;
}

.switch-operational-degraded::before {
  background: var(--warning);
}

/* ==========================================================================
   ACTIONS
   ========================================================================== */

.switch-table-wrap td.row-actions {
  display: table-cell;

  padding-left: 12px;
  padding-right: 12px;

  white-space: nowrap;
  text-align: right;
}

.switch-table-wrap td.row-actions .icon-btn {
  display: inline-flex;

  align-items: center;
  justify-content: center;

  width: 38px;
  height: 38px;

  margin-left: 5px;

  padding: 0;

  border: 1px solid var(--border);
  border-radius: 8px;

  background: var(--surface);
}

.switch-table-wrap td.row-actions .icon-btn:first-child {
  margin-left: 0;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 1100px) {
  .switch-table-wrap table {
    min-width: 1120px;
  }
}

@media (max-width: 760px) {
  .switch-table-wrap table {
    min-width: 1050px;
  }
}
