/* Modern UI v75 — complemento ao style.css */

:root {
  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-text-active: #fff;
}

[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #111827;
  --surface2: #1f2937;
  --sidebar-bg: #030712;
  --border: #374151;
  --border-strong: #4b5563;
  --text: #f3f4f6;
  --text-soft: #d1d5db;
  --muted: #9ca3af;
  --primary-soft: #0c4a6e;
  --success-soft: #064e3b;
  --warning-soft: #78350f;
  --danger-soft: #7f1d1d;
  --info-soft: #1e3a5f;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] tr.clickable-row.selected td { background: #1e3a5f; }
[data-theme="dark"] .nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
[data-theme="dark"] .connect-box { background: var(--surface2); border-color: var(--border); }
[data-theme="dark"] .connect-title, [data-theme="dark"] .connect-ip { color: var(--primary); }

.sidebar { color: var(--sidebar-text); }
.sidebar .nav-item { color: var(--sidebar-text); }
.sidebar .nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar .nav-item.active { background: var(--primary); color: var(--sidebar-text-active); }
.sidebar .sidebar-link, .sidebar .user-info { color: #94a3b8; }
.sidebar .sidebar-link:hover { color: #fff; }
.sidebar .nav-item-admin { border-top-color: rgba(255,255,255,0.1); }

.mobile-menu-btn { display: none; }
.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.55);
  z-index: 150;
}

.stat-card {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  padding: 0.38rem 0.7rem;
  min-height: 0;
}
.stat-card-clickable { cursor: pointer; transition: transform 0.12s, box-shadow 0.12s; }
.stat-card-clickable:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.stat-icon {
  width: 1.65rem; height: 1.65rem; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon svg { width: 0.9rem; height: 0.9rem; }
.stat-icon-net { background: #e0f2fe; color: #0284c7; }
.stat-icon-pc { background: #d1fae5; color: #059669; }
.stat-icon-pend { background: #fef3c7; color: #d97706; }
.stat-icon-auto { background: #ede9fe; color: #7c3aed; }
.stat-body {
  flex: 1; min-width: 0;
  display: flex; flex-direction: row; align-items: center; gap: 0.35rem;
  flex-wrap: nowrap;
}
.stat-body .stat-label { display: inline; flex-shrink: 0; }
.stat-body .stat-value { display: inline; font-size: 1rem; flex-shrink: 0; }
.stat-body .stat-sub {
  display: inline; flex: 1; min-width: 0;
  text-align: right; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.stat-progress {
  flex: 1; min-width: 2rem; max-width: 3.5rem;
  height: 3px; background: var(--border); border-radius: 99px;
  overflow: hidden; margin: 0;
}
.stat-progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--success), #34d399);
  border-radius: 99px; transition: width 0.35s ease;
}

.breadcrumb-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.35rem;
  margin-bottom: 0.85rem; font-size: 0.88rem; color: var(--muted);
}
.breadcrumb-bar button {
  background: none; border: none; padding: 0.15rem 0.25rem; cursor: pointer;
  color: var(--primary-dark); font-weight: 600; font-size: inherit;
}
.breadcrumb-bar button:hover { text-decoration: underline; }
.breadcrumb-bar .crumb-current { color: var(--text); font-weight: 700; }
.breadcrumb-sep { opacity: 0.45; user-select: none; }

.split-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  align-items: start;
}
.split-layout.split-has-side {
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 1rem;
}
.split-main { min-width: 0; }
.split-side {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 10rem);
  overflow: auto;
}
.split-side-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* Painel logado: rolagem interna nas views, nunca na página inteira */
html:has(#app-screen:not(.hidden)),
body:has(#app-screen:not(.hidden)) {
  height: 100%;
  overflow: hidden;
}

/* Computadores: rolagem só na tabela; topo e filtro fixos */
.main-column {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.content-card.views-area {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0.75rem 1rem;
}

.view:not(.hidden) {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

#view-overview:not(.hidden) {
  overflow: hidden;
}

#view-overview:not(.hidden) #overview-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  align-content: start;
}

#view-computers:not(.hidden) {
  overflow: hidden;
}

#view-computers .breadcrumb-bar {
  flex-shrink: 0;
}

#view-computers .computers-head {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  margin-bottom: 0.65rem;
}

.computers-head-text { min-width: 0; }

