/* Admin-area visual identity.
 *
 * The admin section reuses the same shell layout as the regular app but gives
 * itself a distinct accent so the operator instantly knows they're in the
 * administrative side. We use a red/danger accent for the brand mark + a
 * subtle red top border on the sidebar; everything else stays Code Lives-design.
 */

.mf-app-shell--admin .mf-app-shell__sidebar {
    border-right-color: var(--mf-border);
    box-shadow: inset 4px 0 0 var(--mf-danger);
}

[data-bs-theme="dark"] .mf-app-shell--admin .mf-app-shell__sidebar {
    box-shadow: inset 4px 0 0 var(--mf-danger);
}

.mf-sidebar__brand-mark--admin {
    background: linear-gradient(135deg, var(--mf-danger), #B91C1C);
}

/* Small "ADMIN" tag next to the brand wordmark + inline use in titles */
.mf-admin-tag {
    display: inline-block;
    padding: 1px 6px;
    margin-left: 4px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    background: var(--mf-danger);
    color: #FFFFFF;
    border-radius: var(--mf-radius-sm);
    vertical-align: middle;
}

.mf-admin-tag--inline {
    margin-left: 0;
    margin-right: var(--mf-space-2);
    font-size: 11px;
    padding: 3px 8px;
}

.mf-sidebar__license--admin {
    border-color: var(--mf-danger-subtle);
}

[data-bs-theme="dark"] .mf-sidebar__license--admin {
    border-color: var(--mf-danger);
}

/* ---------- Admin dashboard page ---------- */
.mf-admin-dash {
    max-width: 1200px;
}

.mf-admin-dash__header {
    margin-bottom: var(--mf-space-6);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--mf-space-4);
    flex-wrap: wrap;
}

.mf-admin-dash__header-actions {
    display: inline-flex;
    align-items: center;
    gap: var(--mf-space-2);
    flex-wrap: wrap;
}

.mf-admin-dash__title {
    font-size: 24px;
    font-weight: 600;
    color: var(--mf-text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--mf-space-3);
    flex-wrap: wrap;
}

.mf-admin-dash__subtitle {
    color: var(--mf-text-muted);
    font-size: 14px;
    margin: var(--mf-space-2) 0 0 0;
    max-width: 720px;
    line-height: 1.6;
}

.mf-admin-dash__placeholder {
    background: var(--mf-surface);
    border: 1px solid var(--mf-border);
    border-radius: var(--mf-radius-lg);
    padding: var(--mf-space-6);
}

.mf-admin-dash__back {
    margin-bottom: var(--mf-space-3);
    display: inline-flex;
    align-items: center;
    gap: var(--mf-space-1);
}

/* ---------- Flash alerts (used for theme save/delete confirmation) ---------- */
.mf-alert {
    display: flex;
    align-items: center;
    gap: var(--mf-space-3);
    padding: var(--mf-space-3) var(--mf-space-4);
    border-radius: var(--mf-radius);
    border: 1px solid var(--mf-border);
    background: var(--mf-surface);
    color: var(--mf-text);
    font-size: 14px;
    margin-bottom: var(--mf-space-5);
    animation: mf-alert-in 0.2s ease-out;
}

