/* ─── HomeLab Center Styles ─────────────────────────────────── */

:root {
  --primary: #0d6efd;
  --success: #198754;
  --danger: #dc3545;
  --warning: #ffc107;
  --info: #0dcaf0;
  --dark: #212529;
  --sidebar-width: 260px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: #f5f6fa;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Auth Page ───────────────────────────────────────────────── */

.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0d6efd 0%, #6610f2 100%);
}

.auth-card {
  background: white;
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.auth-card h2 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--dark);
}

/* ─── Navbar ──────────────────────────────────────────────────── */

.navbar-brand {
  font-weight: 700;
  font-size: 1.25rem;
}

/* ─── Overview Cards ──────────────────────────────────────────── */

.stat-card {
  background: white;
  border-radius: 10px;
  padding: 1.25rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--dark);
}

.stat-card .stat-label {
  font-size: 0.85rem;
  color: #6c757d;
  margin-top: 0.25rem;
}

/* ─── Server Cards ────────────────────────────────────────────── */

.server-card {
  background: white;
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: all 0.2s;
  cursor: pointer;
  border: 2px solid transparent;
  direction: ltr;
  text-align: left;
}

.server-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  border-color: var(--primary);
}

.server-card .server-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.25rem;
  line-height: 1.3;
  word-break: break-word;
  unicode-bidi: plaintext;
}

.server-card .server-platform {
  color: #6c757d;
  font-size: 0.85rem;
  line-height: 1.25;
  word-break: break-word;
  unicode-bidi: plaintext;
}

.server-card .server-ip {
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  color: #495057;
  line-height: 1.25;
  word-break: break-all;
  unicode-bidi: plaintext;
}

.server-card .server-category {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  display: inline-block;
  margin-top: 0.5rem;
}

