/* ==========================================================================
   ROM Picker & Exporter - Premium Modern Dark Design System
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Primary Color Palette */
  --bg-dark: #090d16;
  --bg-card: #121827;
  --bg-card-hover: #1a2236;
  --bg-card-selected: #1e293b;
  --bg-glass: rgba(18, 24, 39, 0.75);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-hover: rgba(255, 255, 255, 0.18);
  --border-active: rgba(99, 102, 241, 0.4);

  --accent-cyan: #06b6d4;
  --accent-violet: #6366f1;
  --accent-purple: #a855f7;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;

  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  --gradient-cyan: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
  --gradient-emerald: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --gradient-rose: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);

  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(6, 182, 212, 0.08) 0%, transparent 40%);
  background-attachment: fixed;
  padding-bottom: 90px; /* Space for fixed bottom tally bar */
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
  background: #2a3449;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #3b4863;
}

/* Header styling */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 24px;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

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

.brand-icon {
  width: 42px;
  height: 42px;
  background: var(--gradient-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
}

.brand-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: #ffffff;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-text h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  text-decoration: none;
  font-family: inherit;
}

.btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
}

.btn-primary {
  background: var(--gradient-primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-color-hover);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent-rose);
  border-color: rgba(244, 63, 94, 0.25);
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.2);
  border-color: rgba(244, 63, 94, 0.4);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* Main Container */
.main-layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  width: 100%;
  flex: 1;
}

/* System Tabs Navigation */
.tabs-wrapper {
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.tabs-list {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
  min-width: max-content;
}

.tab-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-color-hover);
}

.tab-item.active {
  background: var(--gradient-primary);
  color: #ffffff;
  border-color: transparent;
  box-shadow: var(--shadow-glow);
}

.tab-badge {
  background: rgba(255, 255, 255, 0.15);
  color: inherit;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
}

.tab-item.active .tab-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.tab-badge.has-count {
  background: var(--accent-cyan);
  color: #000000;
}

.tab-item.active .tab-badge.has-count {
  background: #ffffff;
  color: var(--accent-violet);
}

/* Search and Toolbar */
.toolbar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 260px;
}

.search-box svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  stroke: var(--text-muted);
  fill: none;
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 42px;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--accent-violet);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.info-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.info-text span {
  color: var(--accent-cyan);
  font-weight: 700;
}

/* Table styling */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin-bottom: 32px;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.rom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.rom-table th {
  background: rgba(15, 23, 42, 0.8);
  padding: 14px 18px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  user-select: none;
}

.rom-table td {
  padding: 12px 18px;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background-color 0.15s ease;
}

.rom-table tbody tr {
  cursor: pointer;
}

.rom-table tbody tr:hover {
  background-color: var(--bg-card-hover);
}

.rom-table tbody tr.selected-row {
  background-color: rgba(99, 102, 241, 0.12);
}

.rom-table tbody tr.selected-row:hover {
  background-color: rgba(99, 102, 241, 0.18);
}

.col-checkbox {
  width: 50px;
  text-align: center;
}

.col-title {
  font-weight: 600;
  color: var(--text-main);
  min-width: 220px;
}

.col-file {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.825rem;
  color: var(--text-muted);
  min-width: 260px;
}

.col-system {
  width: 150px;
}

.system-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

/* Custom Checkbox */
.custom-checkbox {
  position: relative;
  display: inline-block;
  width: 20px;
  height: 20px;
  vertical-align: middle;
}

.custom-checkbox input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.checkmark {
  position: absolute;
  top: 0;
  left: 0;
  height: 20px;
  width: 20px;
  background-color: var(--bg-dark);
  border: 1.5px solid var(--text-dim);
  border-radius: 4px;
  transition: all 0.2s ease;
}

.custom-checkbox:hover input ~ .checkmark {
  border-color: var(--accent-violet);
}

.custom-checkbox input:checked ~ .checkmark {
  background: var(--gradient-primary);
  border-color: transparent;
}

.checkmark:after {
  content: "";
  position: absolute;
  display: none;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.custom-checkbox input:checked ~ .checkmark:after {
  display: block;
}

/* Pagination */
.pagination-wrapper {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.4);
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 12px;
}

.page-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Detailed Tally Section at Bottom */
.tally-section {
  margin-top: 40px;
  border-top: 2px dashed var(--border-color);
  padding-top: 36px;
}

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

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

.section-title h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

.tally-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 24px;
  margin-bottom: 32px;
}

@media (max-width: 1024px) {
  .tally-grid {
    grid-template-columns: 1fr;
  }
}

.tally-summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.summary-stats-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.stat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-dark);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.stat-name {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.stat-val {
  font-weight: 700;
  color: var(--accent-cyan);
}

.progress-bar-container {
  width: 100px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient-cyan);
  border-radius: 3px;
}

/* Selected Items Detailed Table */
.selected-items-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.selected-table-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.remove-btn {
  background: rgba(244, 63, 94, 0.12);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.775rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.remove-btn:hover {
  background: var(--accent-rose);
  color: #ffffff;
}

.remove-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2.2;
}

/* Sticky Bottom Tally Bar */
.sticky-tally-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(18, 24, 39, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-active);
  padding: 14px 24px;
  z-index: 90;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.6);
}

.tally-bar-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.tally-info {
  display: flex;
  align-items: center;
  gap: 20px;
}

.tally-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-dark);
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.tally-pill-count {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent-cyan);
}

.tally-pill-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

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

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  stroke: var(--text-dim);
  margin-bottom: 12px;
  fill: none;
}

/* Responsive tweaks */
@media (max-width: 768px) {
  header {
    padding: 12px 16px;
  }
  .main-layout {
    padding: 16px;
  }
  .tally-bar-content {
    flex-direction: column;
    align-items: stretch;
  }
  .tally-info {
    justify-content: space-between;
  }
}