.computers-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: #0c4a6e;
  line-height: 1.2;
  margin: 0 0 0.2rem;
}

.computers-crumb.breadcrumb-bar {
  margin-bottom: 0;
  font-size: 0.84rem;
}

.computers-crumb .crumb-root { color: var(--muted); font-weight: 500; }

.computers-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem 0.85rem;
  flex-shrink: 0;
}

.computers-toolbar-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.computers-toolbar-field label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.computers-select {
  min-width: 11.5rem;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
}

.computers-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

.btn-computers-refresh {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.52rem 1rem;
  border: none;
  border-radius: 8px;
  background: #0c4a6e;
  color: #fff;
  font-size: 0.86rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
  box-shadow: 0 1px 2px rgba(12, 74, 110, 0.2);
}

.btn-computers-refresh:hover:not(:disabled) { background: #075985; }
.btn-computers-refresh:active:not(:disabled) { transform: scale(0.98); }
.btn-computers-refresh:disabled { opacity: 0.65; cursor: wait; }

.computers-refresh-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.btn-computers-refresh.is-loading .computers-refresh-icon {
  animation: computers-spin 0.75s linear infinite;
}

@keyframes computers-spin {
  to { transform: rotate(360deg); }
}

.computers-table-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

#view-computers .filter-bar-2 {
  display: none;
}

#view-computers .split-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

#view-computers .split-layout.split-has-side {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 1rem;
  align-items: stretch;
}

#view-computers .split-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  height: 100%;
}

#view-computers .table-wrap.computers-table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: auto;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

#view-computers .table-wrap.computers-table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--border);
}

table.computers-table {
  width: 100%;
  border-collapse: collapse;
}

table.computers-table thead th {
  padding: 0.85rem 1.15rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.computers-table thead th:last-child { text-align: right; }

table.computers-table tbody td {
  padding: 0.65rem 1rem;
  font-size: 0.88rem;
  color: var(--text-soft);
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

table.computers-table tbody tr:last-child td { border-bottom: none; }

table.computers-table tbody tr.clickable-row {
  cursor: pointer;
  transition: background 0.12s ease;
}

table.computers-table tbody tr.clickable-row:hover td {
  background: #f8fafc;
}

table.computers-table tbody tr.clickable-row.selected td {
  background: #e0f2fe;
}

table.computers-table .pc-cell-name {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  color: #0369a1;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

table.computers-table .pc-cell-host {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: #94a3b8;
  line-height: 1.3;
}

table.computers-table .pc-cell-net {
  font-weight: 700;
  color: #0369a1;
  font-size: 0.88rem;
}

table.computers-table .pc-cell-ip code {
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
  background: #f1f5f9;
  padding: 0.2rem 0.45rem;
  border-radius: 5px;
}

table.computers-table .pc-cell-ip .hint-inline {
  font-size: 0.84rem;
  color: var(--muted);
}

table.computers-table td[data-label="Ações"] { text-align: right; }

table.computers-table .action-cell {
  gap: 0.15rem;
}

table.computers-table .icon-btn {
  width: 2.1rem;
  height: 2.1rem;
  color: #64748b;
  border-radius: 8px;
}

table.computers-table .icon-btn:hover {
  background: #f1f5f9;
  color: #0c4a6e;
}

.status-pill {
  display: inline-block;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.status-pill--online {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}

.status-pill--offline {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
}

.computers-table-foot {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.85rem 1.15rem;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}

.computers-table-count {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
}

.computers-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.computers-page-btn {
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.computers-page-btn:hover:not(:disabled):not(.is-active) {
  background: var(--surface2);
  border-color: var(--border-strong);
}

.computers-page-btn.is-active {
  background: #0c4a6e;
  border-color: #0c4a6e;
  color: #fff;
}

.computers-page-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.computers-page-ellipsis {
  padding: 0 0.25rem;
  color: var(--muted);
  font-size: 0.82rem;
  user-select: none;
}

table.computers-table .computers-empty {
  padding: 2rem 1.15rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-dot-wrap { display: inline-flex; align-items: center; gap: 0.4rem; }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--muted);
}
.status-dot.online { background: var(--success); box-shadow: 0 0 0 3px rgba(16,185,129,0.25); }
.status-dot.online.pulse { animation: status-pulse 2s ease-in-out infinite; }
@keyframes status-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(16,185,129,0.25); }
  50% { box-shadow: 0 0 0 6px rgba(16,185,129,0.08); }
}

.action-cell { display: flex; align-items: center; gap: 0.2rem; justify-content: flex-end; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; padding: 0; border: 1px solid transparent;
  border-radius: 8px; background: transparent; color: var(--text-soft);
  cursor: pointer; transition: background 0.12s, color 0.12s;
}
.icon-btn svg { width: 1rem; height: 1rem; }
.icon-btn:hover { background: var(--primary-soft); color: var(--primary-dark); }
.icon-btn.icon-danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn.icon-primary { color: var(--primary-dark); border-color: var(--border); }
.icon-btn.icon-primary:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

.kebab-wrap { position: relative; }
.kebab-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 50;
  min-width: 10.5rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); padding: 0.35rem;
}
.kebab-menu.kebab-menu-fixed {
  position: fixed;
  right: auto;
  z-index: 10050;
}
.kebab-menu button {
  display: block; width: 100%; text-align: left;
  padding: 0.5rem 0.65rem; border: none; background: none;
  border-radius: 7px; font-size: 0.84rem; font-weight: 600;
  color: var(--text-soft); cursor: pointer;
}
.kebab-menu button:hover { background: var(--surface2); color: var(--text); }
.kebab-menu button.menu-danger { color: var(--danger); }
.kebab-menu button.menu-danger:hover { background: var(--danger-soft); }

