/* ============================================================
   AI Фотобудка — Liquid Glass Theme
   Palette: violet #7C3AED → cyan #0891B2 on slate #0F172A
   ============================================================ */

:root {
  --bg-0: #07091a;
  --bg-1: #0f172a;
  --bg-2: #1e1b4b;

  --primary: #7c3aed;
  --primary-soft: rgba(124, 58, 237, 0.18);
  --secondary: #6366f1;
  --accent: #0891b2;
  --accent-soft: rgba(8, 145, 178, 0.18);

  --success: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #38bdf8;

  --fg: #f8fafc;
  --fg-muted: #94a3b8;
  --fg-dim: #64748b;

  --surface: rgba(255, 255, 255, 0.04);
  --surface-strong: rgba(255, 255, 255, 0.07);
  --surface-hover: rgba(255, 255, 255, 0.10);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;

  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.45);
  --glow-primary: 0 0 0 1px rgba(124, 58, 237, 0.35), 0 12px 40px rgba(124, 58, 237, 0.35);
  --glow-accent: 0 0 0 1px rgba(8, 145, 178, 0.35), 0 12px 40px rgba(8, 145, 178, 0.35);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 180ms;
  --dur: 280ms;
  --dur-slow: 480ms;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--fg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-feature-settings: 'cv11', 'ss01';
  letter-spacing: -0.005em;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(1100px 700px at 12% -10%, rgba(124, 58, 237, 0.30), transparent 60%),
    radial-gradient(900px 600px at 92% 10%, rgba(8, 145, 178, 0.25), transparent 60%),
    radial-gradient(800px 800px at 50% 110%, rgba(99, 102, 241, 0.18), transparent 65%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 60%, #050714 100%);
  background-attachment: fixed;
}

/* Typography */
h1, h2, h3, h4, h5 {
  letter-spacing: -0.02em;
  font-weight: 600;
  color: var(--fg);
}
h1 { font-size: clamp(2rem, 4vw, 3rem); font-weight: 700; }
h2 { font-size: clamp(1.6rem, 2.6vw, 2.1rem); }
h3 { font-size: 1.4rem; }
h4 { font-size: 1.15rem; }
p  { color: var(--fg-muted); line-height: 1.6; }
hr { border: 0; height: 1px; background: var(--border); margin: 2rem 0; }
a  { color: #c4b5fd; text-decoration: none; transition: color var(--dur-fast) var(--ease-out); }
a:hover { color: #ddd6fe; }

.text-grad {
  background: linear-gradient(135deg, #c4b5fd 0%, #67e8f9 60%, #a78bfa 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.text-muted-2 { color: var(--fg-muted) !important; }
.text-dim     { color: var(--fg-dim) !important; }

/* ===== Glass surfaces ===== */
.glass {
  background: var(--surface);
  backdrop-filter: blur(22px) saturate(1.2);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.glass-strong {
  background: var(--surface-strong);
  backdrop-filter: blur(28px) saturate(1.3);
  -webkit-backdrop-filter: blur(28px) saturate(1.3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.glass-panel {
  background: var(--surface);
  backdrop-filter: blur(22px) saturate(1.2);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* ===== Navbar ===== */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: rgba(7, 9, 26, 0.55);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.app-nav .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--fg);
  letter-spacing: -0.01em;
}
.app-nav .brand-mark {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: var(--glow-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.app-nav .brand-mark svg { width: 18px; height: 18px; color: white; }
.app-nav .nav-links {
  display: flex;
  gap: 0.35rem;
  margin-left: 1rem;
}
.app-nav .nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.9rem;
  border-radius: 12px;
  color: var(--fg-muted);
  font-weight: 500;
  font-size: 0.93rem;
  transition: all var(--dur) var(--ease-out);
}
.app-nav .nav-link svg { width: 16px; height: 16px; opacity: 0.85; }
.app-nav .nav-link:hover {
  color: var(--fg);
  background: var(--surface-hover);
}
.app-nav .nav-link.active {
  color: var(--fg);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.22), rgba(8, 145, 178, 0.18));
  border: 1px solid rgba(124, 58, 237, 0.35);
}
.app-nav .spacer { flex: 1; }

/* ===== Status pill (network) ===== */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  transition: all var(--dur) var(--ease-out);
}
.status-pill .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--fg-dim);
  box-shadow: 0 0 0 0 currentColor;
  animation: pulse 2s ease-in-out infinite;
}
.status-pill.online {
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.10);
}
.status-pill.online .dot { background: #34d399; color: rgba(52, 211, 153, 0.7); }
.status-pill.slow {
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.10);
}
.status-pill.slow .dot { background: #fbbf24; color: rgba(251, 191, 36, 0.7); }
.status-pill.offline {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.10);
}
.status-pill.offline .dot { background: #f87171; color: rgba(248, 113, 113, 0.7); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 currentColor; }
  50%      { box-shadow: 0 0 0 6px transparent; }
}

/* ===== Page shell ===== */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}
.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
}
.page-header h1 { margin: 0; }
.page-header .sub { color: var(--fg-muted); margin-top: 0.4rem; }
.eyebrow {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #a5b4fc;
  margin-bottom: 0.5rem;
}

