/* GPT AIGC interface refresh - loaded after the legacy stylesheet. */
:root {
  --bg-primary: #0b0d0c;
  --bg-secondary: #111412;
  --bg-card: #171a18;
  --bg-hover: #202521;
  --border: #2a302c;
  --border-light: #3a433d;
  --accent: #42d392;
  --accent-hover: #66e3aa;
  --accent-light: rgba(66, 211, 146, 0.12);
  --accent2: #f2b84b;
  --accent2-light: rgba(242, 184, 75, 0.12);
  --success: #42d392;
  --warning: #f2b84b;
  --danger: #ff6b78;
  --info: #60a5fa;
  --text-primary: #f4f7f5;
  --text-secondary: #b5beb8;
  --text-muted: #768079;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 10px 32px rgba(0, 0, 0, 0.24);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.34);
  --transition: 0.18s ease;
}

html { color-scheme: dark; }

body {
  background: var(--bg-primary);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button, input, select, textarea { appearance: none; }
button, a, input, select, textarea { letter-spacing: 0; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #343b36; border: 2px solid var(--bg-primary); border-radius: 8px; }

.sidebar {
  width: 224px;
  background: #101311;
  border-right-color: var(--border);
}

.sidebar-logo {
  min-height: 68px;
  padding: 16px 18px;
  border-bottom-color: var(--border);
}

.sidebar-logo .logo-icon,
.mobile-header-logo .logo-icon,
.mobile-header .logo-icon,
.auth-logo .logo-icon {
  background: var(--accent) !important;
  color: #062d1e;
  border-radius: 7px;
  box-shadow: none;
}

.sidebar-logo .logo-text {
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
}

.sidebar-logo .logo-text span { color: var(--accent); }
.sidebar-nav { padding: 14px 10px; }
.nav-section { margin-bottom: 22px; }
.nav-section-title {
  padding: 0 10px;
  margin-bottom: 7px;
  color: #667069;
  font-size: 10px;
  letter-spacing: 0;
}

.nav-item {
  min-height: 40px;
  padding: 9px 11px;
  border-radius: 6px;
  color: #9fa9a2;
  font-size: 13px;
}

.nav-item:hover { background: #1a1f1c; color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
  font-weight: 600;
}
.nav-item .nav-icon { color: currentColor; }
.sidebar-footer { border-top-color: var(--border); }
.user-info { border-radius: 6px; }
.user-avatar {
  background: #27302a;
  color: var(--accent);
  border: 1px solid #3a463e;
}

.main-content { margin-left: 224px; min-width: 0; }
.page-header {
  min-height: 92px;
  padding: 24px 28px 0;
  align-items: center;
}
.page-title { font-size: 22px; font-weight: 700; letter-spacing: 0; }
.page-title i[data-lucide] { color: var(--accent); margin-right: 5px; }
.page-subtitle { color: var(--text-muted); margin-top: 3px; }
.page-body { padding: 20px 28px 36px; min-width: 0; }

.card {
  background: var(--bg-card);
  border-color: var(--border);
  border-radius: 8px;
  box-shadow: none;
}
.card-title { color: var(--text-primary); font-size: 14px; }

.btn {
  min-height: 40px;
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 650;
  line-height: 1;
}
.btn-primary {
  background: var(--accent);
  color: #052a1c;
  box-shadow: none;
}
.btn-primary:hover {
  background: var(--accent-hover);
  color: #052a1c;
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(66, 211, 146, 0.16);
}
.btn-secondary {
  background: #202521;
  color: var(--text-primary);
  border-color: var(--border-light);
}
.btn-secondary:hover { background: #29302b; border-color: #4a554e; }
.btn-danger { background: rgba(255, 107, 120, 0.1); color: var(--danger); border-color: rgba(255, 107, 120, 0.3); }
.btn-lg { min-height: 46px; padding: 12px 22px; border-radius: 7px; }
.btn-sm { min-height: 32px; padding: 6px 11px; }

.form-group { margin-bottom: 16px; }
.form-label { color: #cbd2cd; margin-bottom: 7px; font-size: 12px; font-weight: 600; }
.form-control,
.form-control-static {
  min-height: 44px;
  padding: 10px 12px;
  background: #101311;
  color: var(--text-primary);
  border-color: #353d37;
  border-radius: 6px;
}
.form-control:hover { border-color: #4a554e; }
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(66, 211, 146, 0.1);
}
.form-control::placeholder { color: #69736c; }
select.form-control {
  background-image: linear-gradient(45deg, transparent 50%, #8d9891 50%), linear-gradient(135deg, #8d9891 50%, transparent 50%);
  background-position: calc(100% - 16px) 19px, calc(100% - 11px) 19px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
textarea.form-control { min-height: 152px; line-height: 1.65; }
.form-hint { color: var(--text-muted); }

.tool-btn {
  min-height: 36px;
  background: #171b18;
  color: var(--text-secondary);
  border-color: var(--border);
  border-radius: 6px;
}
.tool-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-light); }
.contact-panel { background: #171a18; border-color: var(--border-light); border-radius: 8px; }

.stats-grid { gap: 12px; margin-bottom: 18px; }
.stat-card,
.stat-card[style] {
  min-height: 96px;
  padding: 17px;
  gap: 13px;
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-top-width: 2px !important;
  border-radius: 8px;
}
.stat-card:nth-child(1) { border-top-color: var(--warning) !important; }
.stat-card:nth-child(2) { border-top-color: var(--info) !important; }
.stat-card:nth-child(3) { border-top-color: var(--success) !important; }
.stat-card:nth-child(4) { border-top-color: #ff7a66 !important; }
.stat-icon,
.stat-icon[style] {
  width: 42px;
  height: 42px;
  border-radius: 7px;
  background: #222823 !important;
  color: var(--text-secondary) !important;
}
.stat-value { font-size: 24px; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--text-muted); }

.badge { border-radius: 999px; }
.badge-success { color: var(--success); background: rgba(66, 211, 146, 0.1); }
.badge-running { color: var(--warning); background: rgba(242, 184, 75, 0.1); }
.badge-failed { color: var(--danger); background: rgba(255, 107, 120, 0.1); }
.progress-bar { background: var(--accent); }

.task-grid { gap: 12px; }
.task-card {
  background: #151815;
  border-color: var(--border);
  border-radius: 7px;
}
.task-card:hover { border-color: #475149; box-shadow: var(--shadow); transform: translateY(-2px); }
.task-card-thumb { background: #101311; }
.task-card-body { padding: 12px; }
.task-card-model { color: var(--accent); }

.upload-zone {
  min-height: 112px;
  max-height: none;
  padding: 18px;
  background: #101311;
  border: 1px dashed #445047;
  border-radius: 7px;
}
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--accent); background: rgba(66, 211, 146, 0.05); }
.upload-zone .upload-icon { color: var(--accent); }

.gen-layout {
  grid-template-columns: minmax(320px, 360px) minmax(0, 1fr) !important;
  gap: 16px;
  align-items: start;
}
.gen-panel {
  position: sticky !important;
  top: 16px !important;
  max-height: calc(100vh - 190px) !important;
  overflow-y: auto !important;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}
.gen-panel > .card { padding: 20px; }
.gen-panel .card > div[style*="position:sticky"] {
  background: var(--bg-card) !important;
  border-color: var(--border) !important;
  border-radius: 0 0 8px 8px !important;
}
.gen-result { min-width: 0; }
.gen-result > .card:first-child { min-height: 480px !important; }
.gen-result-img { background: #101311; border-color: var(--border); }
.gen-status { background: #121512; border-color: var(--border); }

#historyCards {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 12px !important;
}

.prompt-tag {
  background: rgba(66, 211, 146, 0.08);
  color: #9af0c8;
  border-color: rgba(66, 211, 146, 0.24);
}
.prompt-tag:hover { background: rgba(66, 211, 146, 0.14); border-color: rgba(66, 211, 146, 0.42); }
.prompt-template-card { border-radius: 7px; }
.prompt-template-card:hover { border-color: var(--accent); background: rgba(66, 211, 146, 0.05); }

.empty-state { color: var(--text-muted); }
.empty-state .empty-title { color: var(--text-secondary); }
.toast { border-radius: 7px; box-shadow: var(--shadow-lg); }
.toast-success { background: #102c20; border-color: #2f9b6d; color: #a5f3d0; }
.toast-error { background: #32171b; border-color: #b94d59; color: #fecdd3; }
.toast-info { background: #162439; border-color: #3f76bd; color: #bfdbfe; }

.auth-page { background: #0b0d0c; background-image: none; padding: 24px; }
.auth-card {
  max-width: 400px;
  padding: 34px;
  background: #151815;
  border-color: var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
}
.auth-logo .logo-icon { width: 52px; height: 52px; }
.auth-footer a { color: var(--accent); }

.mobile-header {
  height: 56px;
  background: rgba(16, 19, 17, 0.96);
  border-bottom-color: var(--border);
  backdrop-filter: blur(14px);
}
.bottom-nav {
  background: rgba(16, 19, 17, 0.97);
  border-top-color: var(--border);
  backdrop-filter: blur(14px);
}
.bottom-nav-inner { height: 62px; }
.bottom-nav-item { color: #77817a; font-size: 10px; gap: 4px; }
.bottom-nav-item.active { color: var(--accent); }
.bottom-nav-item .bnav-icon { display: grid; place-items: center; width: 24px; height: 24px; }

@media (max-width: 1180px) {
  #historyCards { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}

@media (max-width: 900px) {
  .gen-layout { grid-template-columns: 320px minmax(0, 1fr) !important; }
  .page-header { padding-left: 20px; padding-right: 20px; }
  .page-body { padding-left: 20px; padding-right: 20px; }
}

@media (max-width: 768px) {
  .main-content { margin-left: 0; padding-top: 56px; padding-bottom: 78px; }
  .page-header { min-height: auto; padding: 18px 16px 0; align-items: flex-start; gap: 12px; }
  .page-header-tools { flex-wrap: wrap; justify-content: flex-end; }
  .page-body { padding: 16px 16px 28px; }
  .page-title { font-size: 20px; }
  .card { padding: 16px; }
  .gen-layout { grid-template-columns: minmax(0, 1fr) !important; gap: 14px; }
  .gen-panel { position: static !important; max-height: none !important; overflow: visible !important; }
  .gen-panel > .card { padding: 16px; }
  .gen-panel .card > div[style*="position:sticky"] {
    margin-left: -16px !important;
    margin-right: -16px !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
  .gen-result > .card:first-child { min-height: 360px !important; }
  #historyCards { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .stat-card, .stat-card[style] { min-height: 86px; padding: 13px; }
  .stat-icon, .stat-icon[style] { width: 36px; height: 36px; }
  .stat-value { font-size: 21px; }
  textarea.form-control { min-height: 132px; }
  .auth-card { padding: 28px 20px; margin: 0; }
}

@media (max-width: 420px) {
  .page-header { flex-direction: column; }
  .page-header-tools { width: 100%; justify-content: flex-start; }
  .tool-btn { flex: 1; justify-content: center; }
  #historyCards { grid-template-columns: 1fr !important; }
  .stats-grid { grid-template-columns: 1fr 1fr !important; }
  .stat-card, .stat-card[style] { align-items: flex-start; flex-direction: column; gap: 8px; }
}


/* Dashboard refresh */
.dashboard-header .btn { flex-shrink: 0; }
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 28px;
  min-width: 0;
}
.dashboard-section { min-width: 0; }
.dashboard-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.dashboard-section-title { color: var(--text-primary); font-size: 14px; font-weight: 700; }
.dashboard-section-subtitle { color: var(--text-muted); font-size: 12px; margin-top: 3px; }
.text-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}
.text-link:hover { color: var(--accent-hover); }
.dashboard-gallery > .task-grid {
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
.dashboard-gallery > .empty-state {
  min-height: 320px;
  display: grid;
  place-content: center;
  padding: 40px 20px;
  border: 1px dashed var(--border);
  border-radius: 8px;
}
.dashboard-rail {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
}
.quick-actions { display: grid; gap: 4px; margin-top: 12px; }
.quick-action {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 9px 8px;
  border-radius: 7px;
  color: var(--text-secondary);
}
.quick-action:hover { background: var(--bg-hover); color: var(--text-primary); }
.quick-action > i { width: 16px; height: 16px; color: var(--text-muted); }
.quick-action-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 7px;
  background: var(--accent-light);
  color: var(--accent);
}
.quick-action-icon-warm { background: var(--accent2-light); color: var(--accent2); }
.quick-action-icon-blue { background: rgba(96, 165, 250, 0.12); color: var(--info); }
.quick-action-icon i { width: 17px; height: 17px; }
.quick-action strong { display: block; color: var(--text-primary); font-size: 12px; }
.quick-action small { display: block; color: var(--text-muted); font-size: 10px; margin-top: 2px; }
.dashboard-tip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  background: rgba(242, 184, 75, 0.07);
  border-left: 2px solid var(--warning);
  border-radius: 0 7px 7px 0;
}
.dashboard-tip > i { width: 17px; height: 17px; color: var(--warning); flex-shrink: 0; margin-top: 1px; }
.dashboard-tip strong { color: #f4d28f; font-size: 12px; }
.dashboard-tip p { color: var(--text-muted); font-size: 11px; line-height: 1.6; margin-top: 4px; }
.api-key-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  margin-bottom: 18px;
  background: rgba(242, 184, 75, 0.07);
  border: 1px solid rgba(242, 184, 75, 0.24);
  border-radius: 7px;
}
.api-key-banner > i { color: var(--warning) !important; }
.api-key-banner a:not(.btn) { color: var(--accent) !important; }

@media (max-width: 1100px) {
  .dashboard-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: minmax(0, 1fr) 250px; gap: 20px; }
}

@media (max-width: 820px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-rail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

@media (max-width: 768px) {
  .dashboard-header { flex-direction: row; align-items: center; }
  .dashboard-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 22px; }
  .dashboard-gallery > .task-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .dashboard-rail { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .dashboard-header .btn { width: 40px; min-width: 40px; padding: 0; }
  .dashboard-header .btn i { margin: 0; }
  .dashboard-header .btn { font-size: 0; }
}


/* Image workspace refinements */
.expiry-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 28px 16px;
  padding: 10px 13px;
  color: #e7c77e;
  background: rgba(242, 184, 75, 0.07);
  border: 1px solid rgba(242, 184, 75, 0.24);
  border-radius: 7px;
  font-size: 12px;
}
.expiry-notice i { color: var(--warning); flex-shrink: 0; }
.gen-action-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin: 0 -20px;
  padding: 12px 20px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
}
.gen-action-bar .btn { box-shadow: 0 -12px 26px rgba(11, 13, 12, 0.38); }
.toast > svg { width: 17px; height: 17px; flex-shrink: 0; }

@media (max-width: 768px) {
  .expiry-notice { margin: 0 16px 10px; }
  .gen-action-bar { margin: 0 -16px; padding: 12px 16px 14px; }
}


.mobile-logout-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent !important;
  border: 0;
  color: var(--text-muted) !important;
}
.mobile-logout-btn:hover { color: var(--text-primary) !important; }
.mobile-logout-btn svg { width: 18px; height: 18px; }


@media (max-width: 768px) {
  .gen-layout { padding-bottom: 74px; }
  .gen-action-bar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 70px;
    z-index: 190;
    margin: 0;
    padding: 8px;
    background: rgba(23, 26, 24, 0.96);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(14px);
  }
  .gen-action-bar .btn { min-height: 44px; box-shadow: none; }
}


/* Narrow-screen fixes for legacy administration and payment layouts */
.credit-package-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.credit-package-grid .btn { min-width: 0; }

@media (max-width: 480px) {
  .admin-container {
    width: 100%;
    max-width: 100%;
    padding: 16px !important;
    overflow-x: hidden;
  }
  .admin-header {
    width: 100%;
    flex-wrap: wrap;
    gap: 12px;
  }
  .filter-bar {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .admin-stats { grid-template-columns: 1fr !important; }
  .admin-tabs {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .admin-tabs::-webkit-scrollbar { display: none; }
  .chart-header { align-items: flex-start; flex-direction: column; gap: 10px; }
  .credit-package-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .credit-package-grid .btn {
    min-width: 0;
    white-space: normal;
    flex-direction: column;
    gap: 2px;
  }
}
