/* ============================================================
   PII Masker — Dark Theme CSS
   Trash Panda Labs, LLC — raccooncode.net
   ============================================================ */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Neutrals */
  --midnight:  #0B0E11;
  --charcoal:  #1A1E24;
  --gunmetal:  #2A2F38;
  --slate:     #3D4450;
  --ash:       #6B7280;
  --silver:    #9CA3AF;
  --mist:      #D1D5DB;
  --ghost:     #F3F4F6;
  --white:     #FAFBFC;

  /* Brand Teal */
  --teal-900:  #063B3B;
  --teal-700:  #0D7377;
  --teal-500:  #14B8A6;
  --teal-400:  #2DD4BF;
  --teal-300:  #5EEAD4;
  --teal-200:  #99F6E4;

  /* Ice Blue */
  --ice-700:   #1E5F8A;
  --ice-500:   #38A0D6;
  --ice-400:   #5BB8E8;
  --ice-300:   #8DD0F0;
  --ice-200:   #BAE3F7;

  /* Signal */
  --signal-green: #22C55E;
  --signal-amber: #F59E0B;
  --signal-red:   #EF4444;

  /* Effects */
  --teal-glow:        rgba(20, 184, 166, 0.35);
  --teal-glow-strong: rgba(45, 212, 191, 0.6);
  --ice-glow:         rgba(56, 160, 214, 0.3);

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Layout */
  --nav-height: 52px;
  --sidebar-width: 260px;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: 'Outfit', system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--mist);
  background-color: var(--midnight);

  /* Circuit-grid atmosphere */
  background-image:
    linear-gradient(rgba(20,184,166,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20,184,166,0.03) 1px, transparent 1px);
  background-size: 60px 60px;
}

a { color: var(--teal-400); text-decoration: none; }
a:hover { color: var(--teal-300); }

button {
  cursor: pointer;
  font-family: inherit;
}

ul, ol { list-style: none; }

/* ── Navigation Bar ─────────────────────────────────────────── */
.topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(11, 14, 17, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-logo {
  flex-shrink: 0;
}

.nav-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -0.01em;
}

.nav-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--teal-500);
  background: rgba(20, 184, 166, 0.12);
  border: 1px solid rgba(20, 184, 166, 0.2);
  border-radius: 100px;
  padding: 2px 7px;
}

/* ── Mode Toggle Buttons ────────────────────────────────────── */
.nav-mode-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--gunmetal);
  border-radius: var(--radius-md);
  padding: 3px;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--silver);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.mode-btn:hover {
  color: var(--mist);
  background: rgba(255, 255, 255, 0.06);
}

.mode-btn.active {
  color: var(--midnight);
  background: var(--teal-500);
}

.mode-btn.active:hover {
  background: var(--teal-400);
}

.mode-btn svg {
  flex-shrink: 0;
}

/* ── App Layout ─────────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  padding-top: var(--nav-height);
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--charcoal);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  padding: 16px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--gunmetal) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--gunmetal); border-radius: 2px; }

.sidebar-section { display: flex; flex-direction: column; gap: 16px; }
/* Ensure hidden attribute works on elements with explicit display */
[hidden] { display: none !important; }

.sidebar-group { display: flex; flex-direction: column; gap: 8px; }

.sidebar-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ash);
}

/* ── Upload Area ────────────────────────────────────────────── */
.upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 12px;
  background: var(--midnight);
  border: 1.5px dashed var(--gunmetal);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
  min-height: 100px;
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--teal-500);
  background: rgba(20, 184, 166, 0.04);
}

.upload-area.has-file {
  border-color: var(--teal-700);
  border-style: solid;
  background: rgba(20, 184, 166, 0.06);
}

.upload-text {
  font-size: 0.8rem;
  color: var(--silver);
}

.upload-link {
  color: var(--teal-400);
  cursor: pointer;
}

.upload-link:hover { color: var(--teal-300); }

.upload-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--ash);
}

.upload-status {
  font-size: 0.8rem;
  color: var(--teal-400);
  padding: 4px 8px;
  background: rgba(20, 184, 166, 0.08);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(20, 184, 166, 0.2);
}

/* ── Sheet Tabs ─────────────────────────────────────────────── */
.sheet-tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sheet-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  font-size: 0.85rem;
  color: var(--silver);
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  user-select: none;
}

.sheet-tab:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--mist);
}

