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

:root {
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 200ms ease;
  --max-width: 960px;
  --header-height: 64px;

  /* ─── Dark theme (default) ─────────────────────────── */
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-primary: #818cf8;
  --color-primary-hover: #6366f1;
  --color-text: #f1f5f9;
  --color-text-secondary: #94a3b8;
  --color-border: #334155;
  --color-error: #f87171;
  --color-success: #4ade80;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.25), 0 10px 15px rgba(0, 0, 0, 0.3);
}

/* ─── Light theme ──────────────────────────────────── */
.light {
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-border: #e2e8f0;
  --color-error: #ef4444;
  --color-success: #22c55e;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.07), 0 10px 15px rgba(0, 0, 0, 0.1);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
    'Helvetica Neue', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ─── Header ────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow);
}

.header__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header__title {
  font-size: 1.25rem;
  font-weight: 700;
  white-space: nowrap;
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background var(--transition),
    transform var(--transition);
  line-height: 1;
}

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

.btn--refresh {
  background: var(--color-primary);
  color: white;
}

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

.btn--refresh:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn--refresh svg {
  flex-shrink: 0;
}

.btn--theme {
  background: none;
  color: var(--color-text-secondary);
  padding: 8px;
  border-radius: 50%;
}

.btn--theme:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.theme-icon--sun {
  display: none;
}

.light .theme-icon--moon {
  display: none;
}

.light .theme-icon--sun {
  display: block;
}

/* ─── Main Layout ───────────────────────────────────── */
.main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* ─── Tab Navigation ────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--color-border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  flex-shrink: 0;
  padding: 12px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition:
    color var(--transition),
    border-color var(--transition);
  white-space: nowrap;
}

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

.tab-btn--active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* ─── Content Area ──────────────────────────────────── */
.content {
  animation: fadeIn 250ms ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Section Headers ───────────────────────────────── */
.section-header {
  margin-bottom: 16px;
}

.section-header__title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.section-header__description {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}

/* ─── File List ─────────────────────────────────────── */
.file-list {
  display: grid;
  gap: 8px;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition:
    box-shadow var(--transition),
    border-color var(--transition);
}

.file-item:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow);
}

.file-item__info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.file-item__icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.file-item__name {
  font-weight: 600;
  font-size: 0.9rem;
  word-break: break-all;
}

.file-item__meta {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.file-item__download {
  flex-shrink: 0;
  padding: 6px 12px;
  background: var(--color-primary);
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  transition: background var(--transition);
}

.file-item__download:hover {
  background: var(--color-primary-hover);
}

.file-item__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.file-item__download--open {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}

.file-item__download--open:hover {
  background: var(--color-primary);
  color: white;
}

/* ─── Empty State ───────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--color-text-secondary);
}

.empty-state__icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.empty-state__text {
  font-size: 0.95rem;
}

/* ─── Subdomain Grid ───────────────────────────────── */
.subdomains-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.subdomain-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--color-text);
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

.subdomain-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow);
}

.subdomain-card__icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  overflow: hidden;
}

.subdomain-card__icon img,
.subdomain-card__icon svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  color: var(--color-text-secondary);
}

.subdomain-card__name {
  font-weight: 600;
  font-size: 0.95rem;
  flex: 1;
}

.subdomain-card__url {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  word-break: break-all;
}

.subdomain-card__arrow {
  flex-shrink: 0;
  color: var(--color-text-secondary);
  font-size: 1.2rem;
}

/* ─── Toast ─────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  color: white;
  box-shadow: var(--shadow-lg);
  animation:
    slideIn 300ms ease,
    fadeOut 300ms ease 2.7s forwards;
  pointer-events: auto;
}

.toast--error {
  background: var(--color-error);
}

.toast--success {
  background: var(--color-success);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ─── Loading ───────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 48px 16px;
  color: var(--color-text-secondary);
}

.loading__spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ─── Responsive ────────────────────────────────────── */
@media (min-width: 640px) {
  .file-list {
    grid-template-columns: repeat(2, 1fr);
  }

  .subdomains-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .file-list {
    grid-template-columns: repeat(3, 1fr);
  }

  .subdomains-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .header__title {
    font-size: 1.4rem;
  }
}
