/* ===== CSS Variables — Gipsy-inspired dark gold theme ===== */
:root {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-card: #111111;
  --bg-input: #1a1a1a;
  --bg-surface: #141414;
  --accent: #E8A524;
  --accent-hover: #D4920E;
  --accent-light: #F0B840;
  --accent-glow: rgba(232, 165, 36, 0.15);
  --accent-glow-strong: rgba(232, 165, 36, 0.25);
  --text-primary: #e8e8e8;
  --text-secondary: #999;
  --text-muted: #555;
  --border: #1f1f1f;
  --border-accent: rgba(232, 165, 36, 0.2);
  --danger: #e53e3e;
  --danger-hover: #c53030;
  --success: #38a169;
  --warning: #d69e2e;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --sidebar-width: 280px;
  --header-height: 56px;
  --transition: 0.25s ease;
  --font-main: 'Inter', 'Manrope', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --shadow-card: 0 2px 16px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px rgba(232, 165, 36, 0.08);
}

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

html, body {
  height: 100%;
  font-family: var(--font-main);
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a:hover {
  color: var(--accent-light);
}

::selection {
  background: var(--accent);
  color: #000;
}

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* ===== Layout ===== */
#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
  position: relative;
}

.header__logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--accent-light), var(--accent), #C87D0A);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header__nav {
  display: flex;
  gap: 6px;
  align-items: center;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.header__nav a {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  position: relative;
}

.header__nav a:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.04);
}

.header__nav a.active {
  color: var(--accent);
  background: var(--accent-glow);
}

.header__nav a.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 2px;
}

.header__left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header__nickname {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
  border: 1px solid transparent;
}

.header__nickname:hover {
  background: var(--accent-glow);
  border-color: var(--border-accent);
  color: var(--accent);
}

.header__lang-btn {
  background: none;
  border: none;
  padding: 4px 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  opacity: 0.75;
  transition: opacity var(--transition);
}

.header__lang-btn:hover {
  opacity: 1;
}

.header__lang-btn svg {
  display: block;
  border-radius: 2px;
}

.header__logout-btn {
  background: transparent;
  border: 1px solid rgba(229, 62, 62, 0.3);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-main);
}

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

/* ===== Main Content ===== */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar__header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar__list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.sidebar__item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
}

.sidebar__item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border);
}

.sidebar__item.active {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: var(--border-accent);
}

.sidebar__item-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity var(--transition), color var(--transition);
}

.sidebar__item:hover .sidebar__item-delete {
  opacity: 1;
}

.sidebar__item-delete:hover {
  color: var(--danger);
}

.sidebar__item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== Auth Page ===== */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 20px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(232, 165, 36, 0.04) 0%, transparent 60%),
    var(--bg-primary);
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  position: relative;
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

.auth-card__lang {
  position: absolute;
  top: 14px;
  right: 14px;
}

.auth-card__title {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 8px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 2px;
  background: linear-gradient(135deg, var(--accent-light), var(--accent), #C87D0A);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-card__subtitle {
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 28px;
  font-size: 13px;
  font-weight: 400;
}

/* ===== Forms ===== */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.form-input {
  width: 100%;
  padding: 11px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-main);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

select.form-input {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-input--textarea {
  resize: vertical;
  min-height: 80px;
  font-family: var(--font-main);
}

.image-preview {
  margin-top: 8px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 22px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-main);
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.3px;
}

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

.btn--primary {
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  color: #000;
  box-shadow: 0 2px 12px rgba(232, 165, 36, 0.2);
}

.btn--primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  box-shadow: 0 4px 20px rgba(232, 165, 36, 0.3);
  transform: translateY(-1px);
}

.btn--primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn--danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(229, 62, 62, 0.3);
}

.btn--danger:hover:not(:disabled) {
  background: rgba(229, 62, 62, 0.1);
  border-color: var(--danger);
}

.btn--secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn--secondary:hover:not(:disabled) {
  background: var(--bg-input);
  border-color: var(--border-accent);
  color: var(--accent);
}

.btn--full {
  width: 100%;
}

.btn--sm {
  padding: 6px 14px;
  font-size: 12px;
}

.btn--loading {
  opacity: 0.6;
  pointer-events: none;
}

/* ===== Chat Page ===== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 500;
}

.chat-input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.chat-input-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-input-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chat-input-row .form-input {
  flex: 1;
}

.chat-params {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.chat-params .form-group {
  margin-bottom: 0;
  min-width: 120px;
}

.chat-params select.form-input {
  padding: 6px 10px;
  font-size: 12px;
}

.chat-params label {
  font-size: 11px;
}

.chat-params .form-group--resolution {
  min-width: 200px;
}

/* ===== Generation Card ===== */
.gen-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color var(--transition);
  box-shadow: var(--shadow-card);
}

.gen-card:hover {
  border-color: rgba(255,255,255,0.06);
}

.gen-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.gen-card__mode {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent);
  letter-spacing: 1px;
}

