:root {
  --primary-navy: #1c2b36;
  --secondary-blue: #2b4e72;
  --bg-dashboard: #f0f3f6;
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --text-main: #2d3748;
  --text-muted: #718096;
  --green-accent: #2ecc71;
  --orange-accent: #e67e22;
  --blue-accent: #3498db;
  
  --input-bg: #ffffff;
  --input-border: #cbd5e0;
  --table-header-bg: #f7fafc;
  --table-row-hover: #f7fafc;
  --search-bg: #fafafa;
  --chat-msg-bg: #ffffff;
  --chat-msg-body-bg: #f7fafc;
  --accordion-header-bg: #f7fafc;
}

body.dark-mode {
  --bg-dashboard: #0f172a;
  --card-bg: #1e293b;
  --card-border: #334155;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --secondary-blue: #38bdf8;
  
  --input-bg: #0f172a;
  --input-border: #475569;
  --table-header-bg: #1e293b;
  --table-row-hover: #334155;
  --search-bg: #1e293b;
  --chat-msg-bg: #1e293b;
  --chat-msg-body-bg: #0f172a;
  --accordion-header-bg: #1e293b;
}

/* Dark mode style overrides */
body.dark-mode .user-item-link.active {
  background: rgba(56, 189, 248, 0.15);
  border-left: 3px solid var(--secondary-blue);
}
body.dark-mode .ip-highlight {
  background: #3e2723;
  color: #ffb74d;
}
body.dark-mode .msg-tag-badge.tag-users-total {
  background: #115e59;
  color: #2dd4bf;
}
body.dark-mode .msg-tag-badge.tag-updates {
  background: #7c2d12;
  color: #fb923c;
}
body.dark-mode #room-list-header {
  background: var(--search-bg) !important;
  color: var(--text-main);
}
body.dark-mode .stat-icon {
  background: rgba(56, 189, 248, 0.1) !important;
}
.tree-node-root {
  background: var(--table-header-bg) !important;
  font-weight: 600;
}

body {
  font-family: 'Inter', sans-serif;
  overflow: hidden;
  height: 100vh;
  background-color: var(--bg-dashboard);
  display: flex;
  flex-direction: column;
  margin: 0;
  color: var(--text-main);
}

/* Header styling */
#navigation {
  flex: 0 0 auto;
  background: var(--primary-navy);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  color: white;
}

#navigation h5 {
  margin: 0;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

#navigation .stats-summary {
  font-size: 14px;
  color: #cbd5e0;
}

/* Top stats row */
.stats-row {
  display: flex;
  gap: 15px;
  padding: 15px 15px 5px 15px;
  flex: 0 0 auto;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px 12px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  position: relative;
  overflow: hidden;
  min-height: 95px;
}

.stat-card.donut-card {
  flex: 1.5;
}

.stat-card.history-card {
  flex: 2.2;
}

.top-chart-wrapper {
  width: 100%;
  height: 55px;
  margin-top: 4px;
  position: relative;
}

.stat-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-trend {
  font-size: 11px;
  font-weight: 600;
  color: var(--green-accent);
  display: flex;
  align-items: center;
  gap: 3px;
}

.stat-icon {
  font-size: 24px;
  color: var(--secondary-blue);
  opacity: 0.8;
  background: #ebf4ff;
  padding: 8px;
  border-radius: 8px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-chart-container {
  width: 80px;
  height: 45px;
  position: relative;
}

.donut-chart-container {
  width: 100%;
  height: 60px;
  display: flex;
  align-items: center;
}

/* Main workspace layout */
#content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 10px 15px 15px 15px;
}

.column-container {
  flex: 1;
  display: flex;
  flex-direction: row;
  gap: 15px;
  overflow: hidden;
  height: 100%;
}

/* Columns structure */
.column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border-radius: 10px;
  border: 1px solid var(--card-border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: all 0.2s ease-in-out;
  overflow: hidden;
}

.column-header {
  padding: 12px 15px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--card-border);
  font-weight: 600;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.column-header i.header-icon {
  margin-right: 6px;
  color: var(--secondary-blue);
}

.search-wrapper {
  padding: 8px 12px;
  background: var(--search-bg);
  border-bottom: 1px solid var(--card-border);
}

