/* ============================================================
   Subscription Manager — sub.unun.io
   1:1 翻译自 sub.updn.pub (SubscriptionManager.tsx)
   ============================================================ */

/* --- Auth Gate (reuse admin pattern) --- */
.auth-gate-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 60vh; gap: 1rem;
  color: var(--color-text-secondary);
}

.sub-loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(0,0,0,0.1);
  border-top-color: #DD4C4F;
  border-radius: 50%;
  animation: sub-spin 1s linear infinite;
}
html[data-theme="dark"] .sub-loading-spinner {
  border-color: rgba(255,255,255,0.1);
  border-top-color: #DD4C4F;
}
@keyframes sub-spin { to { transform: rotate(360deg); } }

.auth-gate-apple-btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.65rem 1.5rem;
  background: #000; color: #fff;
  border: none; border-radius: 8px;
  font-size: 0.95rem; cursor: pointer;
  transition: opacity 0.2s;
}
.auth-gate-apple-btn:hover { opacity: 0.85; }
html[data-theme="dark"] .auth-gate-apple-btn {
  background: #fff; color: #000;
}
html[data-theme="dark"] .auth-gate-apple-btn svg path { fill: #000; }

/* --- Auth Gate Content (header avoidance) --- */
.auth-gate-content {
  padding: 6rem 1.5rem 3rem;
}

/* --- Container --- */
.sub-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* --- Page Title (watermark) --- */
.sub-page-title {
  font-size: 6rem; font-weight: 900; font-style: italic;
  color: rgba(0,0,0,0.04);
  user-select: none; pointer-events: none;
  line-height: 1; margin-bottom: -1.5rem;
  white-space: nowrap; overflow: hidden;
}
html[data-theme="dark"] .sub-page-title { color: rgba(255,255,255,0.03); }
@media (max-width: 768px) {
  .sub-page-title { font-size: 3rem; margin-bottom: -0.5rem; }
}

/* --- Card Grid --- */
.sub-card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem; padding: 0;
  user-select: none;
}
@media (max-width: 900px) { .sub-card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .sub-card-grid { grid-template-columns: 1fr; } }

