/* Erizos-drop — Corporate Visual Identity */

:root {
  --rts-red: #E30613;
  --rts-red-bright: #F11111;
  --rts-red-hover: #c00510;
  --bg-primary: #0a0a0a;
  --bg-secondary: #141414;
  --bg-elevated: #1e1e1e;
  --bg-card: #242424;
  --text-primary: #ffffff;
  --text-secondary: #b3b3b3;
  --text-muted: #737373;
  --border-subtle: #333333;
  --border-focus: #E30613;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;
  --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --transition: 0.2s ease;
  --bg-image: url('/images/studio-bg.jpg');
  --bg-overlay: rgba(8, 10, 18, 0.78);
  --bg-panel: rgba(36, 36, 36, 0.9);
  --surface-elevated: var(--bg-card);
  --surface-base: var(--bg-secondary);
}

[data-theme="light"] {
  --bg-primary: #f8f8f8;
  --bg-secondary: #ffffff;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --text-primary: #0a0a0a;
  --text-secondary: #404040;
  --text-muted: #737373;
  --border-subtle: #e5e5e5;
  --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.12);
  --bg-overlay: rgba(248, 248, 248, 0.84);
  --bg-panel: rgba(255, 255, 255, 0.92);
  --surface-elevated: var(--bg-card);
  --surface-base: var(--bg-secondary);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font);
  background-color: var(--bg-primary);
  background-image:
    linear-gradient(var(--bg-overlay), var(--bg-overlay)),
    var(--bg-image);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Layout ── */

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: rgba(20, 20, 20, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 3px solid var(--rts-red);
}

[data-theme="light"] .app-header {
  background: rgba(255, 255, 255, 0.88);
}

.logo-block {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-mark {
  width: 48px;
  height: 48px;
  background: var(--rts-red);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: #fff;
  letter-spacing: -0.02em;
}

.logo-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.logo-text span {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-badge {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.instance-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.2;
  text-transform: uppercase;
  vertical-align: middle;
}

.instance-badge.instance-prod {
  background: var(--rts-red);
  color: #fff;
}

.instance-badge.instance-test {
  background: #f59e0b;
  color: #111;
}

.app-main {
  flex: 1;
  padding: 2rem;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}

/* ── Login Page ── */

.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: rgba(36, 36, 36, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
}

[data-theme="light"] .login-card {
  background: rgba(255, 255, 255, 0.94);
}

.login-card .logo-block {
  justify-content: center;
  margin-bottom: 2rem;
}

.login-card h2 {
  text-align: center;
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  width: 100%;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--rts-red);
  color: #fff;
}

.btn-primary:hover {
  background: var(--rts-red-hover);
  box-shadow: 0 4px 14px rgba(227, 6, 19, 0.35);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  width: auto;
  font-size: 0.85rem;
}

.btn-ghost:hover {
  color: var(--text-primary);
}

.btn-microsoft {
  background: #2f2f2f;
  color: #fff;
  margin-bottom: 1rem;
}

.btn-microsoft.hidden {
  display: none;
}

[data-theme="light"] .btn-microsoft {
  background: #fff;
  color: #5e5e5e;
  border: 1px solid var(--border-subtle);
}

.btn-microsoft:hover {
  background: #404040;
}

.btn-microsoft svg {
  width: 20px;
  height: 20px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.ldap-section {
  margin-bottom: 0.5rem;
  transition: opacity var(--transition);
}

.ldap-section.hidden {
  display: none;
}

.ldap-section:not(.active) .form-group input,
.ldap-section:not(.active) button[type="submit"] {
  opacity: 0.6;
}

.ldap-label {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  text-align: center;
}

.ldap-label strong {
  color: var(--rts-red);
}

.fallback-section {
  opacity: 0.55;
  transition: opacity var(--transition);
}

.fallback-section.active {
  opacity: 1;
}

.fallback-section:not(.active) .form-group input,
.fallback-section:not(.active) button[type="submit"] {
  pointer-events: none;
}

.fallback-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--warning);
  margin-bottom: 1rem;
  text-align: center;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

.form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.95rem;
  transition: border-color var(--transition);
}

.form-group input:focus {
  outline: none;
  border-color: var(--border-focus);
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--error);
}

.alert-info {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--info);
}

/* ── Ephemeral storage warning ── */

