/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1;
  border: 1px solid transparent;
  transition: background var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast), box-shadow var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
}

.btn:disabled, .btn[disabled] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn--primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn--primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  color: #fff;
}

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}
.btn--secondary:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
}
.btn--ghost:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.btn--danger {
  background: var(--color-error);
  color: #fff;
  border-color: var(--color-error);
}
.btn--danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }

.btn--lg { padding: 0.875rem 1.75rem; font-size: 1.0625rem; border-radius: var(--radius-lg); }
.btn--sm { padding: 0.375rem 0.875rem; font-size: 0.8125rem; }

/* ── File card ───────────────────────────────────────────────────────────── */
.file-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  transition: box-shadow var(--transition-base), border-color var(--transition-base),
              transform var(--transition-base);
  color: inherit;
}

.file-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
  transform: translateY(-1px);
}

.file-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.file-card__name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.35;
  flex: 1;
}

.file-card__description {
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.file-card__meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-border);
}

.file-card__meta-item {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.6em;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge--pdf   { background: #fff7ed; color: #c2410c; }
.badge--audio { background: #f5f3ff; color: #6d28d9; }
.badge--image { background: #eff6ff; color: #1d4ed8; }
.badge--other { background: var(--color-bg); color: var(--color-text-muted); border: 1px solid var(--color-border); }

.badge--active   { background: #f0fdf4; color: #16a34a; }
.badge--cancelled { background: #fef2f2; color: #dc2626; }
.badge--past_due { background: #fffbeb; color: #d97706; }

/* ── Search ──────────────────────────────────────────────────────────────── */
.search-wrapper { position: relative; }

.search-input {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.625rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: 0.9375rem;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--shadow-sm);
}
.search-input::placeholder { color: var(--color-text-muted); }
.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgb(15 118 110 / 0.12);
}

.search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
  width: 17px;
  height: 17px;
}

/* ── Filter panel ────────────────────────────────────────────────────────── */
.filters-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.125rem;
  position: sticky;
  top: calc(64px + 1rem);
}

.filters-panel__title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  margin-bottom: 0.875rem;
}

.filter-group { margin-bottom: 1.25rem; }
.filter-group:last-child { margin-bottom: 0; }

.filter-group__label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.375rem;
  display: block;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--color-text-muted);
  transition: background var(--transition-fast), color var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.filter-option:hover { background: var(--color-bg); color: var(--color-text); }
.filter-option.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }

.label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
}

.input, .select, .textarea {
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  width: 100%;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgb(15 118 110 / 0.12);
}
.input::placeholder, .textarea::placeholder { color: var(--color-text-muted); }
.input--error { border-color: var(--color-error); }
.form-error { font-size: 0.8125rem; color: var(--color-error); margin-top: 0.25rem; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  border: 1px solid transparent;
  line-height: 1.5;
}

.alert--success { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.alert--error   { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.alert--info    { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.alert--warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }

/* ── Skeleton loading ────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,
    var(--color-border) 25%,
    var(--color-bg) 50%,
    var(--color-border) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 160px;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
}

.empty-state__icon {
  font-size: 2.5rem;
  margin-bottom: 0.875rem;
  opacity: 0.35;
}

.empty-state__title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.375rem;
}

.empty-state__desc { color: var(--color-text-muted); font-size: 0.9375rem; }

/* ── Results info ────────────────────────────────────────────────────────── */
.results-info {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

/* ── Load more ───────────────────────────────────────────────────────────── */
.load-more { text-align: center; margin-top: 2rem; }

/* ── Divider ─────────────────────────────────────────────────────────────── */
hr.divider { border: none; border-top: 1px solid var(--color-border); margin-block: 1.5rem; }

/* ── Card (generic) ──────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

/* ── Subscription status card ────────────────────────────────────────────── */
.status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ── Audio player ────────────────────────────────────────────────────────── */
.player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -4px 12px rgb(0 0 0 / 0.08);
  padding: 0.75rem 1.5rem;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.player__title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Table (admin) ───────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--color-border); }

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  font-size: 0.9375rem;
}

.table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--color-bg); }

/* ── Mobile / tablet improvements ───────────────────────────────────────── */
@media (max-width: 768px) {
  /* Touch targets: ensure all interactive elements are 44px+ */
  .btn { min-height: 44px; }
  .btn--sm { min-height: 36px; }
  .filter-option { min-height: 40px; }

  /* Filters panel: no sticky on mobile */
  .filters-panel {
    position: static;
    margin-bottom: 1rem;
  }

  /* Player: shrink padding, stack title */
  .player {
    padding: 0.625rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .player__title {
    width: 100%;
    order: -1;
  }

  /* Auth card: tighter padding on small screens */
  .modal {
    padding: 1.5rem;
    max-height: 95vh;
    margin: 0.5rem;
    border-radius: var(--radius-md);
  }
}

@media (max-width: 480px) {
  /* Table: tighter cells on very small screens */
  .table th,
  .table td {
    padding: 0.625rem 0.75rem;
  }

  /* File card: slightly less padding */
  .file-card { padding: 1rem; }

  /* Card: tighter padding */
  .card { padding: 1.25rem; }

  /* Buttons: full width in action areas */
  .hero__actions .btn { flex: 1 1 140px; }
}