/* ===== Buttons ===== */
.btn-x {
  --b-bg: var(--surface);
  --b-fg: var(--fg);
  --b-border: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.2rem;
  border-radius: 12px;
  font-weight: 500;
  font-size: 0.95rem;
  border: 1px solid var(--b-border);
  background: var(--b-bg);
  color: var(--b-fg);
  cursor: pointer;
  transition: transform var(--dur) var(--ease-out),
              background var(--dur) var(--ease-out),
              box-shadow var(--dur) var(--ease-out),
              border-color var(--dur) var(--ease-out);
  text-decoration: none;
  user-select: none;
}
.btn-x:hover { background: var(--surface-hover); transform: translateY(-1px); }
.btn-x:active { transform: translateY(0) scale(0.98); }
.btn-x:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.4); }
.btn-x svg { width: 16px; height: 16px; }

.btn-primary-x {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  border-color: transparent;
  color: white;
  box-shadow: var(--glow-primary);
}
.btn-primary-x:hover {
  background: linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%);
  box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.5), 0 16px 48px rgba(124, 58, 237, 0.5);
}

.btn-success-x { background: linear-gradient(135deg, #10b981, #059669); border-color: transparent; color: white; }
.btn-warn-x    { background: linear-gradient(135deg, #f59e0b, #d97706); border-color: transparent; color: white; }
.btn-danger-x  { background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.4); color: #fca5a5; }
.btn-danger-x:hover { background: rgba(239, 68, 68, 0.25); }

.btn-ghost { background: transparent; border-color: var(--border); color: var(--fg-muted); }
.btn-ghost:hover { color: var(--fg); background: var(--surface-hover); }

.btn-lg-x { padding: 0.9rem 1.6rem; font-size: 1.05rem; border-radius: 14px; }
.btn-sm-x { padding: 0.4rem 0.75rem; font-size: 0.83rem; border-radius: 9px; }

/* ===== Form fields ===== */
.field { margin-bottom: 1.1rem; }
.field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--fg-muted);
  margin-bottom: 0.5rem;
  letter-spacing: 0.01em;
}
.field-input,
.field-select,
.field-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--fg);
  font-family: inherit;
  font-size: 0.96rem;
  transition: all var(--dur) var(--ease-out);
  outline: none;
}
.field-input::placeholder { color: var(--fg-dim); }
.field-input:hover,
.field-select:hover,
.field-textarea:hover { border-color: var(--border-strong); }
.field-input:focus,
.field-select:focus,
.field-textarea:focus {
  border-color: rgba(124, 58, 237, 0.6);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.15);
  background: rgba(15, 23, 42, 0.85);
}
.field-textarea { resize: vertical; min-height: 90px; }
.field-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  background-size: 16px;
  padding-right: 2.5rem;
}
.field-file {
  width: 100%;
  padding: 0.6rem 0.9rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  color: var(--fg-muted);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.field-file::file-selector-button {
  padding: 0.4rem 0.8rem;
  margin-right: 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-hover);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.field-check {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--fg-muted);
  cursor: pointer;
  user-select: none;
}
.field-check input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ===== Cards ===== */
.card-x {
  background: var(--surface);
  backdrop-filter: blur(22px) saturate(1.2);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform var(--dur) var(--ease-out),
              border-color var(--dur) var(--ease-out),
              box-shadow var(--dur) var(--ease-out);
  position: relative;
}
.card-x::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(124,58,237,0.0) 0%, rgba(124,58,237,0.25) 50%, rgba(8,145,178,0.0) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0;
  transition: opacity var(--dur) var(--ease-out);
  pointer-events: none;
}
.card-x:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
}
.card-x:hover::before { opacity: 1; }
.card-x .media {
  aspect-ratio: 4 / 3;
  width: 100%;
  background: linear-gradient(135deg, rgba(124,58,237,0.15), rgba(8,145,178,0.15));
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-dim);
  font-size: 0.85rem;
}
.card-x .media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-x .body { padding: 1.1rem 1.2rem 1.2rem; }
.card-x .title { font-weight: 600; font-size: 1.05rem; margin-bottom: 0.5rem; }
.card-x .meta {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  margin-bottom: 0.8rem;
}