.category-proxmox { background: #e8f5e9; color: #2e7d32; }
.category-windows-server { background: #e3f2fd; color: #1565c0; }
.category-dns-dhcp { background: #fff3e0; color: #e65100; }
.category-scanner { background: #f3e5f5; color: #7b1fa2; }
.category-workstation { background: #fce4ec; color: #c62828; }
.category-linux { background: #e0f2f1; color: #00695c; }

/* ─── Status Indicators ───────────────────────────────────────── */

.status-online {
  color: var(--success);
}

.status-offline {
  color: var(--danger);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 6px rgba(25, 135, 84, 0.5);
}

.status-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 6px rgba(220, 53, 69, 0.5);
}

/* ─── Modal Styles ────────────────────────────────────────────── */

.modal-xl {
  max-width: 900px;
}

.detail-section {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.detail-section h6 {
  color: var(--dark);
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.progress-bar-custom {
  height: 8px;
  border-radius: 4px;
  background: #e9ecef;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}

/* ─── Command Output ──────────────────────────────────────────── */

.command-output {
  background: #1e1e1e;
  color: #d4d4d4;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  padding: 1rem;
  border-radius: 8px;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ─── Site Tabs ───────────────────────────────────────────────── */

.site-tabs .nav-link {
  font-weight: 500;
  border-radius: 8px 8px 0 0;
}

.site-tabs .nav-link.active {
  background: white;
  color: var(--primary);
  border-bottom-color: white;
}

/* ─── Alert Cards ─────────────────────────────────────────────── */

.alert-card {
  background: white;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  border-left: 4px solid;
  overflow: hidden;
  direction: ltr;
  text-align: left;
}

.alert-card.critical { border-left-color: var(--danger); }
.alert-card.warning { border-left-color: var(--warning); }
.alert-card.info { border-left-color: var(--info); }

.alert-card strong {
  line-height: 1.35;
}

.alert-card .text-muted.small {
  line-height: 1.35;
  unicode-bidi: plaintext;
}

.alert-card .badge {
  white-space: normal;
  word-break: break-word;
  unicode-bidi: plaintext;
}

.alert-main {
  width: 100%;
}

.alert-actions {
  width: 100%;
  justify-content: flex-start;
  align-items: center;
}

/* ─── Chat ────────────────────────────────────────────────────── */

.chat-container {
  height: 500px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-shell {
  height: 100%;
}

.chat-shell-header {
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}

.chat-model-select {
  width: 95px;
}

.chat-guide {
  background: #f8fbff;
  border: 1px solid #dbe9ff;
  border-radius: 8px;
  padding: 0.75rem;
}

.chat-guide-header {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.chat-capabilities {
  margin-bottom: 0.5rem;
}

.chat-starter-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chat-starter-btn {
  border-radius: 20px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 8px;
  min-height: 0;
}

.chat-message {
  margin-bottom: 1rem;
  max-width: 85%;
}

.chat-message.user {
  margin-left: auto;
  text-align: right;
}

.chat-message .bubble {
  display: inline-block;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  text-align: left;
}

.chat-message.user .bubble {
  background: var(--primary);
  color: white;
}

.chat-message.assistant .bubble {
  background: white;
  border: 1px solid #dee2e6;
}

.chat-input {
  display: flex;
  gap: 0.5rem;
  padding-top: 0.75rem;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.chat-inline-suggestions {
  display: none;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.55rem;
}

.chat-inline-suggestions.show {
  display: flex;
}

.chat-inline-btn {
  border: 1px solid #d8e3ff;
  background: #f6f9ff;
  color: #2e4f84;
  border-radius: 999px;
  padding: 0.3rem 0.55rem;
  font-size: 0.78rem;
  line-height: 1.2;
}

.chat-inline-btn:hover {
  background: #eef4ff;
}

/* ─── Scanner ─────────────────────────────────────────────────── */

.scan-result-row.online {
  background: #f0fff4;
}

.scan-result-row.offline {
  background: #fff5f5;
}

/* ─── Quick Action Buttons ────────────────────────────────────── */

.quick-action-btn {
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-weight: 500;
  transition: all 0.2s;
}

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

/* ─── Loading ─────────────────────────────────────────────────── */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* ─── Mobile Bottom Navigation ──────────────────────────────── */

.mobile-bottom-nav {
  display: none;
}

/* ─── Responsive ──────────────────────────────────────────────── */

@media (max-width: 768px) {
  .container-fluid {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .auth-card {
    margin: 1rem;
    padding: 1.25rem;
  }

  .stat-card .stat-value {
    font-size: 1.5rem;
  }

  .server-card {
    margin-bottom: 0.75rem;
    padding: 1rem;
  }

  .site-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .site-tabs .nav-item {
    flex: 0 0 auto;
  }

  #view-chat {
    min-height: calc(100dvh - 150px);
  }

  #chat-content {
    height: calc(100dvh - 180px);
    min-height: 430px;
  }

  #chat-content .card {
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  #chat-content .card-body.chat-container {
    flex: 1;
    height: auto;
    min-height: 0;
  }

  .chat-guide-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .chat-message {
    max-width: 95%;
  }

  .chat-starter-prompts {
    max-height: 110px;
    overflow-y: auto;
  }

  .modal-dialog.modal-xl {
    max-width: calc(100% - 1rem);
    margin: 0.5rem auto;
  }

  .modal-body {
    padding: 0.75rem;
  }

  .detail-section {
    overflow-x: auto;
  }

  .detail-section table {
    min-width: 560px;
  }

  .command-output {
    max-height: 260px;
    font-size: 0.75rem;
  }

  .navbar-text {
    width: 100%;
    justify-content: space-between;
    margin-top: 0.75rem;
  }

  .app-main-content {
    padding-bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.25rem;
    padding: 0.45rem 0.5rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
    background: #ffffff;
    border-top: 1px solid #dce3ea;
    box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.08);
  }

  .mobile-nav-link {
    border: 0;
    background: transparent;
    border-radius: 10px;
    padding: 0.4rem 0.25rem;
    color: #5f6b7a;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.18rem;
    min-height: 52px;
  }

  .mobile-nav-link.active {
    color: var(--primary);
    background: rgba(13, 110, 253, 0.1);
  }

  .mobile-nav-icon {
    font-size: 1.1rem;
    line-height: 1;
  }

  .mobile-nav-label {
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
  }
}

@media (max-width: 576px) {
  #view-chat {
    min-height: calc(100dvh - 132px);
  }

  #chat-content {
    height: calc(100dvh - 164px);
    min-height: 400px;
  }

  #chat-content .card {
    margin-bottom: 0;
  }

  #chat-content .card-header {
    padding: 0.65rem 0.75rem;
  }

  #chat-content .card-body {
    padding: 0.65rem;
  }

  .chat-input {
    flex-direction: column;
  }

  .chat-input .btn {
    width: 100%;
  }

  .quick-action-btn {
    width: 100%;
  }

  .chat-starter-btn {
    width: 100%;
    text-align: left;
  }

  .chat-model-select {
    width: 88px;
  }

  .alert-card {
    padding: 0.75rem;
  }

  .alert-actions { margin-top: 0.5rem; }
}

@media (max-width: 768px) {
  body.chat-focus-mode nav.navbar {
    display: none;
  }

  body.chat-focus-mode .app-main-content {
    padding-top: 0.5rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  body.chat-focus-mode #view-chat > h4 {
    display: none;
  }

  body.chat-focus-mode #chat-content {
    height: calc(100dvh - 92px);
  }

  body.chat-focus-mode .mobile-bottom-nav {
    display: none;
  }

  body.chat-focus-mode .app-main-content {
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
}
