/* ========================================
   SECURITY HUB - Main Styles
   ======================================== */

/* Navigation items */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  color: #9ca3af;
  font-size: 14px;
  font-weight: 500;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.nav-item:hover {
  background: rgba(59, 130, 246, 0.1);
  color: #e5e7eb;
}

.nav-item.active {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

/* Settings tabs */
.settings-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  color: #9ca3af;
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.settings-tab:hover {
  background: rgba(59, 130, 246, 0.1);
  color: #e5e7eb;
}

.settings-tab.active {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

/* Cards */
.card {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 12px;
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title {
  color: #f3f4f6;
  font-size: 16px;
  font-weight: 600;
}

/* Metric cards */
.metric-card {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 12px;
  padding: 20px;
  transition: all 0.2s ease;
}

.metric-card:hover {
  border-color: #4b5563;
  transform: translateY(-2px);
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  color: #f3f4f6;
}

.metric-label {
  font-size: 13px;
  color: #9ca3af;
  margin-top: 4px;
}

.metric-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.metric-icon.red { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.metric-icon.blue { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.metric-icon.green { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.metric-icon.yellow { background: rgba(234, 179, 8, 0.15); color: #eab308; }
.metric-icon.purple { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.metric-icon.orange { background: rgba(249, 115, 22, 0.15); color: #f97316; }

/* Data tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  background: #111827;
  color: #9ca3af;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #374151;
}

.data-table tbody td {
  padding: 10px 12px;
  color: #d1d5db;
  border-bottom: 1px solid #1f2937;
}

.data-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.05);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
}

.badge-red { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-blue { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge-green { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.badge-yellow { background: rgba(234, 179, 8, 0.15); color: #facc15; }
.badge-purple { background: rgba(168, 85, 247, 0.15); color: #c084fc; }
.badge-gray { background: rgba(107, 114, 128, 0.15); color: #9ca3af; }

/* Severity specific */
.severity-critical { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }
.severity-high { background: rgba(249, 115, 22, 0.15); color: #fdba74; border: 1px solid rgba(249, 115, 22, 0.3); }
.severity-medium { background: rgba(234, 179, 8, 0.15); color: #fde047; border: 1px solid rgba(234, 179, 8, 0.3); }
.severity-low { background: rgba(34, 197, 94, 0.15); color: #86efac; border: 1px solid rgba(34, 197, 94, 0.3); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary { background: #3b82f6; color: white; }
.btn-primary:hover { background: #2563eb; }
.btn-success { background: #22c55e; color: white; }
.btn-success:hover { background: #16a34a; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: #eab308; color: #1f2937; }
.btn-warning:hover { background: #ca8a04; }
.btn-ghost { background: transparent; color: #9ca3af; border: 1px solid #374151; }
.btn-ghost:hover { background: #374151; color: #e5e7eb; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Form inputs */
.form-input {
  width: 100%;
  background: #374151;
  border: 1px solid #4b5563;
  border-radius: 8px;
  padding: 8px 12px;
  color: #f3f4f6;
  font-size: 14px;
  transition: border-color 0.15s ease;
}

.form-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.form-input::placeholder {
  color: #6b7280;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #9ca3af;
  margin-bottom: 4px;
}

.form-select {
  width: 100%;
  background: #374151;
  border: 1px solid #4b5563;
  border-radius: 8px;
  padding: 8px 12px;
  color: #f3f4f6;
  font-size: 14px;
  cursor: pointer;
}

.form-select:focus {
  outline: none;
  border-color: #3b82f6;
}

.form-checkbox {
  width: 16px;
  height: 16px;
  accent-color: #3b82f6;
  cursor: pointer;
}

/* Notifications */
.notification {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn 0.3s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  min-width: 300px;
  max-width: min(420px, calc(100vw - 32px));
}

.notification.success { background: #065f46; color: #a7f3d0; border: 1px solid #047857; }
.notification.error { background: #7f1d1d; color: #fecaca; border: 1px solid #991b1b; }
.notification.warning { background: #78350f; color: #fef3c7; border: 1px solid #92400e; }
.notification.info { background: #1e3a5f; color: #bfdbfe; border: 1px solid #1e40af; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Alarm pulse */
@keyframes alarmPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.alarm-pulse {
  animation: alarmPulse 1s ease-in-out infinite;
}

/* Event timeline */
.timeline-item {
  position: relative;
  padding-left: 28px;
  padding-bottom: 16px;
  border-left: 2px solid #374151;
  margin-left: 8px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3b82f6;
}

.timeline-item.critical::before { background: #ef4444; }
.timeline-item.high::before { background: #f97316; }
.timeline-item.medium::before { background: #eab308; }
.timeline-item.low::before { background: #22c55e; }

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  padding: 16px;
}

.modal-content {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh !important;
  overflow-y: auto !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  margin: 0;
}

/* Ensure modal scrolls on mobile */
@media (max-height: 700px) {
  .modal-content {
    max-height: 85vh !important;
  }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #4b5563; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #6b7280; }

/* Responsive */
@media (max-width: 1024px) {
  #sidebar {
    position: fixed;
    left: -240px;
    top: 0;
    bottom: 0;
    z-index: 20;
    transition: left 0.3s ease;
  }
  #sidebar.open {
    left: 0;
  }
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #6b7280;
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: #9ca3af;
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13px;
}

/* Tab group */
.tab-group {
  display: flex;
  gap: 2px;
  background: #111827;
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #9ca3af;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 34px;
}

.tab-btn:hover { color: #e5e7eb; }
.tab-btn.active { background: #374151; color: #f3f4f6; }

/* Status indicators */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-dot.online { background: #22c55e; }
.status-dot.offline { background: #ef4444; }
.status-dot.warning { background: #eab308; }
.status-dot.connecting { background: #3b82f6; animation: alarmPulse 1s infinite; }

/* QR Analysis highlights */
.qr-highlight-yellow td { background: rgba(234, 179, 8, 0.12) !important; color: #fde047; }
.qr-highlight-red td { background: rgba(239, 68, 68, 0.15) !important; color: #fca5a5; font-weight: 700; }

/* Tools */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.tool-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  width: 100%;
  background: linear-gradient(180deg, rgba(31, 41, 55, 0.95), rgba(17, 24, 39, 1));
  border: 1px solid #374151;
  border-radius: 16px;
  padding: 20px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.tool-card:hover {
  transform: translateY(-2px);
  border-color: #4b5563;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
}

.tool-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(59, 130, 246, 0.14);
  color: #60a5fa;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.tool-card-title {
  color: #f3f4f6;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.tool-card-text {
  color: #9ca3af;
  font-size: 13px;
  line-height: 1.55;
}

.tool-monitor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.tool-dataset-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.tool-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.tool-upload {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  border: 1px dashed #4b5563;
  border-radius: 14px;
  padding: 18px;
  background: rgba(17, 24, 39, 0.55);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.tool-upload:hover {
  border-color: #60a5fa;
  background: rgba(30, 41, 59, 0.8);
}

.tool-textarea {
  min-height: 180px;
  resize: vertical;
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tool-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.tool-stat {
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid #374151;
  border-radius: 12px;
  padding: 14px;
}

.tool-stat-value {
  color: #f3f4f6;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
}

.tool-stat-label {
  color: #9ca3af;
  font-size: 12px;
  margin-top: 4px;
}

.tool-progress {
  height: 14px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.8);
  overflow: hidden;
  margin-bottom: 16px;
}

.tool-progress-bar {
  height: 100%;
  width: 0;
  min-width: 0;
  background: linear-gradient(90deg, #3b82f6, #22c55e);
  color: #e5e7eb;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: width 0.25s ease;
}

.tool-log {
  background: rgba(17, 24, 39, 0.75);
  border: 1px solid #374151;
  border-radius: 12px;
  padding: 12px;
  max-height: 320px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.tool-log-entry {
  padding: 5px 0;
  border-bottom: 1px solid rgba(75, 85, 99, 0.35);
}

.tool-log-entry:last-child {
  border-bottom: none;
}

.tool-log-entry.info { color: #cbd5e1; }
.tool-log-entry.success { color: #86efac; }
.tool-log-entry.warning { color: #fcd34d; }
.tool-log-entry.error { color: #fca5a5; }

.tool-results-table td a {
  text-decoration: none;
}

.tool-results-table td a:hover {
  text-decoration: underline;
}

/* QR detector tool */
.qr-tool-shell {
  position: relative;
}

.qr-tool-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.qr-tool-input {
  background: #ffffff;
  color: #111827;
  border-color: #d1d5db;
}

.qr-tool-drop-zone {
  border: 2px dashed #d1d5db;
  border-radius: 14px;
  padding: 24px;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
  background: #f9fafb;
  color: #374151;
}

.qr-tool-drop-zone.dragover,
.qr-tool-drop-zone:hover {
  border-color: #60a5fa;
  background: #eff6ff;
}

.qr-tool-spinner {
  border: 3px solid #f3f4f6;
  border-top: 3px solid #3b82f6;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  animation: qrToolSpin 1s linear infinite;
}

@keyframes qrToolSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.qr-tool-progress-bar {
  background: linear-gradient(90deg, #3b82f6, #2563eb);
  transition: width 0.25s ease;
}

.qr-tool-select-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.qr-tool-results-layout {
  display: flex;
  gap: 16px;
}

.qr-tool-compare-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.qr-tool-compare-col {
  min-width: 0;
}

.qr-tool-top-box {
  width: 220px;
  flex-shrink: 0;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 12px;
  align-self: flex-start;
  position: sticky;
  top: 12px;
}

.qr-tool-table-scroll {
  max-height: 70vh;
  overflow: auto;
}

.qr-tool-table {
  font-size: 0.8125rem;
}

.qr-tool-table th,
.qr-tool-table td {
  padding: 0.35rem 0.5rem;
}

.qr-tool-table tr:nth-child(even) {
  background: #f9fafb;
}

.qr-tool-highlight-yellow td {
  background: #fefce8 !important;
  color: #854d0e;
}

.qr-tool-highlight-red td {
  background: #fef2f2 !important;
  color: #991b1b;
  font-weight: 700;
}

/* Layout helpers */
#main-content {
  min-width: 0;
}

#settings-modal > div {
  width: min(1100px, calc(100vw - 32px));
  max-height: min(92vh, 980px);
}

#settings-content > * {
  min-width: 0;
}

#settings-content .grid,
#main-content .grid {
  min-width: 0;
}

#settings-content .flex,
#main-content .flex {
  min-width: 0;
}

#settings-content .btn,
#main-content .btn {
  max-width: 100%;
}

#settings-content code {
  word-break: break-word;
}

@media (max-width: 900px) {
  #main-content {
    padding: 16px;
  }

  #settings-modal > div {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }

  #settings-modal .flex.flex-1.min-h-0 {
    flex-direction: column;
  }

  #settings-modal .w-48 {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #374151;
  }

  #settings-modal .settings-tab {
    justify-content: center;
  }

  #settings-content {
    padding: 16px;
  }
}

@media (max-width: 768px) {
  .card,
  .metric-card {
    padding: 16px;
  }

  .modal-overlay {
    padding: 10px;
    align-items: flex-start;
  }

  .modal-content {
    max-height: calc(100vh - 20px) !important;
    border-radius: 14px;
  }

  .tab-group {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: thin;
  }

  .tab-btn {
    flex: 0 0 auto;
  }

  .data-table {
    min-width: 720px;
  }

  .tool-monitor-grid {
    grid-template-columns: 1fr;
  }

  .tool-dataset-row,
  .tool-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .qr-tool-select-grid,
  .qr-tool-compare-grid {
    grid-template-columns: 1fr;
  }

  .qr-tool-results-layout {
    flex-direction: column;
  }

  .qr-tool-top-box {
    width: 100%;
    position: static;
  }

  #notification-container {
    left: 12px;
    right: 12px;
    top: 12px;
  }

  .notification {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 640px) {
  #main-content {
    padding: 12px;
  }

  .metric-value {
    font-size: 24px;
  }

  .btn {
    justify-content: center;
  }

  .card-header {
    align-items: flex-start;
  }
}
