/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: #333;
}

.app-container {
  display: flex;
  min-height: 100vh;
  background: #f5f7fa;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: white;
  border-right: 1px solid #e1e5eb;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 20px rgba(0, 0, 0, 0.05);
  z-index: 100;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid #e1e5eb;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.sidebar-header h2 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.sidebar-subtitle {
  font-size: 0.875rem;
  opacity: 0.9;
}

.sidebar-section {
  padding: 20px;
  border-bottom: 1px solid #e1e5eb;
}

.sidebar-section h3 {
  font-size: 0.875rem;
  text-transform: uppercase;
  color: #6c757d;
  margin-bottom: 16px;
  letter-spacing: 0.5px;
}

.filter-group {
  margin-bottom: 16px;
}

.filter-group label {
  display: block;
  font-size: 0.875rem;
  color: #495057;
  margin-bottom: 6px;
  font-weight: 500;
}

.filter-select,
.filter-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.filter-select:focus,
.filter-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filter-slider {
  width: 100%;
  height: 6px;
  background: #e9ecef;
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
}

.filter-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: #667eea;
  border-radius: 50%;
  cursor: pointer;
}

.sidebar-action {
  width: 100%;
  padding: 10px 16px;
  margin-bottom: 8px;
  background: #f8f9fa;
  border: 1px solid #e1e5eb;
  border-radius: 6px;
  color: #495057;
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}

.sidebar-action:hover {
  background: #e9ecef;
  border-color: #667eea;
  color: #667eea;
}

.btn-outline {
  width: 100%;
  padding: 10px 16px;
  background: transparent;
  border: 1px solid #667eea;
  border-radius: 6px;
  color: #667eea;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-outline:hover {
  background: #667eea;
  color: white;
}

.sidebar-footer {
  margin-top: auto;
  padding: 20px;
  border-top: 1px solid #e1e5eb;
  background: #f8f9fa;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.status-indicator-dot {
  width: 8px;
  height: 8px;
  background: #28a745;
  border-radius: 50%;
}

.status-indicator-dot.active {
  background: #28a745;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.last-updated {
  font-size: 0.75rem;
  color: #6c757d;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.main-header h1 {
  font-size: 2rem;
  color: #212529;
  margin-bottom: 4px;
}