.gen-card__status {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.gen-card__status--pending,
.gen-card__status--processing,
.gen-card__status--queued,
.gen-card__status--in-progress {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid var(--border-accent);
}

.gen-card__status--completed {
  background: rgba(56, 161, 105, 0.1);
  color: var(--success);
  border: 1px solid rgba(56, 161, 105, 0.2);
}

.gen-card__status--failed {
  background: rgba(229, 62, 62, 0.1);
  color: var(--danger);
  border: 1px solid rgba(229, 62, 62, 0.2);
}

.gen-card__prompt {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 12px;
  word-break: break-word;
  line-height: 1.5;
}

.gen-card__progress {
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 12px;
}

.gen-card__progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-hover), var(--accent), var(--accent-light));
  border-radius: 2px;
  transition: width 0.5s ease;
}

.gen-card__video {
  width: 100%;
  max-width: 640px;
  border-radius: var(--radius);
  background: #000;
  margin-bottom: 12px;
}

.gen-card__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== Page Container ===== */
.page {
  padding: 28px;
  overflow-y: auto;
  flex: 1;
}

.page__title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 24px;
  letter-spacing: 0.3px;
}

/* ===== Table ===== */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  white-space: nowrap;
  text-align: center;
  background: var(--bg-surface);
}

th:first-child {
  border-radius: var(--radius) 0 0 0;
}

th:last-child {
  border-radius: 0 var(--radius) 0 0;
}

td {
  text-align: center;
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover {
  background: rgba(255,255,255,0.02);
}

tbody tr:last-child td {
  border-bottom: none;
}

td:first-child,
th:first-child {
  text-align: center;
  width: 40px;
}

td:nth-child(2),
th:nth-child(2) {
  text-align: left;
}

td:last-child,
th:last-child {
  text-align: right;
  padding-right: 16px;
}

.actions-cell {
  display: flex;
  gap: 6px;
  white-space: nowrap;
  justify-content: flex-end;
}

.row--deleted td {
  opacity: 0.45;
}

.row--deleted td:last-child {
  opacity: 1;
}

/* ===== Cards Grid (Analytics) ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: border-color var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-card);
}

.stat-card:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

.stat-card__label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  font-weight: 600;
}

.stat-card__value {
  font-size: 30px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card__note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== Bar Chart ===== */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 28px;
}

.bar-chart__row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bar-chart__label {
  width: 120px;
  font-size: 13px;
  color: var(--text-secondary);
  text-align: right;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-chart__bar-wrap {
  flex: 1;
  height: 28px;
  background: var(--bg-input);
  border-radius: 6px;
  overflow: hidden;
}

.bar-chart__bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-hover), var(--accent), var(--accent-light));
  border-radius: 6px;
  transition: width 0.4s ease;
  display: flex;
  align-items: center;
  padding-left: 10px;
  font-size: 11px;
  font-weight: 700;
  color: #000;
  min-width: fit-content;
}

/* ===== Period Filter ===== */
.period-filter {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.period-filter .btn {
  padding: 6px 16px;
  font-size: 12px;
}

.period-filter .btn.active {
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  color: #000;
  border-color: transparent;
}

/* ===== Profile Page ===== */
.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 500px;
  box-shadow: var(--shadow-card);
}

.profile-card__row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.profile-card__row:last-child {
  border-bottom: none;
}

.profile-card__key {
  color: var(--text-secondary);
  font-size: 13px;
}

.profile-card__val {
  font-weight: 600;
  color: var(--text-primary);
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tabs__tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font-main);
}

.tabs__tab:hover {
  color: var(--text-primary);
}

.tabs__tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ===== Alerts / Errors ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
}

.alert--error {
  background: rgba(229, 62, 62, 0.08);
  color: var(--danger);
  border: 1px solid rgba(229, 62, 62, 0.2);
}

.alert--success {
  background: rgba(56, 161, 105, 0.08);
  color: var(--success);
  border: 1px solid rgba(56, 161, 105, 0.2);
}

/* ===== Inline Form ===== */
.inline-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.inline-form .form-group {
  margin-bottom: 0;
  min-width: 180px;
}

/* ===== Toggle / Switch ===== */
.toggle-group {
  display: inline-flex;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.toggle-group__btn {
  padding: 7px 24px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
  font-family: var(--font-main);
  flex: 1;
  white-space: nowrap;
  text-align: center;
}

.toggle-group__btn.active {
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  color: #000;
}

/* ===== History List ===== */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-card);
}

.history-item:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

.history-item__thumb {
  width: 60px;
  height: 40px;
  border-radius: 8px;
  background: var(--bg-input);
  object-fit: cover;
  flex-shrink: 0;
}

img.history-item__thumb {
  display: block;
}

.history-item__info {
  flex: 1;
  min-width: 0;
}

.history-item__title {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item__meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .main-layout {
    flex-direction: column;
  }

  .header {
    padding: 0 16px;
  }

  .header__nav {
    gap: 4px;
  }

  .header__nav a {
    font-size: 12px;
    padding: 4px 8px;
  }

  .cards-grid {
    grid-template-columns: 1fr 1fr;
  }

  .inline-form {
    flex-direction: column;
  }

  .bar-chart__label {
    width: 80px;
  }

  .page {
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .cards-grid {
    grid-template-columns: 1fr;
  }

  .auth-card {
    padding: 28px 20px;
  }

  .header__logo {
    font-size: 16px;
  }
}