.ephemeral-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 0.875rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(227, 6, 19, 0.45);
  background: rgba(227, 6, 19, 0.12);
  color: var(--rts-red-bright);
}

[data-theme="light"] .ephemeral-banner {
  background: rgba(227, 6, 19, 0.08);
  color: var(--rts-red);
}

.ephemeral-banner-icon {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  margin-top: 0.1rem;
  color: var(--rts-red-bright);
}

[data-theme="light"] .ephemeral-banner-icon {
  color: var(--rts-red);
}

.ephemeral-banner-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.ephemeral-banner-content {
  flex: 1;
  min-width: 0;
}

.ephemeral-banner-content > strong {
  display: block;
  font-size: 0.9375rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--rts-red-bright);
}

[data-theme="light"] .ephemeral-banner-content > strong {
  color: var(--rts-red);
}

.ephemeral-banner-content p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--text-primary);
}

.ephemeral-banner-content p strong {
  color: var(--rts-red-bright);
  font-weight: 700;
}

[data-theme="light"] .ephemeral-banner-content p strong {
  color: var(--rts-red);
}

.ephemeral-banner--compact {
  margin-bottom: 1.25rem;
  text-align: left;
}

.ephemeral-banner--compact .ephemeral-banner-content p {
  font-size: 0.8125rem;
}

/* ── Upload Zone ── */

.upload-zone {
  border: 2px dashed var(--border-subtle);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
  background: var(--bg-panel);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  margin-bottom: 2rem;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--rts-red);
  background: rgba(227, 6, 19, 0.04);
  transform: translateY(-2px);
}

.upload-zone-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  color: var(--rts-red);
}

.upload-zone h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.upload-zone p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.upload-zone .hint {
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

#fileInput {
  display: none;
}

/* Dossier : pas de display:none — Chrome/Edge bloquent le sélecteur sinon */
.file-input-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0.001;
  overflow: hidden;
  z-index: -1;
}

.upload-zone-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin: 1rem 0 0.5rem;
}

.upload-zone-actions .btn {
  width: auto;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.upload-resume-info {
  color: var(--info);
  font-size: 0.82rem;
  margin: 0.35rem 0 0.75rem;
}

/* ── Upload Queue ── */

.queue-section h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

.queue-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.upload-item {
  background: var(--bg-panel);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.upload-item.dismissing {
  opacity: 0;
  transform: translateX(12px);
}

.upload-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
  gap: 1rem;
}

.upload-item-name {
  font-weight: 600;
  font-size: 0.95rem;
  word-break: break-all;
}

.upload-item-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.upload-status {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  white-space: nowrap;
}

.status-uploading {
  background: rgba(59, 130, 246, 0.15);
  color: var(--info);
}

.status-paused {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.status-resuming {
  background: rgba(227, 6, 19, 0.15);
  color: var(--rts-red);
}

.status-scanning {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
}

.status-complete {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.status-error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
}

.progress-track {
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--rts-red), var(--rts-red-bright));
  border-radius: 999px;
  transition: width 0.3s ease;
  width: 0%;
}

.upload-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.upload-stats strong {
  color: var(--text-secondary);
}

.upload-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.upload-actions .btn {
  width: auto;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
}

.theme-toggle {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
}

.theme-toggle:hover {
  color: var(--text-primary);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

.lang-switcher {
  display: inline-flex;
  gap: 0.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.2rem;
}

.lang-btn {
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  min-width: 2rem;
  padding: 0.3rem 0.45rem;
}

.lang-btn:hover {
  color: var(--text-primary);
}

.lang-btn.active {
  background: var(--rts-red);
  color: #fff;
}

.login-card .lang-switcher {
  margin-bottom: 1rem;
}

.hidden,
[hidden] {
  display: none !important;
}

/* ── ClamAV badge ── */

.clamav-badge {
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  transition: border-color var(--transition), background var(--transition);
}

.clamav-badge[data-state="active"] {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.06);
}

.clamav-badge[data-state="offline"],
.clamav-badge[data-state="disabled"],
.clamav-badge[data-state="warning"] {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.06);
}

.clamav-badge[data-state="warning"] .clamav-badge-icon {
  color: var(--warning);
}

.clamav-badge-icon {
  align-items: center;
  color: var(--success);
  display: flex;
  flex-shrink: 0;
  height: 28px;
  justify-content: center;
  position: relative;
  width: 28px;
}

