/* ==========================================================================
   LeetCode Company-Wise Problems Catalog - Modern Clean Design System
   ========================================================================== */

/* --- CSS Variables & Design Tokens --- */
:root {
  /* Light Theme */
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-subtle: #f1f5f9;
  --bg-input: #ffffff;
  
  --border-subtle: #e2e8f0;
  --border-default: #cbd5e1;
  --border-focus: #3b82f6;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  
  --accent-primary: #2563eb;
  --accent-primary-hover: #1d4ed8;
  --accent-light: #eff6ff;
  
  /* Difficulty Pills */
  --diff-easy-bg: #ecfdf5;
  --diff-easy-text: #059669;
  --diff-easy-border: #a7f3d0;
  
  --diff-med-bg: #fffbeb;
  --diff-med-text: #d97706;
  --diff-med-border: #fde68a;
  
  --diff-hard-bg: #fef2f2;
  --diff-hard-text: #dc2626;
  --diff-hard-border: #fecaca;

  /* Frequency Bar */
  --freq-bar-track: #e2e8f0;
  --freq-bar-fill: #3b82f6;

  /* Typography */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
  --shadow-modal: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  
  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-app: #0b0f19;
  --bg-card: #131b2e;
  --bg-card-hover: #1a243d;
  --bg-subtle: #1a233a;
  --bg-input: #101626;
  
  --border-subtle: #1e293b;
  --border-default: #334155;
  --border-focus: #60a5fa;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  
  --accent-primary: #3b82f6;
  --accent-primary-hover: #60a5fa;
  --accent-light: rgba(59, 130, 246, 0.15);
  
  --diff-easy-bg: rgba(16, 185, 129, 0.12);
  --diff-easy-text: #34d399;
  --diff-easy-border: rgba(16, 185, 129, 0.25);
  
  --diff-med-bg: rgba(245, 158, 11, 0.12);
  --diff-med-text: #fbbf24;
  --diff-med-border: rgba(245, 158, 11, 0.25);
  
  --diff-hard-bg: rgba(239, 68, 68, 0.12);
  --diff-hard-text: #f87171;
  --diff-hard-border: rgba(239, 68, 68, 0.25);

  --freq-bar-track: #1e293b;
  --freq-bar-fill: #60a5fa;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-modal: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

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

html, body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* --- App Container (Clean Centered Layout) --- */
.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* --- Header --- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 28px;
}

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

.brand-badge {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(234, 88, 12, 0.25);
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.brand-desc {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

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

.theme-toggle-btn, .header-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-card);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.theme-toggle-btn:hover, .header-icon-btn:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-default);
}

/* --- Hero Section: Company Selector & Timeframes --- */
.hero-section {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

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

.company-title-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.company-avatar-lg {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background-color: var(--accent-light);
  color: var(--accent-primary);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
}

.company-name-heading {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
  line-height: 1.1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.company-stats-text {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Company Switcher Trigger Button */
.switch-company-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  transition: all var(--transition);
}

.switch-company-btn:hover {
  background-color: var(--accent-light);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

/* Quick Popular Company Chips */
.quick-chips-row {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 20px;
  scrollbar-width: none;
}
.quick-chips-row::-webkit-scrollbar {
  display: none;
}

.chip-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
  margin-right: 4px;
  white-space: nowrap;
}

.company-chip {
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  transition: all var(--transition);
}

.company-chip:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-default);
}

.company-chip.active {
  background-color: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

/* Timeframe Segment Tabs */
.timeframe-segment {
  display: inline-flex;
  background-color: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  overflow-x: auto;
  max-width: 100%;
}

.tf-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  transition: all var(--transition);
}

.tf-btn:hover {
  color: var(--text-main);
}

.tf-btn.active {
  background-color: var(--bg-card);
  color: var(--accent-primary);
  box-shadow: var(--shadow-sm);
}

.tf-count {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background-color: rgba(0, 0, 0, 0.06);
  color: var(--text-muted);
}

[data-theme="dark"] .tf-count {
  background-color: rgba(255, 255, 255, 0.1);
}

.tf-btn.active .tf-count {
  background-color: var(--accent-light);
  color: var(--accent-primary);
}

/* --- Filter & Search Toolbar --- */
.toolbar-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

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

.search-icon-svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-subtle);
  pointer-events: none;
}

.problem-search-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border-radius: var(--radius-md);
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-main);
  transition: all var(--transition);
}

.problem-search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.filter-controls-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Difficulty Button Group */
.diff-pill-group {
  display: inline-flex;
  background-color: var(--bg-card);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.diff-pill {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--transition);
}

.diff-pill:hover {
  color: var(--text-main);
}

