/* ═══════════════════════════════════════════════════════
   Banner Generator Admin — Design System
   Dark theme, glassmorphism, premium aesthetic
   ═══════════════════════════════════════════════════════ */

/* ─── CSS Variables ──────────────────────────────────── */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(20, 20, 30, 0.8);
    --bg-card-hover: rgba(30, 30, 45, 0.9);
    --bg-sidebar: rgba(12, 12, 20, 0.95);
    --bg-input: rgba(255, 255, 255, 0.05);
    --bg-input-focus: rgba(255, 255, 255, 0.08);

    --text-primary: #e8e8ed;
    --text-secondary: #8b8b9e;
    --text-muted: #5a5a70;

    --accent: #7c5cfc;
    --accent-hover: #9b7dff;
    --accent-glow: rgba(124, 92, 252, 0.3);

    --green: #34d399;
    --green-bg: rgba(52, 211, 153, 0.12);
    --red: #f87171;
    --red-bg: rgba(248, 113, 113, 0.12);
    --yellow: #fbbf24;
    --yellow-bg: rgba(251, 191, 36, 0.12);
    --blue: #60a5fa;
    --blue-bg: rgba(96, 165, 250, 0.12);

    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);

    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;

    --sidebar-width: 240px;
    --transition: 200ms ease;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Aliases used by inline template styles */
    --bg: var(--bg-primary);
    --surface: var(--bg-card);
    --text: var(--text-primary);
}

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

html {
    color-scheme: dark;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ─── Sidebar ────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 50;
    backdrop-filter: blur(20px);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent);
    font-weight: 700;
    font-size: 1.1rem;
}

.nav-links {
    list-style: none;
    padding: 12px 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

.nav-links a:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-links a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

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

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background var(--transition);
}

.dot.healthy {
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
}

.dot.degraded {
    background: var(--yellow);
    box-shadow: 0 0 8px var(--yellow);
}

.dot.error {
    background: var(--red);
    box-shadow: 0 0 8px var(--red);
}

/* ─── Content ────────────────────────────────────────── */
.content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: blur(12px);
}

.content-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.content-body {
    padding: 28px 32px;
}

/* ─── Cards ──────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(10px);
    overflow: hidden;
    transition: border-color var(--transition);
}

.card:hover {
    border-color: var(--border-hover);
}

.card-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.card-body {
    padding: 20px 22px;
}

/* ─── Stats Grid ─────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition);
    cursor: default;
}

.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue {
    background: var(--blue-bg);
    color: var(--blue);
}

.stat-icon.green {
    background: var(--green-bg);
    color: var(--green);
}

.stat-icon.red {
    background: var(--red-bg);
    color: var(--red);
}

.stat-icon.yellow {
    background: var(--yellow-bg);
    color: var(--yellow);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.stat-value-sm {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ─── Dashboard Grid ─────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

/* ─── Banner List ────────────────────────────────────── */
.banner-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.banner-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 4px;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.banner-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

.banner-item:last-child {
    border-bottom: none;
}

.banner-thumb img {
    width: 80px;
    height: 45px;
    object-fit: cover;
    border-radius: var(--radius-xs);
}

.thumb-placeholder {
    width: 80px;
    height: 45px;
    background: var(--bg-input);
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 1.2rem;
}

.banner-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.banner-theme {
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.banner-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ─── AI Status ──────────────────────────────────────── */
.model-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.model-row:last-child {
    border-bottom: none;
}

.model-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.refs-status {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.refs-status h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 600;
}

/* ─── Status Badges ──────────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.status-generating {
    background: var(--blue-bg);
    color: var(--blue);
}

.status-pending {
    background: var(--yellow-bg);
    color: var(--yellow);
}

.status-approved {
    background: var(--green-bg);
    color: var(--green);
}

.status-published {
    background: var(--green-bg);
    color: var(--green);
}

.status-rejected {
    background: var(--red-bg);
    color: var(--red);
}

.status-failed {
    background: var(--red-bg);
    color: var(--red);
}

/* ─── Buttons ────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

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

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

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

.btn-danger {
    color: var(--red);
    border-color: rgba(248, 113, 113, 0.3);
}

.btn-danger:hover {
    background: var(--red-bg);
}

.btn-lg {
    padding: 12px 28px;
    font-size: 0.95rem;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.78rem;
}

.link {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: color var(--transition);
}

.link:hover {
    color: var(--accent-hover);
}

/* ─── Forms ──────────────────────────────────────────── */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.label-hint {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.8rem;
}

textarea,
select,
input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    line-height: 1.5;
    transition: all var(--transition);
    resize: vertical;
}