.clamav-badge[data-state="offline"] .clamav-badge-icon,
.clamav-badge[data-state="disabled"] .clamav-badge-icon,
.clamav-badge[data-state="loading"] .clamav-badge-icon {
  color: var(--warning);
}

.clamav-badge[data-state="active"] .clamav-badge-icon::after {
  animation: clamav-pulse 2s ease infinite;
  background: var(--success);
  border-radius: 50%;
  content: "";
  height: 8px;
  position: absolute;
  right: -1px;
  top: -1px;
  width: 8px;
}

.clamav-badge-icon svg {
  height: 22px;
  width: 22px;
}

.clamav-badge-text {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.4;
}

.clamav-badge-text strong {
  color: var(--text-primary);
  font-weight: 700;
}

@keyframes clamav-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.85); }
}

/* ── Storage gauge ── */

.storage-gauge {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
}

.storage-gauge-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.625rem;
}

.storage-gauge-label {
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.storage-gauge-text {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: right;
}

.storage-gauge-track {
  background: var(--bg-elevated);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.storage-gauge-fill {
  background: linear-gradient(90deg, var(--rts-red), var(--rts-red-bright));
  border-radius: 999px;
  height: 100%;
  transition: width 0.5s ease;
  width: 0%;
}

.storage-gauge[data-level="warning"] .storage-gauge-fill {
  background: linear-gradient(90deg, #d97706, var(--warning));
}

.storage-gauge[data-level="critical"] .storage-gauge-fill {
  background: linear-gradient(90deg, #b91c1c, var(--error));
}

/* ── Tabs ── */

.tab-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: -1px;
  padding: 0.75rem 1.25rem;
  transition: color var(--transition), border-color var(--transition);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  border-bottom-color: var(--rts-red);
  color: var(--text-primary);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ── Logs ── */

.logs-section {
  background: var(--bg-panel);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.logs-header {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.logs-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.logs-toolbar {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.logs-filter {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 220px;
}

.logs-filter > span {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.logs-filter input[type="search"] {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  padding: 0.55rem 0.75rem;
}

.logs-filter-check {
  flex-direction: row;
  align-items: center;
  min-width: auto;
  padding-bottom: 0.55rem;
}

.logs-filter-check input {
  accent-color: var(--rts-red);
  margin-right: 0.5rem;
}

.logs-count {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-left: auto;
  padding-bottom: 0.55rem;
}

.logs-header h2 {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

.logs-export,
.logs-refresh {
  width: auto;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.logs-table-wrap {
  overflow-x: auto;
}

.logs-table {
  border-collapse: collapse;
  font-size: 0.9rem;
  width: 100%;
}

.logs-table thead th {
  border-bottom: 2px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  text-align: left;
  text-transform: uppercase;
}

.logs-table tbody td {
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.875rem 1rem;
  vertical-align: middle;
}

.logs-table tbody tr:hover {
  background: rgba(227, 6, 19, 0.04);
}

.logs-table tbody tr:last-child td {
  border-bottom: none;
}

.log-user-cell {
  color: var(--text-secondary);
  font-size: 0.85rem;
  white-space: nowrap;
  width: 1%;
}

.log-file-cell-wrapper {
  min-width: 320px;
}

.log-file-cell {
  align-items: flex-start;
  display: flex;
  gap: 0.875rem;
}

.log-file-preview {
  flex-shrink: 0;
}

.log-file-details {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.log-filename {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: normal;
}

.log-file-meta {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.log-media-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.log-media-tag {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.2;
  padding: 0.15rem 0.45rem;
  white-space: nowrap;
}

.log-status-cell {
  text-align: center;
  white-space: nowrap;
  width: 1%;
}

.log-status-wrap {
  align-items: center;
  display: inline-flex;
  gap: 0.45rem;
}

.log-timeline-toggle {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  height: 1.5rem;
  line-height: 1;
  padding: 0;
  width: 1.5rem;
}

.log-timeline-toggle:hover {
  background: rgba(227, 6, 19, 0.12);
  border-color: rgba(227, 6, 19, 0.35);
  color: var(--text-primary);
}

.log-timeline-row.hidden {
  display: none;
}

.log-timeline-row td {
  background: rgba(255, 255, 255, 0.02);
  padding-bottom: 1rem !important;
  padding-top: 0 !important;
}

.log-timeline-panel {
  border-left: 2px solid var(--border-subtle);
  margin-left: 0.5rem;
  padding: 0.75rem 0 0.25rem 1rem;
}

.log-timeline-title {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  margin: 0 0 0.75rem;
  text-transform: uppercase;
}

.log-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.log-timeline-item {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: auto 1fr;
}

.log-timeline-marker {
  background: var(--border-subtle);
  border-radius: 999px;
  height: 0.65rem;
  margin-top: 0.35rem;
  width: 0.65rem;
}

.log-timeline-done .log-timeline-marker {
  background: var(--success);
}

.log-timeline-active .log-timeline-marker {
  animation: log-timeline-pulse 1.4s ease-in-out infinite;
  background: #a78bfa;
}

.log-timeline-pending .log-timeline-marker {
  background: rgba(255, 255, 255, 0.15);
}

.log-timeline-error .log-timeline-marker {
  background: var(--error);
}

.log-timeline-content {
  min-width: 0;
}

.log-timeline-head {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  justify-content: space-between;
}

.log-timeline-head strong {
  font-size: 0.85rem;
}

.log-timeline-head time {
  color: var(--text-muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.log-timeline-content p {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin: 0.2rem 0 0;
}

@keyframes log-timeline-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.55;
    transform: scale(0.9);
  }
}

.log-datetime-cell {
  color: var(--text-secondary);
  font-size: 0.85rem;
  white-space: nowrap;
  width: 1%;
}

.log-datetime {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.log-date {
  font-weight: 500;
}

.log-time {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.log-preview-btn {
  background: none;
  border: none;
  cursor: zoom-in;
  padding: 0;
}

.log-preview {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: block;
  height: 54px;
  object-fit: cover;
  width: 96px;
}

.log-preview-empty {
  color: var(--text-muted);
  display: inline-block;
  width: 96px;
}

.log-preview-lightbox {
  align-items: center;
  display: flex;
  inset: 0;
  justify-content: center;
  position: fixed;
  z-index: 1000;
}

.log-preview-lightbox.hidden {
  display: none;
}

.log-preview-lightbox-backdrop {
  background: rgba(0, 0, 0, 0.75);
  inset: 0;
  position: absolute;
}

.log-preview-lightbox-content {
  margin: 0;
  max-height: 90vh;
  max-width: 90vw;
  position: relative;
  z-index: 1;
}

.log-preview-lightbox-content img {
  border-radius: var(--radius-sm);
  display: block;
  max-height: 90vh;
  max-width: min(90vw, 1920px);
  min-height: 120px;
  object-fit: contain;
  width: auto;
}

.log-preview-lightbox-content img.is-loading {
  opacity: 0.35;
}

.log-preview-lightbox-content figcaption {
  color: #fff;
  font-size: 0.9rem;
  margin-top: 0.75rem;
  text-align: center;
}

.log-preview-lightbox-close {
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 999px;
  color: #fff;
  cursor: pointer;
  font-size: 1.5rem;
  height: 2.25rem;
  line-height: 1;
  position: absolute;
  right: -0.5rem;
  top: -0.5rem;
  width: 2.25rem;
}

.log-status {
  cursor: default;
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  text-transform: uppercase;
  white-space: nowrap;
}

.log-status-scanning {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
}

.log-status-clean {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.log-status-infected {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
  text-transform: none;
}

.log-status-cancelled {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  text-transform: none;
}

.log-status-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  text-transform: none;
}

.log-retry-publish-btn {
  margin-top: 0.5rem;
}

.log-unpublish-btn {
  margin-top: 0.5rem;
}

.logs-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 2rem;
  text-align: center;
}

@media (max-width: 640px) {
  .app-header {
    padding: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
  }

  .app-main {
    padding: 1rem;
  }

  .upload-zone {
    padding: 2rem 1rem;
  }

  .storage-gauge-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.25rem;
  }

  .storage-gauge-text {
    text-align: left;
  }

  .logs-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.75rem;
  }

  .logs-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .logs-count {
    margin-left: 0;
  }

  .logs-table thead {
    display: none;
  }

  .logs-table tbody tr {
    display: block;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
  }

  .logs-table tbody td {
    border: none;
    display: block;
    padding: 0.25rem 0;
  }

  .logs-table tbody td::before {
    color: var(--text-muted);
    content: attr(data-label);
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
  }

  .log-file-cell-wrapper {
    min-width: 0;
  }

  .log-status-cell,
  .log-datetime-cell {
    text-align: left;
  }

  .log-timeline-row td {
    display: block;
  }

  .log-timeline-row td::before {
    display: none;
  }

  .log-timeline-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.15rem;
  }
}

/* ── Documentation ── */

.docs-layout {
  display: grid;
  flex: 1;
  gap: 2rem;
  grid-template-columns: 220px minmax(0, 1fr);
  margin: 0 auto;
  max-width: 1200px;
  padding: 2rem;
  width: 100%;
}

.docs-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  position: sticky;
  top: 1.5rem;
  align-self: start;
}

.docs-nav a {
  border-left: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.88rem;
  padding: 0.4rem 0 0.4rem 0.75rem;
  text-decoration: none;
  transition: color var(--transition), border-color var(--transition);
}

.docs-nav a:hover,
.docs-nav a.active {
  border-left-color: var(--rts-red);
  color: var(--text-primary);
}

.docs-content {
  min-width: 0;
}

.docs-section {
  margin-bottom: 3rem;
  scroll-margin-top: 1.5rem;
}

.docs-section h2 {
  border-bottom: 1px solid var(--border-subtle);
  font-size: 1.35rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
}

.docs-section h3 {
  font-size: 1rem;
  margin: 1.5rem 0 0.75rem;
}

.docs-section p,
.docs-section li {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.6;
}

.docs-list,
.docs-steps {
  margin: 0.75rem 0 1rem 1.25rem;
}

.docs-list li,
.docs-steps li {
  margin-bottom: 0.35rem;
}

.docs-section code {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.84em;
  padding: 0.1rem 0.35rem;
}

.docs-diagram {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin: 1rem 0;
  overflow-x: auto;
  padding: 1rem;
}

.docs-diagram code {
  background: none;
  padding: 0;
  white-space: pre;
}

.docs-code-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin: 0.75rem 0 1.25rem;
  overflow: hidden;
  position: relative;
}

.docs-code-wrap pre {
  margin: 0;
  overflow-x: auto;
  padding: 1rem 1rem 1rem 1.25rem;
}

.docs-code-wrap code {
  background: none;
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  padding: 0;
  white-space: pre;
}

.docs-copy-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  position: absolute;
  right: 0.5rem;
  top: 0.5rem;
  z-index: 1;
}

.docs-copy-btn:hover {
  border-color: var(--rts-red);
  color: var(--text-primary);
}

.docs-table {
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 1rem 0;
  width: 100%;
}

.docs-table th,
.docs-table td {
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.65rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

.docs-table th {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.docs-callout {
  background: rgba(227, 6, 19, 0.08);
  border: 1px solid rgba(227, 6, 19, 0.25);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin: 1rem 0;
  padding: 0.85rem 1rem;
}

.docs-base {
  margin-top: 1rem;
}

.docs-footer-note {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 2rem;
}

.docs-section a {
  color: var(--rts-red-bright);
}

.login-docs-link {
  margin-top: 1.25rem;
  text-align: center;
}

.login-docs-link a {
  color: var(--text-muted);
  font-size: 0.88rem;
  text-decoration: none;
}

.login-docs-link a:hover {
  color: var(--rts-red-bright);
}

/* ── Footer ── */

.app-footer {
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
  padding: 1.25rem 2rem 1.5rem;
  text-align: center;
}

.login-page .app-footer {
  margin-top: 2rem;
  max-width: 420px;
  padding-left: 1rem;
  padding-right: 1rem;
  width: 100%;
}

.app-footer-copy {
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.app-footer-notice {
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.5;
  margin: 0 auto;
  max-width: 52rem;
}

/* ── Admin ── */

.admin-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.admin-header {
  align-items: flex-start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.admin-header h2 {
  font-size: 1.35rem;
  margin-bottom: 0.25rem;
}

.admin-subtitle {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.admin-stats-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.admin-card {
  background: var(--bg-panel);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.admin-card h3 {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.admin-card-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.admin-card-meta {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-top: 0.35rem;
}

.admin-block h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

.admin-logs-summary {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

.admin-logs-clean {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.admin-logs-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 220px;
}

.admin-logs-field span {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
}

.admin-logs-field select {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font: inherit;
  padding: 0.55rem 0.75rem;
}

.admin-logs-hint {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin: 0;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  border-collapse: collapse;
  font-size: 0.88rem;
  width: 100%;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.7rem 0.75rem;
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.admin-actions-cell {
  white-space: nowrap;
}

.admin-empty {
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 1.25rem 0;
  text-align: center;
}

.admin-delete-btn {
  font-size: 0.78rem;
  padding: 0.35rem 0.65rem;
}

.admin-erizos-hint,
.admin-routing-hint {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0 0 1rem;
}

.admin-routing-source {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin: 0.75rem 0 0;
}

.admin-erizos-form {
  margin-bottom: 1.25rem;
}

.admin-erizos-grid {
  display: grid;
  gap: 0.75rem 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 0.75rem;
}

.admin-erizos-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.admin-erizos-field span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.admin-erizos-field input[type="text"],
.admin-erizos-field input[type="number"] {
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-primary);
  font: inherit;
  padding: 0.45rem 0.6rem;
}

.admin-erizos-field-sm {
  max-width: 120px;
}

.admin-erizos-field-wide {
  grid-column: 1 / -1;
}

.admin-erizos-field-check {
  align-items: center;
  flex-direction: row;
  gap: 0.5rem;
}

.admin-erizos-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.admin-publish-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.admin-erizos-select {
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-primary);
  font: inherit;
  max-width: 160px;
  padding: 0.35rem 0.5rem;
}

.admin-publish-btn {
  font-size: 0.78rem;
  padding: 0.35rem 0.55rem;
}

.erizos-publish-bar {
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
}

.erizos-publish-bar-main {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

.erizos-publish-bar-label {
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 600;
  width: 100%;
}

.erizos-publish-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.erizos-publish-field span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.erizos-publish-field select {
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-primary);
  font: inherit;
  min-width: 180px;
  padding: 0.4rem 0.55rem;
}

.erizos-publish-field-wide select {
  min-width: 220px;
}

.erizos-publish-hint {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin: 0.65rem 0 0;
}

.erizos-modal {
  align-items: center;
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 1.25rem;
  position: fixed;
  z-index: 10000;
}

.erizos-modal.hidden {
  display: none !important;
}

.erizos-modal-backdrop {
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(3px);
  inset: 0;
  position: absolute;
}

.erizos-modal-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 2.5rem);
  max-width: 440px;
  overflow-y: auto;
  padding: 1.35rem;
  position: relative;
  width: min(440px, 100%);
  z-index: 1;
}

.erizos-modal-panel h3 {
  margin: 0 0 0.5rem;
}

.erizos-modal-file {
  color: var(--rts-red);
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
  word-break: break-all;
}

.erizos-modal-intro {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0 0 1rem;
}

.erizos-modal-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.erizos-modal-field span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.erizos-modal-field select {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-primary);
  font: inherit;
  padding: 0.45rem 0.6rem;
  width: 100%;
}

.erizos-modal-check {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  margin: 0.25rem 0 1rem;
}

.erizos-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

body.erizos-modal-open {
  overflow: hidden;
}

.admin-erizos-user {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.admin-publish-status-cell {
  min-width: 150px;
}

.admin-publish-badge {
  border-radius: 999px;
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  padding: 0.2rem 0.55rem;
}

.admin-publish-badge--published {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.admin-publish-badge--failed {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
}

.admin-publish-badge--skipped,
.admin-publish-badge--none {
  background: rgba(115, 115, 115, 0.15);
  color: var(--text-muted);
}

.admin-retry-btn {
  display: block;
  font-size: 0.76rem;
  padding: 0.25rem 0.45rem;
}

@media (max-width: 900px) {
  .docs-layout {
    grid-template-columns: 1fr;
    padding: 1rem;
  }

  .docs-nav {
    border-bottom: 1px solid var(--border-subtle);
    flex-direction: row;
    flex-wrap: wrap;
    padding-bottom: 1rem;
    position: static;
  }

  .docs-nav a {
    border-left: none;
    border-bottom: 2px solid transparent;
    padding: 0.35rem 0.5rem;
  }

  .docs-nav a:hover,
  .docs-nav a.active {
    border-bottom-color: var(--rts-red);
    border-left-color: transparent;
  }
}