/* --- Subscription Card --- */
.sub-card {
  position: relative;
  aspect-ratio: 1.6 / 1;
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: 1.25rem; border-radius: 24px;
  overflow: hidden; cursor: pointer;
  transition: all 0.3s ease;
  background: linear-gradient(145deg, #f8f9fa, #ffffff);
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
  --glow-x: 50%; --glow-y: 50%;
  --glow-intensity: 0; --glow-radius: 200px;
}
html[data-theme="dark"] .sub-card {
  background: linear-gradient(145deg, #1e222d, #14171e);
  border-color: rgba(255,255,255,0.05);
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}
.sub-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 0 0 1px rgba(221,76,79,0.2);
}
html[data-theme="dark"] .sub-card:hover {
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 0 1px rgba(221,76,79,0.3);
}

/* Card glow border (::after) */
.sub-card::after {
  content: '';
  position: absolute; inset: 0; padding: 6px;
  background: radial-gradient(
    var(--glow-radius) circle at var(--glow-x) var(--glow-y),
    rgba(221,76,79, calc(var(--glow-intensity) * 0.8)) 0%,
    rgba(221,76,79, calc(var(--glow-intensity) * 0.4)) 30%,
    transparent 60%
  );
  border-radius: inherit;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  pointer-events: none; z-index: 10;
}

/* Warning card (urgent) */
.sub-card--warning { border-color: rgba(221,76,79,0.3); }
html[data-theme="dark"] .sub-card--warning { border-color: rgba(221,76,79,0.4); }

.sub-card--paused { opacity: 0.5; border-style: dashed; }

/* Watermark */
.sub-card__watermark {
  position: absolute; bottom: -15px; right: -10px;
  font-size: 100px; font-weight: 900; font-style: italic;
  line-height: 1;
  color: rgba(0,0,0,0.04);
  pointer-events: none; user-select: none; z-index: 1;
}
html[data-theme="dark"] .sub-card__watermark { color: rgba(255,255,255,0.03); }

/* Header: icon + name + badge */
.sub-card__header {
  display: flex; align-items: center; gap: 0.5rem; z-index: 2;
}
.sub-card__icon { font-size: 1.75rem; }
.sub-card__logo {
  width: 2rem; height: 2rem; border-radius: 6px;
  object-fit: contain;
  background: rgba(255,255,255,0.8);
  transition: transform 0.2s;
}
.sub-card__logo:hover { transform: scale(1.1); }
html[data-theme="dark"] .sub-card__logo { background: rgba(255,255,255,0.1); }
.sub-card__name {
  font-size: 1rem; font-weight: 600;
  color: var(--color-text); flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sub-card__cycle-badge {
  font-size: 0.7rem; padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: rgba(0,0,0,0.08); color: #666;
}
html[data-theme="dark"] .sub-card__cycle-badge {
  background: rgba(255,255,255,0.1); color: #999;
}

/* Content area */
.sub-card__content { z-index: 2; position: relative; margin-top: 1.5rem; }
.sub-card__amount {
  display: inline-flex; align-items: baseline;
  transition: opacity 0.2s;
}
.sub-card__amount-yen { font-size: 1.25rem; color: #DD4C4F; }
.sub-card__amount-num { font-size: 3rem; font-weight: 700; color: #DD4C4F; line-height: 1; }
.sub-card__amount-unit { font-size: 1.125rem; color: #9ca3af; margin-left: 0.25rem; }

/* Summary card (first card) */
.sub-card__summary-yen { font-size: 1.875rem; color: #DD4C4F; margin-right: -0.25rem; }
.sub-card__summary-num { font-size: 100px; font-weight: 900; color: #DD4C4F; line-height: 1; }
.sub-card__summary-unit { font-size: 1.125rem; color: #9ca3af; margin-left: 0.25rem; }

/* Hover overlay for original price */
.sub-card__amount-hover {
  position: absolute; inset: 0;
  display: inline-flex; align-items: baseline;
  opacity: 0; transition: opacity 0.2s;
}
.sub-card:hover .sub-card__amount-hover { opacity: 1; }
.sub-card:hover .sub-card__amount--can-hover { opacity: 0; }

/* Footer: countdown + date + progress */
.sub-card__footer { z-index: 2; margin-top: auto; }
.sub-card__footer-info {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 0.5rem;
}
.sub-card__countdown { font-size: 0.7rem; color: #aaa; }
html[data-theme="dark"] .sub-card__countdown { color: #777; }
.sub-card__countdown.urgent { color: #DD4C4F; font-weight: 600; }
.sub-card__billing-date { font-size: 0.7rem; color: #aaa; }
html[data-theme="dark"] .sub-card__billing-date { color: #666; }

/* Progress bar */
.progress-bar {
  width: 100%; height: 6px; border-radius: 3px;
  background: rgba(0,0,0,0.08); overflow: hidden; z-index: 2;
}
html[data-theme="dark"] .progress-bar { background: rgba(255,255,255,0.08); }
.progress-bar__fill {
  height: 100%; border-radius: 3px; transition: width 0.3s ease;
}
.progress-bar__fill--full { background: linear-gradient(90deg, #1D4ED8, #3B82F6); }
.progress-bar__fill--normal { background: linear-gradient(90deg, #3B82F6, #60A5FA); }
.progress-bar__fill--warning { background: linear-gradient(90deg, #DD4C4F, #EF4444); }

/* --- FAB Button --- */
.sub-fab {
  position: fixed; bottom: 2rem; right: 2rem;
  width: 56px; height: 56px; border-radius: 50%;
  background: #DD4C4F; color: white;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(221,76,79,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 100;
}
.sub-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(221,76,79,0.5);
}

/* --- Modal --- */
.sub-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.sub-modal-content {
  background: white;
  border-radius: 1rem; padding: 1.5rem;
  width: 100%; max-width: 420px;
  max-height: 90vh; overflow-y: auto;
}
html[data-theme="dark"] .sub-modal-content { background: #1f2937; }

.sub-modal-title {
  font-size: 1.25rem; font-weight: 600;
  margin: 0 0 1.5rem 0; color: var(--color-text);
}

/* Form */
.sub-form-group { margin-bottom: 1rem; }
.sub-form-group label {
  display: block; font-size: 0.85rem; font-weight: 500;
  color: #666; margin-bottom: 0.5rem;
}
html[data-theme="dark"] .sub-form-group label { color: #9ca3af; }
.sub-form-group input,
.sub-form-group select {
  width: 100%; padding: 0.75rem;
  border: 1px solid #d1d5db; border-radius: 0.5rem;
  font-size: 1rem; background: white; color: var(--color-text);
  box-sizing: border-box;
}
html[data-theme="dark"] .sub-form-group input,
html[data-theme="dark"] .sub-form-group select {
  background: #374151; border-color: #4b5563;
}
.sub-form-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
}

/* Icon picker */
.sub-icon-picker { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.sub-icon-option {
  width: 40px; height: 40px;
  border: 2px solid transparent; border-radius: 0.5rem;
  background: rgba(0,0,0,0.05); font-size: 1.25rem;
  cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}
html[data-theme="dark"] .sub-icon-option { background: rgba(255,255,255,0.1); }
.sub-icon-option:hover { background: rgba(0,0,0,0.1); }
html[data-theme="dark"] .sub-icon-option:hover { background: rgba(255,255,255,0.2); }
.sub-icon-option.selected { border-color: #DD4C4F; background: rgba(221,76,79,0.1); }

/* Logo */
.sub-logo-preview {
  width: 48px; height: 48px; border-radius: 8px;
  object-fit: contain; background: rgba(0,0,0,0.03);
  margin-bottom: 0.5rem;
}
html[data-theme="dark"] .sub-logo-preview { background: rgba(255,255,255,0.05); }
.sub-logo-url-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.sub-logo-url-input {
  flex: 1; padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db; border-radius: 0.5rem;
  font-size: 0.85rem; background: white; color: var(--color-text);
}
html[data-theme="dark"] .sub-logo-url-input { background: #374151; border-color: #4b5563; }
.sub-btn-fetch-logo {
  padding: 0.5rem 0.75rem; background: #DD4C4F;
  color: white; border: none; border-radius: 0.5rem;
  font-size: 0.85rem; font-weight: 500; cursor: pointer;
  white-space: nowrap; transition: all 0.2s;
}
.sub-btn-fetch-logo:hover:not(:disabled) { background: #c43c3f; }
.sub-btn-fetch-logo:disabled { opacity: 0.5; cursor: not-allowed; }
.sub-btn-upload-local {
  display: inline-block; padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db; border-radius: 0.5rem;
  font-size: 0.85rem; cursor: pointer; transition: all 0.2s;
  color: var(--color-text);
}
html[data-theme="dark"] .sub-btn-upload-local { border-color: #4b5563; }
.sub-btn-upload-local:hover { background: rgba(0,0,0,0.05); }
html[data-theme="dark"] .sub-btn-upload-local:hover { background: rgba(255,255,255,0.1); }

/* Split options */
.sub-split-options { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.sub-radio-option {
  display: flex; align-items: center; gap: 0.5rem;
  cursor: pointer; font-size: 0.9rem; color: var(--color-text);
}
.sub-radio-option input[type="radio"] { width: auto; accent-color: #DD4C4F; }
.sub-split-select {
  padding: 0.5rem; border: 1px solid #d1d5db;
  border-radius: 0.5rem; font-size: 0.9rem;
  background: white; color: var(--color-text);
}
html[data-theme="dark"] .sub-split-select { background: #374151; border-color: #4b5563; }

/* Modal actions */
.sub-modal-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 1.5rem; padding-top: 1rem;
  border-top: 1px solid rgba(0,0,0,0.1);
}
html[data-theme="dark"] .sub-modal-actions { border-top-color: rgba(255,255,255,0.1); }
.sub-modal-actions-right { display: flex; gap: 0.75rem; align-items: center; }

.sub-btn-cancel, .sub-btn-save, .sub-btn-delete {
  padding: 0.75rem 1.25rem; border: none; border-radius: 0.5rem;
  font-size: 0.9rem; font-weight: 500; cursor: pointer;
  transition: all 0.2s;
}
.sub-btn-cancel { background: #f3f4f6; color: #374151; }
html[data-theme="dark"] .sub-btn-cancel { background: #374151; color: #d1d5db; }
.sub-btn-cancel:hover { background: #e5e7eb; }
html[data-theme="dark"] .sub-btn-cancel:hover { background: #4b5563; }
.sub-btn-save { background: #DD4C4F; color: white; }
.sub-btn-save:hover:not(:disabled) { background: #c43c3f; }
.sub-btn-save:disabled { opacity: 0.5; cursor: not-allowed; }
.sub-btn-delete { background: transparent; color: #dc2626; }
.sub-btn-delete:hover:not(:disabled) { background: #fef2f2; }
html[data-theme="dark"] .sub-btn-delete:hover:not(:disabled) { background: rgba(220,38,38,0.2); }
.sub-btn-delete:disabled { opacity: 0.5; cursor: not-allowed; }

.sub-btn-pause {
  padding: 0.5rem; border: 1px solid #d1d5db;
  border-radius: 0.5rem; background: white; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
html[data-theme="dark"] .sub-btn-pause { background: #374151; border-color: #4b5563; }
.sub-btn-pause:hover { background: #f3f4f6; }
html[data-theme="dark"] .sub-btn-pause:hover { background: #4b5563; }

/* Toast */
.sub-toast {
  position: fixed; top: 1rem; left: 50%;
  transform: translateX(-50%) translateY(-10px);
  padding: 0.75rem 1.5rem; border-radius: 0.5rem;
  color: white; font-size: 0.9rem; font-weight: 500;
  z-index: 9999; opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}
.sub-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.sub-toast--success { background: #22c55e; }
.sub-toast--error { background: #ef4444; }

/* Spotlight */
#sub-spotlight {
  position: fixed; width: 800px; height: 800px;
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle,
    rgba(221,76,79,0.15) 0%, rgba(221,76,79,0.08) 15%,
    rgba(221,76,79,0.04) 25%, rgba(221,76,79,0.02) 40%,
    rgba(221,76,79,0.01) 65%, transparent 70%
  );
  z-index: 200; opacity: 0;
  mix-blend-mode: screen;
  will-change: transform, opacity;
  transform: translate(-50%, -50%);
}

/* Responsive */
@media (max-width: 768px) {
  .auth-gate-content { padding: 5rem 1rem 2rem; }
  .sub-fab { bottom: 1.5rem; right: 1.5rem; width: 48px; height: 48px; }
}