.sheet-tab.active {
  background: rgba(20, 184, 166, 0.12);
  color: var(--teal-400);
  border-left: 2px solid var(--teal-500);
  padding-left: 8px;
}

.sheet-tab-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 100px;
  border: 1px solid;
  flex-shrink: 0;
  white-space: nowrap;
}

.badge-configured,
.badge-mask {
  color: var(--signal-green);
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.2);
}

.badge-skip {
  color: var(--ash);
  background: rgba(107, 114, 128, 0.12);
  border-color: rgba(107, 114, 128, 0.2);
}

.badge-pending {
  color: var(--signal-amber);
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.2);
}

.badge-teal {
  color: var(--teal-400);
  background: rgba(20, 184, 166, 0.12);
  border-color: rgba(20, 184, 166, 0.2);
}

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 24px 100px;
  scrollbar-width: thin;
  scrollbar-color: var(--gunmetal) transparent;
}

.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb { background: var(--gunmetal); border-radius: 3px; }

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: calc(100vh - var(--nav-height) - 80px);
  text-align: center;
}

.empty-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--silver);
}

.empty-sub {
  font-size: 0.88rem;
  color: var(--ash);
  max-width: 320px;
}

/* ── Preview Tabs ───────────────────────────────────────────── */
.preview-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--gunmetal);
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

.preview-tabs::-webkit-scrollbar { display: none; }

.preview-tab {
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--silver);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s, border-color 0.12s;
  margin-bottom: -1px;
}

.preview-tab:hover { color: var(--mist); }

.preview-tab.active {
  color: var(--teal-400);
  border-bottom-color: var(--teal-500);
}

/* ── Text Preview (report unmask) ──────────────────────────── */
.text-preview {
  background: var(--surface-800);
  border: 1px solid var(--surface-600);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--mist);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  max-height: calc(100vh - var(--nav-height) - 240px);
}

/* ── Table Container ────────────────────────────────────────── */
.table-container {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - var(--nav-height) - 240px);
  border: 1px solid var(--gunmetal);
  border-radius: var(--radius-md);
  scrollbar-width: thin;
  scrollbar-color: var(--gunmetal) transparent;
}

.table-container::-webkit-scrollbar { width: 6px; height: 6px; }
.table-container::-webkit-scrollbar-track { background: transparent; }
.table-container::-webkit-scrollbar-thumb { background: var(--gunmetal); border-radius: 3px; }

/* ── Data Table ─────────────────────────────────────────────── */
.data-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
}

.data-table td,
.data-table th {
  padding: 6px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Row number sticky column */
.row-num {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--charcoal);
  color: var(--ash);
  font-size: 0.72rem;
  text-align: right;
  min-width: 40px;
  border-right: 1px solid var(--gunmetal) !important;
  user-select: none;
}

/* Header row — column names */
.header-row th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: rgba(20, 184, 166, 0.08);
  color: var(--teal-300);
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid var(--teal-700) !important;
  border-left: 2px solid var(--teal-500);
  padding-left: 10px;
}

.header-row th.row-num {
  background: rgba(20, 184, 166, 0.08);
  border-left: none;
  z-index: 4;
}

/* Strategy row — select dropdowns */
.strategy-row td {
  position: sticky;
  top: 33px;     /* below header row */
  z-index: 3;
  background: rgba(20, 184, 166, 0.04);
  border-bottom: 1px solid var(--gunmetal) !important;
  padding: 4px 8px;
}

.strategy-row td.row-num {
  background: rgba(20, 184, 166, 0.04);
  z-index: 4;
}

/* Data rows */
.data-row {
  cursor: pointer;
  transition: background 0.1s;
}

.data-row:nth-child(odd) td {
  background: var(--midnight);
}

.data-row:nth-child(even) td {
  background: rgba(26, 30, 36, 0.6);
}

.data-row:hover td {
  background: rgba(20, 184, 166, 0.05);
}

.data-row.header-marked td {
  background: rgba(20, 184, 166, 0.08);
  color: var(--teal-300);
  font-weight: 500;
}

.data-row.header-marked td.row-num {
  background: rgba(20, 184, 166, 0.08);
}

/* ── Strategy Select ────────────────────────────────────────── */
.strategy-select {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--mist);
  background: var(--gunmetal);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  min-width: 130px;
  max-width: 180px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.strategy-select:hover {
  border-color: var(--teal-700);
}

.strategy-select:focus {
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px var(--teal-glow);
}

