/**
 * WinGet System Update Monitor Stylesheet (updates.css)
 * Externalized for Strict Content Security Policy (CSP) compliance.
 * Mobile-First Responsive Redesign for Desktop, Tablet, and Mobile devices.
 */

:root {
  --bg-dark: #0b0f19;
  --card-bg: rgba(30, 41, 59, 0.7);
  --card-border: rgba(255, 255, 255, 0.1);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.25);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
}

/* Light Theme Variables (Solar Slate Glassmorphism) */
html[data-theme="light"] {
  --bg-dark: #f8fafc;
  --card-bg: rgba(255, 255, 255, 0.88);
  --card-border: rgba(148, 163, 184, 0.35);
  --text-main: #0f172a;
  --text-muted: #475569;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-dark);
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.1) 0px, transparent 50%);
  color: var(--text-main);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.75rem 1rem calc(2rem + env(safe-area-inset-bottom, 0px));
}

.container {
  width: 100%;
  max-width: 960px;
}

/* -------------------------------------------------------------
   Header Section
   ------------------------------------------------------------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--card-border);
  flex-wrap: wrap;
  gap: 1.25rem;
}

.title-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.title-icon {
  font-size: 2rem;
  line-height: 1;
}

.title-group h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-main);
}

.title-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.title-sub::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
}

/* -------------------------------------------------------------
   Buttons & Interactive Elements (Touch-Optimized)
   ------------------------------------------------------------- */
.btn-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.btn-group-start {
  justify-content: flex-start !important;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  padding: 0.55rem 1rem;
  min-height: 40px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

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

.btn-update {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.35);
  font-weight: 600;
}

.btn-update:hover {
  background: rgba(59, 130, 246, 0.3);
  border-color: rgba(59, 130, 246, 0.6);
  color: #93c5fd;
}

.btn-pin {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

.btn-pin:hover {
  background: rgba(245, 158, 11, 0.25);
  border-color: rgba(245, 158, 11, 0.5);
  color: #fde68a;
}

.btn-unpin {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.btn-unpin:hover {
  background: rgba(16, 185, 129, 0.25);
  border-color: rgba(16, 185, 129, 0.5);
  color: #6ee7b7;
}

.btn-reset {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-reset:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

.btn-npm-all {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.35);
  font-weight: 600;
}

.btn-npm-all:hover {
  background: rgba(16, 185, 129, 0.28);
  border-color: rgba(16, 185, 129, 0.6);
  color: #6ee7b7;
}

.btn-pip-all {
  background: rgba(234, 179, 8, 0.15);
  color: #facc15;
  border-color: rgba(234, 179, 8, 0.35);
  font-weight: 600;
}

.btn-pip-all:hover {
  background: rgba(234, 179, 8, 0.28);
  border-color: rgba(234, 179, 8, 0.6);
  color: #fde047;
}

/* -------------------------------------------------------------
   Modular Tab Filter Bar
   ------------------------------------------------------------- */
.tab-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
  padding: 0.3rem;
  background: rgba(30, 41, 59, 0.45);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow-x: auto;
  scrollbar-width: none;
}

.tab-bar::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  user-select: none;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--text-main);
  font-weight: 600;
  box-shadow: none;
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 0.45rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-size: 0.725rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', Consolas, monospace;
}

.tab-btn.active .tab-badge {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-main);
}

/* Category Filter Rules */
.filter-winget .pkg-row-npm,
.filter-winget .pkg-row-pip {
  display: none !important;
}

.filter-npm .pkg-row-winget,
.filter-npm .pkg-row-pip {
  display: none !important;
}

.filter-pip .pkg-row-winget,
.filter-pip .pkg-row-npm {
  display: none !important;
}

.is-hidden {
  display: none !important;
}

.tab-empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* -------------------------------------------------------------
   Section Cards
   ------------------------------------------------------------- */
.section-card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.35rem 1.5rem;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.45);
  margin-bottom: 1.75rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