@keyframes mf-alert-in {
    from { transform: translateY(-6px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

.mf-alert--success {
    background: var(--mf-success-subtle);
    border-color: var(--mf-success);
    color: var(--mf-text);
}

.mf-alert--danger {
    background: var(--mf-danger-subtle);
    border-color: var(--mf-danger);
}

.mf-alert--success::before {
    content: '✓';
    flex: 0 0 24px;
    height: 24px;
    width: 24px;
    border-radius: var(--mf-radius-full);
    background: var(--mf-success);
    color: #FFFFFF;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

/* ---------- Themes grid ---------- */
.mf-theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--mf-space-5);
}

.mf-theme-grid > .mf-empty {
    grid-column: 1 / -1;
}

.mf-theme-card {
    background: var(--mf-surface);
    border: 1px solid var(--mf-border);
    border-radius: var(--mf-radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform var(--mf-transition), box-shadow var(--mf-transition), border-color var(--mf-transition);
    box-shadow: var(--mf-shadow-sm);
}

.mf-theme-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--mf-shadow-md);
    border-color: var(--mf-border-strong);
}

/* User-facing "Currently selected" hero on /site/themes — sits above the
   grid so the user sees their active theme at a glance and can preview it
   without scrolling around looking for the "Selected" badge. */
.mf-current-theme {
    display: flex;
    align-items: center;
    gap: var(--mf-space-4);
    padding: var(--mf-space-4) var(--mf-space-5);
    margin-bottom: var(--mf-space-5);
    background: var(--mf-surface);
    border: 1px solid var(--mf-accent, #4f46e5);
    border-left: 4px solid var(--mf-accent, #4f46e5);
    border-radius: var(--mf-radius-lg);
    box-shadow: var(--mf-shadow-sm);
    flex-wrap: wrap;
}
.mf-current-theme--empty {
    border-color: var(--mf-border-strong);
    border-left-color: var(--mf-warning, #f59e0b);
    background: var(--mf-surface-muted, var(--mf-surface));
}
.mf-current-theme__icon {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--mf-accent-soft, rgba(79, 70, 229, .12));
    color: var(--mf-accent, #4f46e5);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.mf-current-theme__icon svg {
    width: 20px;
    height: 20px;
}
.mf-current-theme--empty .mf-current-theme__icon {
    background: rgba(245, 158, 11, .12);
    color: var(--mf-warning, #f59e0b);
}
.mf-current-theme__body {
    flex: 1;
    min-width: 220px;
}
.mf-current-theme__label {
    font-size: 11px;
    color: var(--mf-text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 600;
    margin-bottom: 2px;
}
.mf-current-theme__name {
    font-size: 18px;
    font-weight: 600;
    color: var(--mf-text);
    display: flex;
    align-items: center;
    gap: var(--mf-space-2);
    flex-wrap: wrap;
}
.mf-current-theme__slug {
    font-family: var(--mf-font-mono, 'Consolas', monospace);
    font-size: 12px;
    color: var(--mf-text-muted);
    background: var(--mf-surface-muted, rgba(0, 0, 0, .04));
    padding: 2px 8px;
    border-radius: var(--mf-radius-sm);
    font-weight: 500;
}
.mf-current-theme__meta {
    display: flex;
    align-items: center;
    gap: var(--mf-space-2);
    margin-top: 6px;
    flex-wrap: wrap;
}
.mf-current-theme__hint {
    color: var(--mf-text-muted);
    font-size: 12px;
}

/* User-facing "Selected" state on /site/themes — gives the active theme a
   visible ring and a slight lift so the choice is immediately obvious. */
.mf-theme-card--selected {
    border-color: var(--mf-accent, #4f46e5);
    box-shadow: 0 0 0 2px var(--mf-accent, #4f46e5), var(--mf-shadow-md);
}
.mf-theme-card--selected:hover {
    border-color: var(--mf-accent, #4f46e5);
    box-shadow: 0 0 0 2px var(--mf-accent, #4f46e5), var(--mf-shadow-lg, var(--mf-shadow-md));
}

.mf-theme-card__select-form {
    display: inline-flex;
}

.mf-theme-card__preview {
    aspect-ratio: 16 / 10;
    overflow: hidden;
    position: relative;
    background: var(--mf-surface-2);
    border-bottom: 1px solid var(--mf-border);
}

.mf-theme-card__iframe {
    width: 100%;
    height: 100%;
    border: 0;
    pointer-events: none;
    /* Force light color-scheme inside preview iframes so dark-mode admin doesn't
       bleed into theme previews (themes are usually light-designed). */
    color-scheme: light;
    background: #FFFFFF;
}

/* Hover overlay shows "Open preview" */
.mf-theme-card__preview::after {
    content: 'Click "Preview" to enlarge';
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    transition: opacity var(--mf-transition);
    pointer-events: none;
}

.mf-theme-card:hover .mf-theme-card__preview::after {
    opacity: 1;
}

.mf-theme-card__body {
    padding: var(--mf-space-4);
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--mf-space-2);
}

.mf-theme-card__name {
    font-size: 15px;
    font-weight: 600;
    color: var(--mf-text);
    margin: 0;
}

.mf-theme-card__slug {
    font-size: 12px;
    color: var(--mf-text-muted);
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    background: var(--mf-surface-2);
    border-radius: var(--mf-radius-sm);
    align-self: flex-start;
}

.mf-theme-card__badges {
    display: flex;
    gap: var(--mf-space-1);
    flex-wrap: wrap;
}

.mf-theme-card__actions {
    display: flex;
    gap: var(--mf-space-2);
    padding: var(--mf-space-3) var(--mf-space-4);
    border-top: 1px solid var(--mf-border);
    background: var(--mf-bg);
}

.mf-theme-card__actions .mf-btn {
    flex: 1;
    justify-content: center;
}

/* Delete form should match button styling, not split layout */
.mf-theme-card__delete-form {
    display: contents;
}

/* ---------- Preview modal ---------- */
.mf-theme-preview-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2500;
    display: none;
    animation: mf-fade-in 0.18s ease-out;
}

[data-bs-theme="dark"] .mf-theme-preview-backdrop {
    background: rgba(0, 0, 0, 0.75);
}

.mf-theme-preview-modal {
    position: fixed;
    inset: 40px;
    z-index: 2510;
    background: var(--mf-bg);
    border: 1px solid var(--mf-border);
    border-radius: var(--mf-radius-xl);
    box-shadow: var(--mf-shadow-lg);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: mf-modal-in 0.2s ease-out;
}

.mf-theme-preview-backdrop--open { display: block; }
.mf-theme-preview-modal--open    { display: flex; }

@keyframes mf-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes mf-modal-in {
    from { transform: scale(0.96); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.mf-theme-preview-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--mf-space-3) var(--mf-space-5);
    border-bottom: 1px solid var(--mf-border);
    background: var(--mf-surface);
    flex-shrink: 0;
}

.mf-theme-preview-modal__title {
    font-size: 15px;
    font-weight: 600;
    color: var(--mf-text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--mf-space-2);
}

.mf-theme-preview-modal__body {
    flex: 1;
    overflow: hidden;
    background: #FFFFFF;
}

.mf-theme-preview-modal__iframe {
    width: 100%;
    height: 100%;
    border: 0;
    color-scheme: light;
}

@media (max-width: 575.98px) {
    .mf-theme-preview-modal { inset: 8px; }
}

/* ---------- Analyzer panel ---------- */
.mf-analyze-summary {
    margin-bottom: var(--mf-space-4);
    display: flex;
    gap: var(--mf-space-2);
    flex-wrap: wrap;
}

.mf-analyze-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mf-analyze-list li {
    display: flex;
    align-items: center;
    gap: var(--mf-space-3);
    padding: var(--mf-space-2) var(--mf-space-3);
    border-radius: var(--mf-radius);
    font-size: 13px;
    background: var(--mf-bg);
    border: 1px solid var(--mf-border);
}

.mf-analyze-list li strong {
    color: var(--mf-text);
    font-weight: 500;
    flex: 1;
}

.mf-analyze-icon {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    border-radius: var(--mf-radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    color: #FFFFFF;
}

.mf-analyze-pass .mf-analyze-icon { background: var(--mf-success); }
.mf-analyze-fail .mf-analyze-icon { background: var(--mf-danger); }

.mf-analyze-pass {
    border-color: var(--mf-success-subtle);
}

.mf-analyze-fail {
    border-color: var(--mf-danger-subtle);
    background: var(--mf-danger-subtle);
}

.mf-analyze-type {
    font-size: 10px;
    color: var(--mf-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--mf-surface-2);
    padding: 2px 6px;
    border-radius: var(--mf-radius-sm);
}

.mf-analyze-missing {
    color: var(--mf-danger);
    font-size: 12px;
    font-style: italic;
}

/* ---------- Theme form layout ---------- */
.mf-theme-form__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--mf-space-3);
    flex-wrap: wrap;
}

.mf-theme-form__footer-right {
    display: flex;
    gap: var(--mf-space-2);
    margin-left: auto;
}

/* Large monospaced textarea for HTML editing */
.mf-textarea--code {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.55;
    min-height: 460px;
    width: 100%;
    resize: vertical;
    tab-size: 4;
}

.mf-theme-form__char-count {
    font-size: 12px;
    color: var(--mf-text-muted);
    font-variant-numeric: tabular-nums;
}

/* ---------- Card title / subtitle (used by form cards) ---------- */
.mf-card__title {
    font-size: 16px;
    font-weight: 600;
    color: var(--mf-text);
    margin: 0;
}

.mf-card__subtitle {
    font-size: 13px;
    color: var(--mf-text-muted);
    margin: 2px 0 0 0;
}

@media (max-width: 575.98px) {
    .mf-theme-grid {
        grid-template-columns: 1fr;
    }
    .mf-admin-dash__header {
        flex-direction: column;
        align-items: stretch;
    }
}
