/* ==========================================================================
   NETASSET — VM PAGE
   Virtual Resources / Virtual Machines

   IMPORTANT:
   This CSS is synchronized with vm.html.

   HTML classes used:
   .vm-page
   .vm-list-card
   .list-toolbar
   .search-wrap
   .search-icon
   .filter-group
   .stats-grid
   .stat-card
   .table-wrap
   .vm-table
   .list-footer
   ========================================================================== */

/* ==========================================================================
   1. PAGE
   ========================================================================== */

.vm-page {
  width: 100%;
  max-width: 100%;
}

/* ==========================================================================
   2. VM LIST CARD
   ========================================================================== */

.vm-list-card {
  width: 100%;
  overflow: hidden;

  border: 1px solid var(--border);
  border-radius: 12px;

  background: var(--surface);

  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   3. TOOLBAR
   ========================================================================== */

.vm-list-card .list-toolbar {
  display: flex;

  align-items: center;
  justify-content: space-between;

  gap: 20px;

  min-height: 72px;

  padding: 14px 18px;

  border-bottom: 1px solid var(--border);

  background: var(--surface);
}

/* --------------------------------------------------------------------------
   SEARCH
   -------------------------------------------------------------------------- */

.vm-list-card .search-wrap {
  position: relative;

  width: 390px;
  max-width: 100%;

  flex: 0 1 390px;
}

.vm-list-card .search-wrap input {
  display: block;

  width: 100%;
  height: 40px;

  box-sizing: border-box;

  padding: 0 14px 0 38px;

  border: 1px solid var(--border);
  border-radius: 8px;

  outline: none;

  background: var(--surface);

  color: var(--text);

  font-family: var(--font-body);
  font-size: 13px;

  transition:
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.vm-list-card .search-wrap input::placeholder {
  color: var(--text-muted);
}

.vm-list-card .search-wrap input:focus {
  border-color: var(--accent);

  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* --------------------------------------------------------------------------
   SEARCH ICON
   -------------------------------------------------------------------------- */

.vm-list-card .search-icon {
  position: absolute;

  left: 13px;
  top: 50%;

  z-index: 2;

  display: flex;

  align-items: center;
  justify-content: center;

  width: 16px;
  height: 16px;

  color: var(--text-muted);

  font-size: 15px;
  line-height: 1;

  transform: translateY(-50%);

  pointer-events: none;
}

/* --------------------------------------------------------------------------
   FILTERS
   -------------------------------------------------------------------------- */

.vm-list-card .filter-group {
  display: flex;

  align-items: center;

  gap: 10px;

  flex-shrink: 0;
}

.vm-list-card .filter-group select {
  width: 160px;
  height: 40px;

  box-sizing: border-box;

  padding: 0 12px;

  border: 1px solid var(--border);
  border-radius: 8px;

  outline: none;

  background: var(--surface);

  color: var(--text);

  font-family: var(--font-body);
  font-size: 13px;

  cursor: pointer;

  transition:
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.vm-list-card .filter-group select:focus {
  border-color: var(--accent);

  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ==========================================================================
   4. STATISTICS
   ========================================================================== */

/*
   IMPORTANT:
   HTML menggunakan .stats-grid
   bukan .stat-grid.
*/

.vm-list-card .stats-grid {
  display: grid;

  grid-template-columns: repeat(4, minmax(0, 1fr));

  width: 100%;

  border-bottom: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   STAT CARD
   -------------------------------------------------------------------------- */

.vm-list-card .stats-grid .stat-card {
  display: flex;

  min-width: 0;
  min-height: 96px;

  flex-direction: column;
  justify-content: center;

  padding: 18px 22px;

  border-right: 1px solid var(--border);
}

.vm-list-card .stats-grid .stat-card:last-child {
  border-right: none;
}

/* --------------------------------------------------------------------------
   STAT LABEL
   -------------------------------------------------------------------------- */

.vm-list-card .stat-label {
  display: block;

  margin-bottom: 8px;

  color: var(--text-muted);

  font-size: 10px;
  font-weight: 600;

  letter-spacing: 0.07em;

  line-height: 1.2;

  text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   STAT VALUE

   HTML:
   <strong id="totalVm">5</strong>
   -------------------------------------------------------------------------- */

.vm-list-card .stats-grid .stat-card strong {
  display: block;

  color: var(--text);

  font-family: var(--font-display, "Space Grotesk", sans-serif);

  font-size: 24px;
  font-weight: 600;

  line-height: 1;
}

/* ==========================================================================
   5. TABLE WRAPPER
   ========================================================================== */

/*
   IMPORTANT:
   HTML menggunakan .table-wrap
   bukan .table-wrapper.
*/

.vm-list-card .table-wrap {
  width: 100%;

  overflow-x: auto;
  overflow-y: hidden;

  -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   6. VM TABLE
   ========================================================================== */

.vm-table {
  width: 100%;

  min-width: 1180px;

  border-collapse: collapse;

  table-layout: fixed;
}

/* --------------------------------------------------------------------------
   TABLE CELLS
   -------------------------------------------------------------------------- */

.vm-table th,
.vm-table td {
  box-sizing: border-box;

  padding: 13px 16px;

  border-bottom: 1px solid var(--border);

  text-align: left;

  vertical-align: middle;
}

/* --------------------------------------------------------------------------
   TABLE HEADER
   -------------------------------------------------------------------------- */

.vm-table th {
  height: 44px;

  padding-top: 0;
  padding-bottom: 0;

  background: var(--bg);

  color: var(--text-muted);

  font-size: 10px;
  font-weight: 600;

  letter-spacing: 0.06em;

  line-height: 1;

  text-transform: uppercase;

  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   TABLE BODY
   -------------------------------------------------------------------------- */

.vm-table td {
  height: 76px;

  color: var(--text);

  font-size: 12px;
}

.vm-table tbody tr {
  transition: background 140ms ease;
}

.vm-table tbody tr:hover {
  background: #f9fbfd;
}

.vm-table tbody tr:last-child td {
  border-bottom: none;
}

/* ==========================================================================
   7. TABLE COLUMN WIDTHS
   ========================================================================== */

.vm-table th:nth-child(1),
.vm-table td:nth-child(1) {
  width: 19%;
}

.vm-table th:nth-child(2),
.vm-table td:nth-child(2) {
  width: 17%;
}

.vm-table th:nth-child(3),
.vm-table td:nth-child(3) {
  width: 11%;
}

.vm-table th:nth-child(4),
.vm-table td:nth-child(4) {
  width: 10%;
}

.vm-table th:nth-child(5),
.vm-table td:nth-child(5) {
  width: 9%;
}

.vm-table th:nth-child(6),
.vm-table td:nth-child(6) {
  width: 13%;
}

.vm-table th:nth-child(7),
.vm-table td:nth-child(7) {
  width: 9%;
}

.vm-table th:nth-child(8),
.vm-table td:nth-child(8) {
  width: 9%;
}

.vm-table th:nth-child(9),
.vm-table td:nth-child(9) {
  width: 12%;
}

/* ==========================================================================
   8. TABLE TEXT
   ========================================================================== */

.table-primary {
  display: block;

  color: var(--text);

  font-size: 12px;
  font-weight: 600;

  line-height: 1.35;
}

.table-secondary {
  display: block;

  margin-top: 3px;

  color: var(--text-muted);

  font-size: 10px;

  line-height: 1.35;
}

.mono {
  font-family: var(--font-mono);
  font-size: 11px;
}

/* ==========================================================================
   9. VM CODE LINK
   ========================================================================== */

.table-link {
  display: block;

  margin-bottom: 3px;

  padding: 0;

  border: none;

  background: transparent;

  color: var(--accent-dark);

  font-family: var(--font-mono);

  font-size: 10px;
  font-weight: 500;

  line-height: 1.3;

  cursor: pointer;
}

.table-link:hover {
  text-decoration: underline;
}

/* ==========================================================================
   10. STATUS BADGES
   ========================================================================== */

.status-badge {
  display: inline-flex;

  align-items: center;
  justify-content: center;

  gap: 6px;

  min-height: 26px;

  padding: 5px 10px;

  border-radius: 999px;

  font-size: 10px;
  font-weight: 600;

  line-height: 1;

  white-space: nowrap;
}

.status-badge::before {
  content: "";

  width: 6px;
  height: 6px;

  flex: 0 0 6px;

  border-radius: 50%;

  background: currentColor;
}

/* Lifecycle */

.status-badge.active,
.status-badge.provisioned {
  background: var(--success-soft);

  color: #07966a;
}

.status-badge.maintenance {
  background: var(--warning-soft);

  color: #d97706;
}

.status-badge.retired {
  background: var(--danger-soft);

  color: #dc2626;
}

/* Operational */

.status-badge.running {
  background: var(--success-soft);

  color: #07966a;
}

.status-badge.stopped {
  background: var(--neutral-soft);

  color: #64748b;
}

.status-badge.paused {
  background: var(--warning-soft);

  color: #d97706;
}

.status-badge.down {
  background: var(--danger-soft);

  color: #dc2626;
}

/* ==========================================================================
   11. ACTIONS
   ========================================================================== */

.table-actions {
  display: flex;

  align-items: center;
  justify-content: flex-start;

  gap: 6px;

  white-space: nowrap;
}

.action-btn {
  display: inline-flex;

  align-items: center;
  justify-content: center;

  min-width: 34px;
  height: 34px;

  padding: 0 9px;

  border: 1px solid var(--border);
  border-radius: 8px;

  background: var(--surface);

  color: var(--text-muted);

  font-family: var(--font-body);

  font-size: 11px;
  font-weight: 600;

  cursor: pointer;

  transition:
    background 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    transform 140ms ease;
}

.action-btn:hover {
  background: var(--bg);

  border-color: var(--border-strong);

  color: var(--text);

  transform: translateY(-1px);
}

.action-btn-danger:hover {
  border-color: #f3b5b5;

  background: var(--danger-soft);

  color: var(--danger);
}

/* ==========================================================================
   12. FOOTER
   ========================================================================== */

.vm-list-card .list-footer {
  display: flex;

  align-items: center;
  justify-content: space-between;

  gap: 12px;

  min-height: 50px;

  padding: 9px 16px;

  border-top: 1px solid var(--border);

  background: var(--surface);

  color: var(--text-muted);

  font-size: 11px;
}

/* --------------------------------------------------------------------------
   RESET BUTTON
   -------------------------------------------------------------------------- */

.vm-list-card .btn-reset {
  min-height: 34px;

  padding: 0 12px;

  border: 1px solid var(--border);
  border-radius: 8px;

  background: var(--surface);

  color: var(--text);

  font-family: var(--font-body);

  font-size: 11px;
  font-weight: 600;

  cursor: pointer;

  transition:
    background 140ms ease,
    border-color 140ms ease;
}

.vm-list-card .btn-reset:hover {
  background: var(--bg);

  border-color: var(--border-strong);
}

/* ==========================================================================
   13. EMPTY STATE
   ========================================================================== */

.vm-list-card .empty-state {
  display: flex;

  align-items: center;
  justify-content: center;

  flex-direction: column;

  min-height: 220px;

  gap: 6px;

  color: var(--text-muted);

  text-align: center;
}

.vm-list-card .empty-state strong {
  color: var(--text);

  font-size: 13px;
}

.vm-list-card .empty-state span {
  font-size: 11px;
}

/* ==========================================================================
   14. VM MODAL
   ========================================================================== */

.vm-modal {
  width: min(900px, calc(100vw - 32px));

  max-width: 900px;
  max-height: calc(100vh - 32px);

  margin: auto;
  padding: 0;

  overflow: hidden;

  border: 1px solid var(--border);
  border-radius: 14px;

  background: var(--surface);

  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

.vm-modal::backdrop {
  background: rgba(15, 23, 42, 0.56);
}

.vm-form {
  display: flex;

  max-height: calc(100vh - 32px);

  flex-direction: column;
}

/* ==========================================================================
   15. MODAL HEADER
   ========================================================================== */

.vm-modal .modal-header {
  display: flex;

  align-items: flex-start;
  justify-content: space-between;

  gap: 20px;

  padding: 22px 28px;

  border-bottom: 1px solid var(--border);

  background: var(--surface);
}

.vm-modal .modal-eyebrow {
  display: block;

  margin-bottom: 5px;

  color: var(--accent-dark);

  font-family: var(--font-mono);

  font-size: 10px;
  font-weight: 600;

  letter-spacing: 0.08em;

  text-transform: uppercase;
}

.vm-modal .modal-header h2 {
  margin: 0;

  color: var(--text);

  font-family: var(--font-display);

  font-size: 22px;
  font-weight: 600;

  line-height: 1.2;
}

.vm-modal .modal-close {
  display: inline-flex;

  align-items: center;
  justify-content: center;

  width: 36px;
  height: 36px;

  flex: 0 0 36px;

  padding: 0;

  border: 1px solid var(--border);
  border-radius: 8px;

  background: var(--surface);

  color: var(--text);

  font-size: 20px;
  line-height: 1;

  cursor: pointer;
}

.vm-modal .modal-close:hover {
  background: var(--bg);

  border-color: var(--border-strong);
}

/* ==========================================================================
   16. MODAL BODY
   ========================================================================== */

.vm-modal .modal-body {
  flex: 1;

  overflow-y: auto;

  background: var(--surface);
}

/* ==========================================================================
   17. FORM SECTION
   ========================================================================== */

.vm-modal .form-section {
  padding: 24px 28px;

  border-bottom: 1px solid var(--border);
}

.vm-modal .form-section:last-child {
  border-bottom: none;
}

.vm-modal .form-section-title {
  margin-bottom: 18px;
}

.vm-modal .form-section-title h3 {
  margin: 0 0 5px;

  color: var(--text);

  font-family: var(--font-display);

  font-size: 16px;
  font-weight: 600;

  line-height: 1.25;
}

.vm-modal .form-section-title p {
  margin: 0;

  color: var(--text-muted);

  font-size: 12px;

  line-height: 1.45;
}

/* ==========================================================================
   18. FORM GRID
   ========================================================================== */

.vm-modal .form-grid {
  display: grid;

  grid-template-columns: repeat(2, minmax(0, 1fr));

  gap: 18px 20px;
}

/* ==========================================================================
   19. FORM FIELD

   HTML uses:
   <label class="field">
   ========================================================================== */

.vm-modal .field {
  display: flex;

  min-width: 0;

  flex-direction: column;

  gap: 7px;
}

.vm-modal .field-full {
  grid-column: 1 / -1;
}

.vm-modal .field > span {
  color: var(--text);

  font-size: 12px;
  font-weight: 600;

  line-height: 1.3;
}

.vm-modal .field > span b {
  color: var(--danger);

  font-weight: 600;
}

/* ==========================================================================
   20. FORM CONTROLS
   ========================================================================== */

.vm-modal .field input,
.vm-modal .field select,
.vm-modal .field textarea {
  display: block;

  width: 100%;

  min-height: 42px;

  box-sizing: border-box;

  padding: 0 12px;

  border: 1px solid var(--border-strong);
  border-radius: 8px;

  outline: none;

  background: var(--surface);

  color: var(--text);

  font-family: var(--font-body);

  font-size: 13px;

  transition:
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.vm-modal .field textarea {
  min-height: 100px;

  padding: 10px 12px;

  resize: vertical;
}

.vm-modal .field input::placeholder {
  color: var(--text-muted);
}

.vm-modal .field input:focus,
.vm-modal .field select:focus,
.vm-modal .field textarea:focus {
  border-color: var(--accent);

  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ==========================================================================
   21. MODAL FOOTER
   ========================================================================== */

.vm-modal .modal-footer {
  display: flex;

  align-items: center;
  justify-content: flex-end;

  gap: 10px;

  padding: 14px 28px;

  border-top: 1px solid var(--border);

  background: var(--surface);
}

/* ==========================================================================
   22. RESPONSIVE — TABLET
   ========================================================================== */

@media (max-width: 1100px) {
  .vm-list-card .search-wrap {
    width: 320px;

    flex-basis: 320px;
  }

  .vm-list-card .filter-group select {
    width: 145px;
  }
}

/* ==========================================================================
   23. RESPONSIVE — 900px
   ========================================================================== */

@media (max-width: 900px) {
  .vm-list-card .list-toolbar {
    align-items: stretch;

    flex-direction: column;

    gap: 12px;
  }

  .vm-list-card .search-wrap {
    width: 100%;

    flex: 1 1 auto;
  }

  .vm-list-card .filter-group {
    width: 100%;
  }

  .vm-list-card .filter-group select {
    width: 100%;

    flex: 1;

    min-width: 0;
  }

  .vm-modal .form-grid {
    grid-template-columns: 1fr;
  }

  .vm-modal .field-full {
    grid-column: auto;
  }
}

/* ==========================================================================
   24. RESPONSIVE — 700px
   ========================================================================== */

@media (max-width: 700px) {
  .vm-list-card .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vm-list-card .stats-grid .stat-card:nth-child(2) {
    border-right: none;
  }

  .vm-list-card .stats-grid .stat-card:nth-child(-n + 2) {
    border-bottom: 1px solid var(--border);
  }

  .vm-list-card .list-footer {
    align-items: flex-start;

    flex-direction: column;
  }
}

/* ==========================================================================
   25. RESPONSIVE — MOBILE
   ========================================================================== */

@media (max-width: 600px) {
  .vm-list-card .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vm-list-card .stats-grid .stat-card {
    min-height: 82px;

    padding: 15px 16px;
  }

  .vm-list-card .stat-label {
    font-size: 9px;
  }

  .vm-list-card .stats-grid .stat-card strong {
    font-size: 21px;
  }

  .vm-list-card .filter-group {
    flex-direction: column;
  }

  .vm-list-card .filter-group select {
    width: 100%;
  }

  .vm-modal {
    width: calc(100vw - 20px);

    max-height: calc(100vh - 20px);
  }

  .vm-modal .modal-header {
    padding: 18px 20px;
  }

  .vm-modal .form-section {
    padding: 20px;
  }

  .vm-modal .modal-footer {
    padding: 12px 20px;
  }
}

/* ==========================================================================
   26. SAFETY OVERRIDES
   ========================================================================== */

/*
   Prevent long technical values from breaking the table layout.
*/

.vm-table td {
  overflow: hidden;
}

.vm-table td > * {
  min-width: 0;
}

.vm-table .mono {
  overflow: hidden;

  text-overflow: ellipsis;

  white-space: nowrap;
}

/* ==========================================================================
   27. BUTTON ALIGNMENT
   ========================================================================== */

.vm-table td:last-child {
  white-space: nowrap;
}

.vm-table td:last-child .table-actions {
  justify-content: flex-start;
}

/* ==========================================================================
   END
   ========================================================================== */