/* -------------------------------------------------------------
   Desktop Tabular Layout (> 680px)
   ------------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

th {
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--card-border);
}

td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

.app-name {
  font-weight: 600;
  color: var(--text-main);
  word-break: break-word;
}

code {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.8rem;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.2rem 0.45rem;
  border-radius: 5px;
  word-break: break-all;
}

.badge-avail {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.775rem;
  font-weight: 600;
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  font-family: 'JetBrains Mono', Consolas, monospace;
}

.badge-pinned {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.775rem;
  font-weight: 600;
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-source {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', Consolas, monospace;
  margin-right: 0.45rem;
  vertical-align: middle;
}

.badge-winget {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-npm {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-pip {
  background: rgba(234, 179, 8, 0.15);
  color: #facc15;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.ver-text {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.825rem;
  color: #cbd5e1;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem !important;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.footer {
  margin-top: 1rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

/* Hidden elements on desktop */
.mobile-id,
.mobile-label {
  display: none;
}

/* -------------------------------------------------------------
   Mobile & Responsive Layout (<= 680px)
   Transforms tables into clean, touch-friendly interactive cards
   ------------------------------------------------------------- */
@media (max-width: 680px) {
  body {
    padding: 1.25rem 0.75rem calc(1.75rem + env(safe-area-inset-bottom, 0px));
  }

  .header {
    position: relative;
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
  }

  .title-group {
    justify-content: flex-start;
    padding-right: 48px;
  }

  .title-group h1 {
    font-size: 1.35rem;
  }

  .header .theme-cycler {
    position: absolute;
    top: 0;
    right: 0;
    margin: 0;
    padding: 0;
    width: 38px;
    height: 38px;
    min-height: 38px;
    border-radius: 9999px;
    justify-content: center;
    z-index: 10;
  }

  .header .theme-cycler .theme-cycler-label {
    display: none;
  }

  .header .btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    width: 100%;
  }

  .header .btn-group .btn-reset,
  .header .btn-group .btn-npm-all,
  .header .btn-group .btn-pip-all {
    grid-column: 1 / -1;
  }

  .header .btn {
    width: 100%;
    min-height: 44px;
    font-size: 0.825rem;
  }

  .tab-bar {
    width: 100%;
    margin-bottom: 1rem;
    padding: 0.25rem;
  }

  .tab-btn {
    padding: 0.5rem 0.85rem;
    font-size: 0.8rem;
    flex: 1 1 auto;
    justify-content: center;
  }

  .section-card {
    padding: 1rem 0.85rem;
    border-radius: 14px;
    margin-bottom: 1.25rem;
  }

  .section-title {
    font-size: 1rem;
  }

  /* Transform table into mobile cards */
  .table-container {
    overflow: visible;
  }

  table,
  tbody {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tbody {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
  }

  tr.pkg-row {
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 0.95rem;
    gap: 0.65rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  }

  td {
    display: block;
    padding: 0;
    border-bottom: none;
  }

  .name-col {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
  }

  .app-name {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.35;
  }

  .mobile-id {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .mobile-id code {
    font-size: 0.725rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
  }

  .id-col {
    display: none;
  }

  .ver-col,
  .avail-col {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0;
    border-top: 1px dashed rgba(255, 255, 255, 0.07);
  }

  .mobile-label {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
  }

  .ver-text {
    font-size: 0.85rem;
  }

  .action-col {
    display: block;
    padding-top: 0.35rem;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
  }

  .action-col .btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    width: 100%;
  }

  .action-col .btn {
    min-height: 44px;
    padding: 0.65rem 0.5rem;
    font-size: 0.85rem;
    width: 100%;
  }

  .empty-state {
    padding: 1.75rem 1rem !important;
    font-size: 0.9rem;
  }
}

/* -------------------------------------------------------------
   Solar Slate Light Theme Overrides (System Updates Monitor)
   ------------------------------------------------------------- */
html[data-theme="light"] body {
  background: #f8fafc;
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.06) 0px, transparent 50%);
}