.main-subtitle {
  color: #6c757d;
  font-size: 0.875rem;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-refresh {
  padding: 8px 16px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-refresh:hover {
  background: #5a6fd8;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: white;
  border-radius: 10px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-online {
  border-left: 4px solid #28a745;
}

.stat-idle {
  border-left: 4px solid #ffc107;
}

.stat-offline {
  border-left: 4px solid #dc3545;
}

.stat-sysmon {
  border-left: 4px solid #6610f2;
}

.stat-alerts {
  border-left: 4px solid #fd7e14;
}

.stat-icon {
  font-size: 2rem;
}

.stat-info {
  flex: 1;
}

.stat-label {
  font-size: 0.875rem;
  color: #6c757d;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 2rem;
  font-weight: bold;
  color: #212529;
}

.stat-percentage {
  font-size: 0.875rem;
  color: #28a745;
  font-weight: 500;
}

.stat-trend {
  font-size: 0.75rem;
  color: #6c757d;
}

/* Section Styles */
.section {
  background: white;
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 1.5rem;
  color: #212529;
}

.section-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.filter-badge {
  padding: 6px 12px;
  background: #e9ecef;
  border-radius: 20px;
  font-size: 0.875rem;
  color: #495057;
}

/* Devices Grid */
.devices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.device-card {
  background: white;
  border-radius: 10px;
  padding: 20px;
  border: 1px solid #e1e5eb;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.device-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  border-color: #667eea;
}

.device-card.status-online {
  border-left: 4px solid #28a745;
}

.device-card.status-idle {
  border-left: 4px solid #ffc107;
}

.device-card.status-offline {
  border-left: 4px solid #dc3545;
}

.device-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.device-name {
  display: flex;
  align-items: center;
  gap: 12px;
}

.device-icon {
  font-size: 1.5rem;
}

.device-name h3 {
  font-size: 1.25rem;
  color: #212529;
}

.status-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge.status-online {
  background: #d4edda;
  color: #155724;
}

.status-badge.status-idle {
  background: #fff3cd;
  color: #856404;
}

.status-badge.status-offline {
  background: #f8d7da;
  color: #721c24;
}

.device-info {
  margin-bottom: 20px;
}

.info-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.875rem;
}

.info-label {
  color: #6c757d;
}

.info-value {
  color: #212529;
  font-weight: 500;
}

.device-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.metric-label {
  font-size: 0.75rem;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-value {
  font-size: 1.25rem;
  font-weight: bold;
  color: #212529;
}

.metric-bar {
  height: 6px;
  background: #e9ecef;
  border-radius: 3px;
  overflow: hidden;
}

.metric-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.cpu-fill {
  background: linear-gradient(90deg, #667eea, #764ba2);
}

.ram-fill {
  background: linear-gradient(90deg, #f093fb, #f5576c);
}

.device-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #6c757d;
  padding-top: 16px;
  border-top: 1px solid #e9ecef;
}

.footer-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.footer-label {
  font-size: 0.7rem;
  opacity: 0.7;
}

.sysmon-indicator {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: rgba(102, 126, 234, 0.1);
  border-radius: 4px;
  font-size: 0.75rem;
  color: #667eea;
}

.sysmon-icon {
  font-size: 0.875rem;
}

/* Empty State */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state h3 {
  font-size: 1.5rem;
  color: #6c757d;
  margin-bottom: 8px;
}

.empty-state p {
  color: #adb5bd;
  margin-bottom: 24px;
}

.btn {
  padding: 10px 24px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn:hover {
  background: #5a6fd8;
}

/* AI Assistant */
.ai-assistant {
  background: white;
  border-radius: 10px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.ai-assistant.expanded {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.ai-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  cursor: pointer;
}

.ai-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-icon {
  font-size: 1.5rem;
}

.ai-toggle {
  background: transparent;
  border: 2px solid white;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-content {
  padding: 24px;
}

.chat-history {
  height: 300px;
  overflow-y: auto;
  margin-bottom: 20px;
  padding-right: 10px;
}

.chat-message {
  margin-bottom: 16px;
  padding: 16px;
  border-radius: 10px;
  max-width: 85%;
}

.chat-message.question {
  background: #e3f2fd;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.chat-message.answer {
  background: #f5f5f5;
  margin-right: auto;
  border-bottom-left-radius: 4px;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.75rem;
}

.message-type {
  font-weight: 500;
}

.message-computer {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 8px;
  border-radius: 10px;
}

.message-content {
  line-height: 1.5;
  font-size: 0.875rem;
}

.message-time {
  font-size: 0.7rem;
  color: #6c757d;
  text-align: right;
  margin-top: 8px;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 10px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: #6c757d;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.chat-input-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-select {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.875rem;
  width: 200px;
}

.input-with-button {
  display: flex;
  gap: 8px;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.875rem;
}

.chat-input:focus {
  outline: none;
  border-color: #667eea;
}

.chat-send-btn {
  padding: 12px 24px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-send-btn:hover:not(:disabled) {
  background: #5a6fd8;
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-ghost {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: #6c757d;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-ghost:hover:not(:disabled) {
  background: #f8f9fa;
  border-color: #667eea;
  color: #667eea;
}

.btn-ghost:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.quick-questions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quick-label {
  font-size: 0.75rem;
  color: #6c757d;
}

.quick-btn {
  padding: 6px 12px;
  background: #f8f9fa;
  border: 1px solid #e1e5eb;
  border-radius: 4px;
  font-size: 0.75rem;
  color: #495057;
  cursor: pointer;
  transition: all 0.2s;
}

.quick-btn:hover {
  background: #e9ecef;
  border-color: #667eea;
  color: #667eea;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 1200px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 24px;
  border-bottom: 1px solid #e1e5eb;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 12px 12px 0 0;
}

.modal-title h2 {
  font-size: 1.75rem;
  margin-bottom: 8px;
}

.modal-subtitle {
  display: flex;
  gap: 16px;
  font-size: 0.875rem;
  opacity: 0.9;
}

.subtitle-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.modal-close {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.modal-close:hover {
  opacity: 1;
}

.modal-content {
  padding: 24px;
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px;
  gap: 20px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e9ecef;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Modal Grid */
.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.modal-card {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
  border: 1px solid #e1e5eb;
}

.card-title {
  font-size: 1rem;
  color: #495057;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.metric-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-label {
  font-size: 0.75rem;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-value {
  font-size: 1.5rem;
  font-weight: bold;
  color: #212529;
}

.info-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.info-label {
  font-size: 0.875rem;
  color: #6c757d;
}

.info-value {
  font-size: 0.875rem;
  font-weight: 500;
  color: #212529;
}

.status-tag {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
}

.status-tag.status-online {
  background: #d4edda;
  color: #155724;
}

.status-tag.status-idle {
  background: #fff3cd;
  color: #856404;
}

.status-tag.status-offline {
  background: #f8d7da;
  color: #721c24;
}

/* Modal Tabs */
.modal-tabs {
  margin-top: 24px;
}

.section {
  margin-bottom: 32px;
}

.section-title {
  font-size: 1.25rem;
  color: #212529;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Tables */
.table-container {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid #e1e5eb;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead {
  background: #f8f9fa;
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 500;
  color: #495057;
  border-bottom: 2px solid #e1e5eb;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #e1e5eb;
  vertical-align: top;
}

.data-table tbody tr:hover {
  background: #f8f9fa;
}

.event-id {
  display: inline-block;
  padding: 2px 8px;
  background: #e9ecef;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.75rem;
}

.event-type {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.event-type.type-process_create {
  background: #d4edda;
  color: #155724;
}

.event-type.type-network_connection {
  background: #cce5ff;
  color: #004085;
}

.event-type.type-file_create {
  background: #fff3cd;
  color: #856404;
}

.event-description {
  max-width: 300px;
  word-wrap: break-word;
}

.no-data {
  text-align: center;
  color: #6c757d;
  font-style: italic;
}

.process-name {
  font-weight: 500;
  color: #495057;
}

.cpu-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: #e9ecef;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.connection-status {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.connection-status.status-established {
  background: #d4edda;
  color: #155724;
}

.connection-status.status-listening {
  background: #fff3cd;
  color: #856404;
}

.connection-status.status-time_wait {
  background: #f8d7da;
  color: #721c24;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .app-container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #e1e5eb;
  }
  
  .sidebar-header {
    text-align: center;
  }
  
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
  
  .devices-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
  
  .modal-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .main-content {
    padding: 16px;
  }
  
  .main-header {
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
  }
  
  .section-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  
  .devices-grid {
    grid-template-columns: 1fr;
  }
  
  .chat-actions {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  
  .quick-questions {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .modal {
    width: 95%;
    margin: 10px;
  }
  
  .input-with-button {
    flex-direction: column;
  }
  
  .chat-select {
    width: 100%;
  }
}