.search-input {
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-main);
  border-radius: 6px;
  font-size: 12px;
  padding: 5px 10px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--secondary-blue);
}

.column-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0;
  -webkit-overflow-scrolling: touch;
}

/* Column Lists and Cards */
.tabs-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tabs-list li {
  border-bottom: 1px solid var(--card-border);
}

/* Custom scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-dashboard);
}
::-webkit-scrollbar-thumb {
  background: var(--card-border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* User Row Design */
.user-item-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 15px;
  text-decoration: none;
  color: var(--text-main);
  transition: background 0.15s;
  font-size: 13px;
}

.user-item-link:hover {
  background: var(--table-row-hover);
  text-decoration: none;
  color: var(--text-main);
}

.user-item-link.active {
  background: var(--table-row-hover);
  border-left: 3px solid var(--secondary-blue);
}

.user-card-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.user-avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--table-row-hover);
  color: var(--secondary-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.user-name-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
}

.status-dot-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green-accent);
  flex-shrink: 0;
}

/* Accordion Panels for Rooms & Paths */
.accordion-panel {
  border-bottom: 1px solid var(--card-border);
}

.panel-header {
  background: var(--accordion-header-bg);
  padding: 10px 15px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--card-border);
}

.panel-header:first-child {
  border-top: none;
}

.rooms-paths-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.accordion-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  transition: flex 0.2s ease-in-out;
}

.accordion-panel.expanded {
  flex: 1;
  min-height: 0;
}

.accordion-panel.collapsed-panel {
  flex: 0 0 auto;
}