html[data-theme="light"] .header {
  border-bottom-color: rgba(148, 163, 184, 0.35);
}

html[data-theme="light"] .title-group h1 {
  color: #0f172a;
}

html[data-theme="light"] .title-sub {
  color: #475569;
}

html[data-theme="light"] .btn {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

html[data-theme="light"] .btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

html[data-theme="light"] .btn-update {
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
  border-color: rgba(37, 99, 235, 0.35);
}

html[data-theme="light"] .btn-update:hover {
  background: rgba(37, 99, 235, 0.2);
  border-color: rgba(37, 99, 235, 0.6);
  color: #1e40af;
}

html[data-theme="light"] .btn-pin {
  background: rgba(217, 119, 6, 0.1);
  color: #b45309;
  border-color: rgba(217, 119, 6, 0.3);
}

html[data-theme="light"] .btn-pin:hover {
  background: rgba(217, 119, 6, 0.2);
  color: #92400e;
}

html[data-theme="light"] .btn-unpin {
  background: rgba(16, 185, 129, 0.1);
  color: #047857;
  border-color: rgba(16, 185, 129, 0.3);
}

html[data-theme="light"] .btn-unpin:hover {
  background: rgba(16, 185, 129, 0.2);
  color: #065f46;
}

html[data-theme="light"] .btn-reset {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.3);
}

html[data-theme="light"] .btn-reset:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #991b1b;
}

html[data-theme="light"] .btn-npm-all {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border-color: rgba(16, 185, 129, 0.35);
}

html[data-theme="light"] .btn-npm-all:hover {
  background: rgba(16, 185, 129, 0.25);
  color: #065f46;
}

html[data-theme="light"] .btn-pip-all {
  background: rgba(202, 138, 4, 0.12);
  color: #a16207;
  border-color: rgba(202, 138, 4, 0.35);
}

html[data-theme="light"] .btn-pip-all:hover {
  background: rgba(202, 138, 4, 0.25);
  color: #854d0e;
}

html[data-theme="light"] .tab-bar {
  background: rgba(226, 232, 240, 0.8);
  border-color: rgba(148, 163, 184, 0.35);
}

html[data-theme="light"] .tab-btn {
  color: #64748b;
}

html[data-theme="light"] .tab-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.6);
  color: #0f172a;
}

html[data-theme="light"] .tab-btn.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] .tab-badge {
  background: rgba(15, 23, 42, 0.08);
  color: #334155;
}

html[data-theme="light"] .section-card {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(148, 163, 184, 0.35);
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .section-title {
  color: #0f172a;
}

html[data-theme="light"] th {
  background: #f1f5f9;
  color: #475569;
  border-bottom-color: rgba(148, 163, 184, 0.35);
}

html[data-theme="light"] td {
  border-bottom-color: rgba(148, 163, 184, 0.2);
  color: #0f172a;
}

html[data-theme="light"] tr.pkg-row:hover {
  background: rgba(241, 245, 249, 0.7);
}

html[data-theme="light"] .pkg-id code {
  background: rgba(15, 23, 42, 0.05);
  color: #475569;
}

html[data-theme="light"] .pkg-new {
  color: #0284c7;
}

html[data-theme="light"] .pin-badge {
  background: rgba(217, 119, 6, 0.12);
  color: #b45309;
  border-color: rgba(217, 119, 6, 0.3);
}

html[data-theme="light"] .tab-empty-state {
  color: #475569;
}

html[data-theme="light"] .footer {
  color: #64748b;
}

@media (max-width: 640px) {
  html[data-theme="light"] tr.pkg-row {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(148, 163, 184, 0.35);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  }

  html[data-theme="light"] .mobile-id code {
    background: rgba(15, 23, 42, 0.05);
    color: #475569;
  }

  html[data-theme="light"] .ver-col,
  html[data-theme="light"] .avail-col,
  html[data-theme="light"] .action-col {
    border-top-color: rgba(148, 163, 184, 0.25);
  }
}