/* Chip / tag */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 500;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  color: var(--fg-muted);
}
.chip strong { color: var(--fg); font-weight: 600; }
.chip-primary { background: var(--primary-soft); border-color: rgba(124,58,237,0.35); color: #c4b5fd; }
.chip-accent  { background: var(--accent-soft);  border-color: rgba(8,145,178,0.35);  color: #67e8f9; }

/* Status pills (job statuses) */
.status {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.77rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid;
  text-transform: uppercase;
}
.status::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.status-queued     { color: #94a3b8; border-color: rgba(148,163,184,0.4); background: rgba(148,163,184,0.10); }
.status-processing { color: #67e8f9; border-color: rgba(8,145,178,0.4);   background: rgba(8,145,178,0.10); }
.status-retrying   { color: #fcd34d; border-color: rgba(245,158,11,0.4);  background: rgba(245,158,11,0.10); }
.status-failed     { color: #fca5a5; border-color: rgba(239,68,68,0.4);   background: rgba(239,68,68,0.10); }
.status-done       { color: #6ee7b7; border-color: rgba(16,185,129,0.4);  background: rgba(16,185,129,0.10); }
.status-processing::before,
.status-retrying::before { animation: pulse 1.4s ease-in-out infinite; }

/* ===== Data table ===== */
.table-wrap {
  background: var(--surface);
  backdrop-filter: blur(22px) saturate(1.2);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table-x {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.table-x thead th {
  text-align: left;
  padding: 0.85rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-dim);
  background: rgba(15, 23, 42, 0.4);
  border-bottom: 1px solid var(--border);
}
.table-x tbody td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  vertical-align: middle;
}
.table-x tbody tr { transition: background var(--dur-fast) var(--ease-out); }
.table-x tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.table-x tbody tr:last-child td { border-bottom: 0; }
.table-x .num { font-variant-numeric: tabular-nums; }
.table-x .empty {
  padding: 3rem 1rem; text-align: center; color: var(--fg-dim);
}

/* ===== Flash alerts ===== */
.flash {
  padding: 0.9rem 1.1rem;
  background: linear-gradient(135deg, rgba(124,58,237,0.15), rgba(8,145,178,0.10));
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 14px;
  color: #ddd6fe;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}
.flash p { color: inherit; margin: 0.15rem 0; }

/* ===== Spinner ===== */
.spinner-x {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.12);
  border-top-color: #c4b5fd;
  border-right-color: #67e8f9;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Utilities ===== */
.row-flex { display: flex; gap: 1rem; flex-wrap: wrap; }
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 1.75rem;
}
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

/* ===== Preset form grid ===== */
.preset-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.1rem 1.5rem;
}
.preset-form .field { margin: 0; }
.preset-form .field-full { grid-column: 1 / -1; }
.preset-form .ref-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}
.preset-form .ref-slot {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.85rem;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.preset-form .ref-slot .slot-label {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-muted);
  font-weight: 600;
}
.preset-form .ref-slot .thumb {
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-muted);
  font-size: 0.78rem;
}
.preset-form .ref-slot .thumb.empty { border-style: dashed; }
.preset-form .ref-slot .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preset-form .current-media {
  margin-top: 0.6rem;
  width: 140px; aspect-ratio: 1 / 1;
  border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  display: flex; align-items: center; justify-content: center;
}
.preset-form .current-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preset-form .current-media.contain img { object-fit: contain; max-width: 100%; max-height: 100%; }
@media (max-width: 720px) {
  .preset-form { grid-template-columns: 1fr; }
  .preset-form .ref-grid { grid-template-columns: 1fr; }
}

.fade-in { animation: fadeIn var(--dur-slow) var(--ease-out) both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