.panel-body {
  max-height: 250px;
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.accordion-panel.expanded .panel-body {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

.tree-node {
  font-size: 12px;
  padding: 6px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-main);
  border-bottom: 1px dashed var(--card-border);
}

.tree-node.depth-1 {
  padding-left: 25px;
}

.tree-node i {
  color: var(--text-muted);
  margin-right: 6px;
}

.node-badge {
  background: var(--table-row-hover);
  color: var(--text-muted);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
}

/* Details Section styling */
.table-details {
  font-size: 12px;
  margin-bottom: 0;
  background-color: transparent !important;
}

.table-details th {
  background: var(--table-header-bg) !important;
  border-top: none;
  font-weight: 600;
  color: var(--text-muted);
}

.table-details tr, 
.table-details td {
  background-color: transparent !important;
  color: var(--text-main);
  border-color: var(--card-border);
}

.table-details tbody tr:hover td {
  background-color: var(--table-row-hover) !important;
}

.table-details td {
  vertical-align: middle;
}

.ip-highlight {
  background: #fffaf0;
  color: #dd6b20;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

.chart-box {
  border-top: 1px solid var(--card-border);
  padding: 15px;
  background: #ffffff;
  flex: 0 0 170px;
}

.chart-box-title {
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.details-chart-wrapper {
  height: 120px;
  position: relative;
}

/* Chat Messages styling */
#messages-container {
  background: var(--bg-dashboard);
  display: flex;
  flex-direction: column;
}

#messages {
  list-style: none;
  margin: 0;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg-card {
  background: var(--chat-msg-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
  display: flex;
  flex-direction: column;
  position: relative;
}

.msg-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.msg-tag-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
}

.msg-tag-badge.tag-users-total {
  background: #e6fffa;
  color: #319795;
}

.msg-tag-badge.tag-updates {
  background: #fffaf0;
  color: #dd6b20;
}

.msg-card-time {
  font-size: 10px;
  color: var(--text-muted);
}

.msg-card-body {
  font-size: 11px;
  font-family: monospace;
  background: var(--chat-msg-body-bg);
  color: var(--text-main);
  padding: 8px;
  border-radius: 4px;
  word-break: break-all;
  white-space: pre-wrap;
  max-height: 100px;
  overflow-y: auto;
}

.pause-stream-btn {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: 600;
  transition: all 0.2s ease-in-out;
}

.pause-stream-btn.btn-danger {
  background-color: #e53e3e !important;
  border-color: #e53e3e !important;
  color: #ffffff !important;
}

.pause-stream-btn.btn-outline-secondary {
  background-color: transparent !important;
  border-color: var(--input-border) !important;
  color: var(--text-main) !important;
}

.pause-stream-btn.btn-outline-secondary:hover {
  background-color: var(--table-row-hover) !important;
  color: var(--text-main) !important;
}

/* Collapsible columns */
.column.collapsed {
  flex: 0 0 45px !important;
  min-width: 45px !important;
  overflow: hidden;
}

.column.collapsed .column-header span,
.column.collapsed .search-wrapper,
.column.collapsed .column-content,
.column.collapsed .chart-box,
.column.collapsed .pause-stream-btn,
.column.collapsed #pause-stream-btn-bottom,
.column.collapsed .rooms-paths-container {
  display: none !important;
}

.column.collapsed .column-header {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 15px 5px;
  cursor: pointer;
}

.column.collapsed .column-header span.collapsed-title {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  margin-top: 15px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  display: block !important;
}

/* Regla especial para centrar el icono y texto verticalmente en la columna colapsada del chat */
.column.collapsed .column-header span.collapsed-title.chat-collapsed-title {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  writing-mode: horizontal-tb;
}

.vertical-text {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 1px;
}

.toggle-btn {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  transition: all 0.2s ease-in-out;
  border: none;
  outline: none;
}

.toggle-btn:hover {
  background: var(--table-row-hover);
  color: var(--text-main);
}

/* Utilities */
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Responsive Mobile & Tablet Layout (< 992px) - Desktop layout above 992px remains 100% untouched */
@media (max-width: 991.98px) {
  body {
    overflow-y: auto !important;
    height: auto !important;
    min-height: 100vh;
  }

  #navigation {
    padding: 10px 15px;
    flex-wrap: wrap;
    gap: 8px;
  }

  #navigation h5 {
    font-size: 15px;
  }

  #navigation .stats-summary {
    font-size: 12px;
  }

  .stats-row {
    flex-wrap: wrap;
    padding: 10px 10px 5px 10px;
    gap: 10px;
  }

  .stat-card.history-card {
    flex: 0 0 100% !important;
    width: 100%;
  }

  .stat-card.donut-card {
    flex: 1 1 calc(50% - 5px) !important;
    min-width: 140px;
  }

  .stat-card:not(.history-card):not(.donut-card) {
    flex: 1 1 calc(50% - 5px);
    min-width: 130px;
  }

  #content {
    overflow: visible !important;
    height: auto !important;
    padding: 5px 10px 25px 10px;
  }

  .column-container {
    flex-direction: column !important;
    height: auto !important;
    overflow: visible !important;
    gap: 14px;
  }

  .column {
    width: 100% !important;
    min-width: 100% !important;
    flex: none !important;
    max-height: 420px;
    min-height: 260px;
  }

  .column#col-detail-view {
    flex: none !important;
    max-height: 480px;
  }

  .column#col-chat {
    max-height: 450px;
  }

  /* Collapsed column on mobile: sleek horizontal bar instead of squeezed vertical strip */
  .column.collapsed {
    flex: none !important;
    width: 100% !important;
    min-width: 100% !important;
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    overflow: hidden;
  }

  .column.collapsed .column-header {
    height: 100% !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 10px 15px !important;
  }

  .column.collapsed .column-header span:first-child {
    display: flex !important;
    align-items: center;
    gap: 6px;
    font-size: 13px;
  }

  .column.collapsed .column-header span.collapsed-title,
  .column.collapsed .column-header span.collapsed-title.chat-collapsed-title {
    display: none !important;
  }

  .column.collapsed .toggle-btn {
    display: block !important;
    transform: rotate(90deg);
  }

  /* Table details responsive readability */
  .table-details {
    font-size: 11px;
  }

  .table-details th,
  .table-details td {
    padding: 8px 6px;
  }

  .ip-highlight {
    font-size: 10px;
    padding: 1px 4px;
    word-break: break-all;
  }

  .user-name-title {
    font-size: 12px;
    max-width: 160px;
  }

  .user-avatar-circle {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .msg-card-body {
    font-size: 10px;
    max-height: 120px;
  }

  .search-input {
    font-size: 13px; /* Prevents auto-zoom on mobile Safari */
  }
}