textarea:focus,
select:focus,
input:focus {
    outline: none;
    background: var(--bg-input-focus);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea::placeholder {
    color: var(--text-muted);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b8b9e' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-actions {
    padding-top: 8px;
}

/* ─── Generate Page ──────────────────────────────────── */
.generate-form-wrapper {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    align-items: start;
}

.generate-info .info-block {
    margin-bottom: 20px;
}

.generate-info h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.generate-info ol,
.generate-info ul {
    padding-left: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

.gen-result {
    margin-top: 20px;
}

.success-result {
    padding: 8px 0;
}

.success-result h3 {
    color: var(--green);
    margin-bottom: 8px;
}

.error-result h3 {
    color: var(--red);
    margin-bottom: 8px;
}

/* ─── Gallery ────────────────────────────────────────── */
.gallery-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.filter-tag {
    padding: 6px 16px;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    transition: all var(--transition);
    cursor: pointer;
    text-transform: capitalize;
}

.filter-tag:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.filter-tag.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.gallery-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all var(--transition);
}

.gallery-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.gallery-img img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.img-placeholder {
    width: 100%;
    height: 180px;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.gallery-info {
    padding: 14px 16px;
}

.gallery-theme {
    font-weight: 600;
    font-size: 0.9rem;
    display: block;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.gallery-model,
.gallery-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.gallery-post-text {
    margin-top: 10px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ─── Pagination ─────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.page-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* ─── Prompts Page ───────────────────────────────────── */
.prompts-layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.template-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.template-item {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition);
}

.template-item:hover {
    border-color: var(--border-hover);
}

.template-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.template-body p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.template-body code {
    font-size: 0.78rem;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 1px 5px;
    border-radius: 4px;
}

.neg-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.neg-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.neg-item:hover {
    border-color: var(--border-hover);
}

.neg-text {
    flex: 1;
    font-size: 0.85rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.neg-meta {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ─── Settings Page ──────────────────────────────────── */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.settings-list {
    display: flex;
    flex-direction: column;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.setting-value {
    font-size: 0.85rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.setting-value code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.82rem;
}

/* ─── Badges ─────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-input);
    white-space: nowrap;
}

/* ─── Empty States ───────────────────────────────────── */
.empty-state {
    padding: 32px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.full-width {
    grid-column: 1 / -1;
}

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .generate-form-wrapper {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 300ms ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .content {
        margin-left: 0;
    }

    .content-body {
        padding: 20px 16px;
    }

    .content-header {
        padding: 16px;
    }

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

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

/* ─── Animations ─────────────────────────────────────── */
@media (prefers-reduced-motion: no-preference) {

    .stat-card,
    .gallery-card {
        transition: transform 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ─── Additional Button Variants ─────────────────────── */
.btn-success {
    color: var(--green);
    border-color: rgba(52, 211, 153, 0.3);
}

.btn-success:hover {
    background: var(--green-bg);
}

.btn-secondary {
    color: var(--text-muted);
    border-color: var(--border);
}

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

/* ─── Template CRUD ──────────────────────────────────── */
.template-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.prompt-highlight {
    display: block;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.8rem;
    line-height: 1.5;
    padding: 0.5rem;
    background: var(--bg-input);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
}

.form-group.compact {
    margin-bottom: 12px;
}

.form-group.compact label {
    font-size: 0.8rem;
    margin-bottom: 4px;
}

.create-form {
    margin-bottom: 1.5rem;
    animation: slideDown 0.25s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── Search Input ───────────────────────────────────── */
input[type="search"] {
    width: auto;
    padding: 6px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.85rem;
}

input[type="search"]:focus {
    outline: none;
    background: var(--bg-input-focus);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}