/* --------------------------------------------------------
   Knyle Share shared styles
   -------------------------------------------------------- */

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

:root {
  --color-bg: #ffffff;
  --color-surface: #fafafa;
  --color-border: #e5e5e5;
  --color-text: #171717;
  --color-muted: #737373;
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-danger: #dc2626;
  --color-danger-hover: #b91c1c;
  --color-success: #16a34a;
  --color-warning: #ca8a04;
  --color-badge-bg: #f4f4f5;
  --color-badge-text: #3f3f46;
  --color-badge-protected-bg: #dbeafe;
  --color-badge-protected-text: #1e40af;
  --color-badge-public-bg: #f0fdf4;
  --color-badge-public-text: #166534;
  --color-badge-disabled-bg: #fef2f2;
  --color-badge-disabled-text: #991b1b;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0a0a0a;
    --color-surface: #111111;
    --color-border: #262626;
    --color-text: #ededed;
    --color-muted: #a3a3a3;
    --color-accent: #3b82f6;
    --color-accent-hover: #60a5fa;
    --color-danger: #ef4444;
    --color-danger-hover: #f87171;
    --color-success: #22c55e;
    --color-warning: #eab308;
    --color-badge-bg: #27272a;
    --color-badge-text: #d4d4d8;
    --color-badge-protected-bg: #1e3a5f;
    --color-badge-protected-text: #93c5fd;
    --color-badge-public-bg: #14532d;
    --color-badge-public-text: #86efac;
    --color-badge-disabled-bg: #450a0a;
    --color-badge-disabled-text: #fca5a5;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

html {
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  color: var(--color-text);
  background-color: var(--color-bg);
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.3;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}

small,
.text-muted {
  color: var(--color-muted);
  font-size: 0.87rem;
}

code,
.mono {
  font-family: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.87em;
}

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

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.25rem;
  width: 100%;
}

main {
  flex: 1;
  padding: 2rem 0;
}

.page-centered {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.25rem;
}

.centered-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-md);
}

.centered-card.wide {
  max-width: 520px;
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.87rem;
  font-weight: 500;
  line-height: 1;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 120ms ease;
}

.btn:hover {
  text-decoration: none;
}

.btn.is-disabled,
.btn[disabled] {
  opacity: 0.5;
  pointer-events: none;
}

.btn-full {
  width: 100%;
}

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

.btn-primary:hover {
  background: var(--color-accent-hover);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

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

.btn-danger {
  background: var(--color-danger);
  color: #ffffff;
}

.btn-danger:hover {
  background: var(--color-danger-hover);
}

.page-title {
  margin-bottom: 1.5rem;
}

.page-title h1 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  background: var(--color-badge-bg);
  color: var(--color-badge-text);
  font-size: 0.8rem;
}

.card,
.detail-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
}

.bundle-list {
  list-style: none;
}

.bundle-list li + li {
  border-top: 1px solid var(--color-border);
}

.bundle-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 0;
  color: inherit;
}

.bundle-item:hover {
  text-decoration: none;
}

.bundle-item.is-disabled {
  opacity: 0.6;
}

.bundle-name {
  font-weight: 600;
  color: var(--color-text);
}

.bundle-slug {
  margin-top: 0.2rem;
  color: var(--color-muted);
  font-size: 0.87rem;
}

.bundle-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.45rem;
}

.bundle-stats {
  text-align: right;
  color: var(--color-muted);
  font-size: 0.87rem;
  flex-shrink: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--color-badge-bg);
  color: var(--color-badge-text);
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  font-size: 0.76rem;
  font-weight: 500;
}

.badge-protected {
  background: var(--color-badge-protected-bg);
  color: var(--color-badge-protected-text);
}

.badge-public {
  background: var(--color-badge-public-bg);
  color: var(--color-badge-public-text);
}

.badge-active {
  color: var(--color-success);
}

.badge-disabled {
  background: var(--color-badge-disabled-bg);
  color: var(--color-badge-disabled-text);
}

.breadcrumb {
  margin-bottom: 1rem;
  font-size: 0.87rem;
  color: var(--color-muted);
}

.bundle-url {
  margin-top: 0.4rem;
  color: var(--color-muted);
}

.flash-stack {
  position: sticky;
  top: 0;
  z-index: 30;
}

.flash {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
}

.flash-notice {
  background: rgba(22, 163, 74, 0.12);
  color: var(--color-text);
}

.flash-alert {
  background: rgba(220, 38, 38, 0.12);
  color: var(--color-text);
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

@media (max-width: 720px) {
  .bundle-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .bundle-stats {
    text-align: left;
  }
}