.diff-pill.active[data-diff="all"] {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}
.diff-pill.active[data-diff="Easy"] {
  background-color: var(--diff-easy-bg);
  color: var(--diff-easy-text);
}
.diff-pill.active[data-diff="Medium"] {
  background-color: var(--diff-med-bg);
  color: var(--diff-med-text);
}
.diff-pill.active[data-diff="Hard"] {
  background-color: var(--diff-hard-bg);
  color: var(--diff-hard-text);
}

.clean-select {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
}

.clean-select:focus {
  border-color: var(--accent-primary);
}

/* --- Stats & Counter Bar --- */
.stats-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.stats-breakdown {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
}

.stats-easy-badge { color: var(--diff-easy-text); font-weight: 600; }
.stats-med-badge { color: var(--diff-med-text); font-weight: 600; }
.stats-hard-badge { color: var(--diff-hard-text); font-weight: 600; }

/* --- Problem Cards / Rows --- */
.problems-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.problem-row {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: all var(--transition);
}

.problem-row:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-sm);
  background-color: var(--bg-card-hover);
}

.problem-row.is-solved {
  opacity: 0.65;
}

.problem-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1;
}

/* Solved Checkbox */
.solved-checkbox {
  appearance: none;
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border-default);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  position: relative;
}

.solved-checkbox:checked {
  background-color: #10b981;
  border-color: #10b981;
}

.solved-checkbox:checked::after {
  content: '';
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  position: absolute;
  top: 3px;
}

.problem-idx {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-subtle);
  min-width: 28px;
}

.problem-info-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.problem-title-link {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--transition);
}

.problem-title-link:hover {
  color: var(--accent-primary);
  text-decoration: underline;
}

.ext-link-icon {
  width: 12px;
  height: 12px;
  color: var(--text-subtle);
  opacity: 0.6;
}

/* Problem Tags */
.problem-tags-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.clean-tag {
  font-size: 11px;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 4px;
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.clean-tag:hover {
  background-color: var(--accent-light);
  color: var(--accent-primary);
}

/* Problem Right Meta */
.problem-right {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
}

.diff-badge-pill {
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  min-width: 70px;
}

.diff-badge-pill.Easy {
  background-color: var(--diff-easy-bg);
  color: var(--diff-easy-text);
  border: 1px solid var(--diff-easy-border);
}
.diff-badge-pill.Medium {
  background-color: var(--diff-med-bg);
  color: var(--diff-med-text);
  border: 1px solid var(--diff-med-border);
}
.diff-badge-pill.Hard {
  background-color: var(--diff-hard-bg);
  color: var(--diff-hard-text);
  border: 1px solid var(--diff-hard-border);
}

/* Sleek Frequency Meter */
.frequency-meter-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100px;
}

.frequency-label-val {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.frequency-bar-bg {
  width: 100%;
  height: 5px;
  border-radius: var(--radius-full);
  background-color: var(--freq-bar-track);
  overflow: hidden;
}

.frequency-bar-fill {
  height: 100%;
  background-color: var(--freq-bar-fill);
  border-radius: var(--radius-full);
}

.acceptance-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  min-width: 55px;
  text-align: right;
}

/* --- Pagination --- */
.pagination-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  padding: 16px 0;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 12px;
}

.page-btn-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pg-btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-card);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  transition: all var(--transition);
}

.pg-btn:hover:not(:disabled) {
  background-color: var(--bg-card-hover);
  border-color: var(--border-default);
}

.pg-btn.active {
  background-color: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

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

/* --- Empty State --- */
.clean-empty-state {
  text-align: center;
  padding: 60px 20px;
  background-color: var(--bg-card);
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-lg);
  margin-top: 12px;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-main);
}

.empty-state-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* --- Company Selector Modal --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.company-modal {
  width: 100%;
  max-width: 600px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  animation: modalScaleIn 150ms ease-out forwards;
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

.modal-close-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.modal-close-btn:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

.modal-search-box {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-search-input {
  width: 100%;
  padding: 10px 14px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-main);
}

.modal-search-input:focus {
  outline: none;
  background-color: var(--bg-card);
  border-color: var(--accent-primary);
}

.modal-company-grid {
  padding: 12px 20px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px;
}

.modal-company-item {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all var(--transition);
}

.modal-company-item:hover {
  background-color: var(--bg-subtle);
  color: var(--accent-primary);
}

.modal-company-item.active {
  background-color: var(--accent-light);
  color: var(--accent-primary);
  font-weight: 700;
}

.modal-company-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-subtle);
}

/* Toast */
.toast-msg {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  background-color: var(--text-main);
  color: var(--bg-card);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  animation: modalScaleIn 150ms ease-out forwards;
}

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
  .hero-main-row {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .toolbar-section {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-box-wrap {
    width: 100%;
  }

  .problem-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .problem-right {
    width: 100%;
    justify-content: space-between;
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
  }
}