.strategy-select.is-skip {
  color: var(--ash);
}

.strategy-select.is-active {
  color: var(--teal-300);
  border-color: rgba(20, 184, 166, 0.4);
}

/* ── Buttons ────────────────────────────────────────────────── */
a.btn-primary, a.btn-ghost {
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--midnight);
  background: var(--teal-500);
  border: none;
  border-radius: var(--radius-sm);
  transition: background 0.15s, box-shadow 0.15s;
  text-transform: none;
  letter-spacing: 0;
}

.btn-primary:hover:not(:disabled) {
  background: var(--teal-400);
  box-shadow: 0 0 0 3px var(--teal-glow);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--mist);
  background: transparent;
  border: 1.5px solid var(--gunmetal);
  border-radius: var(--radius-sm);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--teal-400);
  border-color: var(--teal-500);
  background: rgba(20, 184, 166, 0.05);
}

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

.btn-sm {
  padding: 5px 12px;
  font-size: 0.75rem;
}

/* ── Action Bar ─────────────────────────────────────────────── */
.action-bar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(11, 14, 17, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--gunmetal);
  margin-top: 16px;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.action-bar-info {
  font-size: 0.82rem;
  color: var(--silver);
  flex: 1;
}

.action-bar-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Result Header ──────────────────────────────────────────── */
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.result-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
}

/* ── Sheet Config Section ───────────────────────────────────── */
.sheet-section {
  margin-bottom: 24px;
}

.sheet-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.sheet-section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--mist);
}

.skip-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--silver);
  cursor: pointer;
  user-select: none;
  margin-left: auto;
}

.skip-toggle input[type="checkbox"] {
  accent-color: var(--teal-500);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* ── Inputs ─────────────────────────────────────────────────── */
input[type="text"],
input[type="search"],
select {
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--mist);
  background: var(--midnight);
  border: 1.5px solid var(--gunmetal);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

input[type="text"]:focus,
input[type="search"]:focus,
select:focus {
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px var(--teal-glow);
}

/* ── Scrollbar (global) ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gunmetal); border-radius: 3px; }

/* ── Loading / Spinner ──────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(20, 184, 166, 0.3);
  border-top-color: var(--teal-500);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Toast notifications ────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--charcoal);
  border: 1px solid var(--gunmetal);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: var(--mist);
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  pointer-events: auto;
  animation: slideUp 0.2s ease;
}

.toast.toast-error {
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--signal-red);
}

.toast.toast-success {
  border-color: rgba(34, 197, 94, 0.3);
  color: var(--signal-green);
}

@keyframes slideUp {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

/* ── Utility classes ────────────────────────────────────────── */
.hidden { display: none !important; }
.mono { font-family: 'JetBrains Mono', monospace; }
.text-teal { color: var(--teal-400); }
.text-muted { color: var(--ash); }
.text-silver { color: var(--silver); }

/* ── Skip-sheet overlay ─────────────────────────────────────── */
.skip-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 80px;
  border: 1.5px dashed var(--gunmetal);
  border-radius: var(--radius-md);
  color: var(--ash);
  font-size: 0.85rem;
  font-style: italic;
}

/* ── Divider ────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--gunmetal);
  margin: 16px 0;
}

/* ── Mode switch transition ─────────────────────────────────── */
#mask-view,
#unmask-view {
  animation: fadeIn 0.18s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Download buttons — prominent after masking ─────────────── */
#btn-download-masked:not(:disabled),
#btn-download-restored:not(:disabled) {
  background: var(--teal-500);
  box-shadow: 0 0 0 2px var(--teal-glow);
}

#btn-download-masked:not(:disabled):hover,
#btn-download-restored:not(:disabled):hover {
  background: var(--teal-400);
  box-shadow: 0 0 0 4px var(--teal-glow-strong);
}

#btn-download-key:not(:disabled) {
  border-color: var(--teal-700);
  color: var(--teal-300);
}

/* ── Skip sheet message ─────────────────────────────────────── */
.skip-overlay {
  font-style: normal;
  letter-spacing: 0.02em;
  color: var(--silver);
  background: rgba(107, 114, 128, 0.05);
}

/* ── Upload area loading state ──────────────────────────────── */
.upload-area.is-loading {
  pointer-events: none;
  opacity: 0.7;
}

/* ── Uploading indicator inside upload area ─────────────────── */
.upload-loading-text {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--teal-400);
}
