/*!
 * UltraGuard Pro — Antivirus Module Styles
 * Scan Panel, Progress Bar, Status Badge, Quick Actions
 * Loaded only on Antivirus admin pages via AntivirusModule::enqueue_assets().
 *
 * All --ug-* variables are defined in admin-base.css which loads first.
 */

/* ==========================================================================
   ANTIVIRUS — Scan Panel & Progress UI
   ========================================================================== */

.ug-scan-panel {
  background: var(--ug-bg-primary, #fff);
  border: 1px solid var(--ug-border, #e2e8f0);
  border-radius: var(--ug-radius-md, 8px);
  padding: 20px 24px;
  margin-bottom: var(--ug-spacing-md, 16px);
  box-shadow: var(--ug-shadow-xs, 0 1px 3px rgba(0,0,0,.06));
}

/* Header row */
.ug-scan-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.ug-scan-panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  color: var(--ug-dark, #1e293b);
}

.ug-scan-panel-title .dashicons {
  color: var(--ug-primary, #0ea5e9);
  font-size: 20px;
  width: 20px;
  height: 20px;
}

.ug-scan-panel-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--ug-gray, #64748b);
}

/* ── Status badge ─────────────────────────────────────────────────────────── */

.ug-scan-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.ug-scan-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ug-scan-badge--idle {
  background: var(--ug-bg-tertiary, #eceff1);
  color: var(--ug-gray, #64748b);
}
.ug-scan-badge--idle .ug-scan-badge-dot {
  background: var(--ug-gray-lighter, #b0bec5);
}

.ug-scan-badge--running {
  background: rgba(14,165,233,.1);
  color: var(--ug-primary, #0ea5e9);
}
.ug-scan-badge--running .ug-scan-badge-dot {
  background: var(--ug-primary, #0ea5e9);
  animation: ug-pulse 1.2s ease-in-out infinite;
}

.ug-scan-badge--complete {
  background: rgba(16,185,129,.1);
  color: var(--ug-success, #10b981);
}
.ug-scan-badge--complete .ug-scan-badge-dot {
  background: var(--ug-success, #10b981);
}

.ug-scan-badge--error {
  background: rgba(239,68,68,.1);
  color: var(--ug-error, #ef4444);
}
.ug-scan-badge--error .ug-scan-badge-dot {
  background: var(--ug-error, #ef4444);
}

@keyframes ug-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .5; transform: scale(1.3); }
}

/* ── Progress bar ─────────────────────────────────────────────────────────── */

.ug-scan-progress-wrap {
  margin-bottom: 14px;
}

.ug-scan-progress-bar-track {
  height: 8px;
  background: var(--ug-bg-tertiary, #eceff1);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.ug-scan-progress-bar-fill {
  height: 100%;
  background: var(--ug-gradient-primary,
    linear-gradient(135deg, #0ea5e9 0%, #38bdf8 100%));
  border-radius: 4px;
  transition: width .4s ease;
  min-width: 2px; /* always show a sliver so 0% isn't invisible */
}

.ug-scan-progress-stats {
  display: flex;
  gap: 20px;
  font-size: 12px;
  color: var(--ug-gray, #64748b);
  flex-wrap: wrap;
  align-items: center;
}

.ug-scan-progress-stats strong {
  color: var(--ug-dark, #1e293b);
}

.ug-scan-current-file {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--ug-font-mono,
    'SF Mono', Monaco, Consolas, 'Courier New', monospace);
  font-size: 11px;
  color: var(--ug-gray-light, #78909c);
}

/* ── Action buttons row ───────────────────────────────────────────────────── */

.ug-scan-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.ug-custom-scan-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
  min-width: 280px;
}

.ug-custom-scan-wrap input {
  flex: 1;
  height: 36px;
  padding: 0 12px;
  border: 1.5px solid var(--ug-border, #e2e8f0);
  border-radius: var(--ug-radius-sm, 6px);
  font-size: 13px;
  font-family: var(--ug-font-mono,
    'SF Mono', Monaco, Consolas, 'Courier New', monospace);
  background: var(--ug-bg-secondary, #f8fafc);
  color: var(--ug-dark, #1e293b);
  outline: none;
  transition: border-color .15s ease;
}

.ug-custom-scan-wrap input:focus {
  border-color: var(--ug-primary, #0ea5e9);
  background: var(--ug-bg-primary, #fff);
  box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}

/* ── Quick action list (dashboard sidebar) ────────────────────────────────── */

.ug-quick-action-list {
  display: flex;
  flex-direction: column;
}

.ug-quick-action-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--ug-border, #e2e8f0);
  text-decoration: none;
  color: var(--ug-dark, #1e293b);
  font-size: 14px;
  font-weight: 500;
  transition: color .15s ease, padding-left .15s ease;
}

.ug-quick-action-item:last-child { border-bottom: none; }

.ug-quick-action-item:hover {
  color: var(--ug-primary, #0ea5e9);
  padding-left: 4px;
}

.ug-quick-action-item .dashicons:first-child {
  color: var(--ug-primary, #0ea5e9);
  flex-shrink: 0;
  font-size: 18px;
  width: 18px;
  height: 18px;
}

.ug-quick-action-item .dashicons:last-child {
  margin-left: auto;
  color: var(--ug-gray-lighter, #b0bec5);
  font-size: 16px;
  width: 16px;
  height: 16px;
}

.ug-quick-action-item:hover .dashicons:last-child {
  color: var(--ug-primary, #0ea5e9);
}

/* ==========================================================================
   CURRENT RENDERER-COMPATIBLE SCAN UI
   Styles for elements that JS injects to match the PHP RenderEngine output.
   ========================================================================== */

/* Current file — injected as standalone block below the .ug-scan-live-stats list */
#ug-current-file.ug-scan-current-file {
  flex: none;         /* override the flex:1 from the panel-based rule */
  display: block;
  margin-top: 6px;
  padding: 4px 6px;
  background: var(--ug-bg-secondary, #f8fafc);
  border-radius: var(--ug-radius-sm, 4px);
  font-size: 11px;
  font-family: var(--ug-font-mono, 'SF Mono', Monaco, Consolas, monospace);
  color: var(--ug-gray, #64748b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Flatten renderer wrappers inside the scan card so reload state matches live JS state */
#ug-scan-panel #ug-progress-fill,
#fc-scan-progress-card #fc-scan-progress-bar,
#ug-db-scan-panel #db-scan-progress-bar {
  margin-bottom: 10px;
}

#ug-scan-panel #ug-progress-fill > .ultraguard-component,
#fc-scan-progress-card #fc-scan-progress-bar > .ultraguard-component,
#ug-db-scan-panel #db-scan-progress-bar > .ultraguard-component {
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}

/* Live stats list — compact horizontal layout */
.ug-scan-live-stats .ultraguard-list,
.fc-live-stats-row .ultraguard-list,
.ug-db-scan-stats .ultraguard-list {
  /* Strip the default list borders/bg so it sits cleanly inside the card */
  border: none;
  background: transparent;
  padding: 6px 0 2px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px 18px;
  flex-wrap: wrap;
}

.ug-scan-live-stats .ultraguard-list-item,
.fc-live-stats-row .ultraguard-list-item,
.ug-db-scan-stats .ultraguard-list-item {
  padding: 0;
  border: none;
  font-size: 13px;
  width: auto;
  min-width: 0;
  flex: 0 1 auto;
}

/* Threat badge turns red when count > 0 (badge class swapped by JS) */
.ug-scan-live-stats .ultraguard-badge-danger,
.fc-live-stats-row .ultraguard-badge-danger,
.ug-db-scan-stats .ultraguard-badge-danger {
  font-weight: 700;
}

/* Progress label — sits above the bar, updated by JS on every poll */
#ug-progress-fill .ultraguard-security-suitegress-label,
#fc-scan-progress-bar .ultraguard-security-suitegress-label,
#db-scan-progress-bar .ultraguard-security-suitegress-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ug-dark, #1e293b);
  margin-bottom: 6px;
}

/* Percentage readout below the bar */
#ug-progress-fill [data-rt-progress-label],
#fc-scan-progress-bar [data-rt-progress-label],
#db-scan-progress-bar [data-rt-progress-label] {
  display: block;
  font-size: 12px;
  color: var(--ug-gray, #64748b);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* Progress bar — ensure it has a minimum visible sliver */
#ug-progress-fill .ultraguard-security-suitegress-bar,
#fc-scan-progress-bar .ultraguard-security-suitegress-bar,
#db-scan-progress-bar .ultraguard-security-suitegress-bar {
  min-width: 2px;
  transition: width 0.4s ease;
}

/* ==========================================================================
   JS-INJECTED STATS BAR  (#ug-live-stats-injected)
   Shown when the page loads idle and a scan is started without a reload.
   Styled to match the PHP-rendered .ug-scan-live-stats list.
   ========================================================================== */
.ug-scan-stats-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 20px;
  padding: 10px 0 6px;
  border-top: 1px solid var(--ug-border, #e2e8f0);
  margin-top: 2px;
}

.ug-scan-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ug-dark, #1e293b);
}

.ug-scan-stat .dashicons {
  font-size: 16px;
  width: 16px;
  height: 16px;
  color: var(--ug-primary, #0ea5e9);
  flex-shrink: 0;
}

.ug-scan-stat-label {
  color: var(--ug-gray, #64748b);
  font-weight: 500;
}

/* Current file line — shown below stats in both PHP-list and injected variants */
.ug-scan-current-file {
  display: block;
  width: 100%;
  font-size: 11px;
  font-family: var(--ug-font-mono, 'SF Mono', Monaco, Consolas, 'Courier New', monospace);
  color: var(--ug-gray-light, #94a3b8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-top: 4px;
}

/* PHP-rendered live stats list — remove its default list chrome */
.ug-scan-live-stats.ultraguard-list {
  border: none;
  border-radius: 0;
  padding: 10px 0 6px;
  margin: 0;
  background: transparent;
  border-top: 1px solid var(--ug-border, #e2e8f0);
}

.ug-scan-live-stats .ultraguard-list-item:hover,
.fc-live-stats-row .ultraguard-list-item:hover,
.ug-db-scan-stats .ultraguard-list-item:hover {
  background: transparent;
  margin: 0;
  border-radius: 0;
}

.ug-scan-live-stats .ultraguard-list-badge,
.fc-live-stats-row .ultraguard-list-badge,
.ug-db-scan-stats .ultraguard-list-badge {
  margin-left: auto;
  min-width: 32px;
  text-align: center;
}

#ug-scan-panel .ug-scan-current-file,
#fc-scan-progress-card .fc-current-file,
#ug-db-scan-panel .ug-db-scan-phase,
#ug-db-scan-panel .ug-complete-detail {
  margin-top: 4px;
  margin-bottom: 0;
  padding: 4px 8px;
  background: var(--ug-bg-secondary, #f8fafc);
  border-radius: var(--ug-radius-sm, 4px);
  font-size: 11px;
  color: var(--ug-gray, #64748b);
}

#ug-db-scan-panel .ug-db-scan-phase,
#ug-db-scan-panel .ug-complete-detail {
  display: inline-block;
  width: auto;
}

@media (max-width: 782px) {
  .ug-scan-live-stats .ultraguard-list,
  .fc-live-stats-row .ultraguard-list,
  .ug-db-scan-stats .ultraguard-list,
  .ug-scan-stats-bar {
    gap: 8px 12px;
  }

  .ug-scan-live-stats .ultraguard-list-item,
  .fc-live-stats-row .ultraguard-list-item,
  .ug-db-scan-stats .ultraguard-list-item {
    flex-basis: 100%;
  }
}

/* ── Antivirus additional mobile fixes ─────────────────────────── */
@media screen and (max-width: 1024px) {
  .ultraguard-scan-controls {
    flex-wrap: wrap;
    gap: 8px;
  }

  .ultraguard-scan-controls .ultraguard-button {
    flex: 1 1 auto;
  }
}

@media screen and (max-width: 782px) {
  .ultraguard-scan-file-list {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .ultraguard-scan-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .ultraguard-quarantine-actions {
    flex-direction: column;
    gap: 6px;
  }

  .ultraguard-quarantine-actions .ultraguard-button {
    width: 100%;
    justify-content: center;
  }
}