.skeleton-row td { padding: 0.85rem 1rem; }
.skeleton-block {
  height: 0.85rem; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 200% 100%; animation: skeleton-shimmer 1.2s infinite;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}
.overview-grid-search .overview-search-head {
  grid-column: 1 / -1;
}
.overview-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
}
.overview-card h3 {
  font-size: 0.82rem; margin-bottom: 0.4rem; color: var(--text);
}
.overview-list { list-style: none; }
.overview-list li {
  display: flex; justify-content: space-between; align-items: center;
  gap: 0.5rem; padding: 0.3rem 0; border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}
.overview-list.overview-list-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 0.85rem;
}
.overview-list.overview-list-cols li {
  min-width: 0;
}
.overview-list li:last-child { border-bottom: none; }
.overview-list button {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--primary-dark); font-weight: 600; text-align: left;
}
.overview-list button:hover { text-decoration: underline; }

.overview-search-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.15rem;
}
.overview-search-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}
.overview-card-wide {
  grid-column: 1 / -1;
}
.search-result-meta {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: right;
  flex-shrink: 0;
}
.search-result-meta code {
  font-size: 0.78rem;
}

.automation-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}
.automation-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; margin-bottom: 0.5rem;
}
.connect-box {
  border-color: var(--border) !important;
  background: var(--surface2) !important;
}
.connect-title { color: var(--muted) !important; }
.connect-ip { color: var(--primary-dark) !important; }

.modal-drawer {
  margin: 0 0 0 auto;
  max-width: min(520px, 96vw);
  width: 100%;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  border-left: 1px solid var(--border);
  animation: drawer-in 0.22s ease;
}
@keyframes drawer-in {
  from { transform: translateX(100%); opacity: 0.6; }
  to { transform: translateX(0); opacity: 1; }
}
.modal-drawer::backdrop { background: rgba(15,23,42,0.4); }

.app-loading .content-card { opacity: 0.55; pointer-events: none; }

@media (max-width: 1024px) {
  .split-layout.split-has-side { grid-template-columns: 1fr; }
  .split-side { position: static; max-height: none; }
  .overview-grid { grid-template-columns: 1fr; }
}

body.remote-viewer-fs-active { overflow: hidden; }

@media (max-width: 768px) {
  .mobile-menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-overlay { display: block !important; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 769px) {
  table.mobile-table.mobile-table-cards thead {
    display: table-header-group;
  }
  table.mobile-table.mobile-table-cards tbody tr {
    display: table-row;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
  }
  table.mobile-table.mobile-table-cards td {
    display: table-cell;
    text-align: inherit;
    padding: inherit;
  }
  table.mobile-table.mobile-table-cards td::before {
    display: none;
  }
  table.mobile-table.mobile-table-cards .row-actions {
    flex-direction: row;
    align-items: center;
    width: auto;
  }
  table.mobile-table.mobile-table-cards .row-actions .btn {
    width: auto;
    min-height: auto;
  }
}
