/* ============================================================
   Shared admin design system
   Cross-page, reusable styles for the admin panel pages.
   Page-specific rules live in each page's own css file.
   ============================================================ */

/* --- Page shell --- */
.admin-page {
    background: var(--tg-bg);
    min-height: 100vh;
}

/* Admin layout main content area */
.admin-main {
    background: var(--tg-bg);
    min-height: 100vh;
    color: var(--tg-text);
}

.mud-main-content.admin-main {
    padding-top: 0;
}

/* --- Hero header banner --- */
.admin-hero {
    border-radius: var(--tg-radius-2xl);
    color: #fff;
    box-shadow: 0 18px 40px -20px rgba(29, 78, 216, 0.55);
}

.admin-hero--purple,
.admin-hero--green,
.admin-hero--indigo {
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 45%, #7c3aed 100%);
}

/* Mud typography inside the hero inherits white text */
.admin-hero .mud-typography {
    color: #fff;
}

.hero-subtitle {
    opacity: 0.9;
}

/* --- Cards & boxes --- */
.admin-card {
    border: 1px solid var(--tg-border);
    border-radius: var(--tg-radius-xl);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.admin-card--full {
    height: 100%;
}

.bordered-box {
    border: 1px solid var(--tg-border);
    border-radius: var(--tg-radius-lg);
}

/* --- Typography helpers --- */
.card-title {
    font-weight: 700;
    color: var(--tg-text);
}

.card-subtitle {
    color: var(--tg-text-muted);
}

.text-muted {
    color: var(--tg-text-muted);
}

.text-faint {
    color: #98a2b3;
}

.text-dark {
    color: var(--tg-text);
}

.text-soft {
    color: #4a5568;
}

.text-blue {
    color: var(--tg-primary);
}

.text-white {
    color: #fff;
}

.fw-500 {
    font-weight: 500;
}

.fw-600 {
    font-weight: 600;
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.fw-700 {
    font-weight: 700;
}

.fw-800 {
    font-weight: 800;
}

.label-caps {
    color: var(--tg-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- Loading --- */
.loading-area {
    height: 300px;
}

/* Full-screen loading shown while auth state is being resolved
   (prerender + initial circuit connect) to avoid the login flash. */
.admin-auth-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--tg-bg);
}

/* --- Misc helpers --- */
.ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.min-w-0 {
    min-width: 0;
}

/* Inline stat (icon + number), used in tables and lists */
.inline-stat .mud-icon-root {
    margin-right: 4px;
}

.stat-icon-views {
    color: var(--tg-primary);
}

.stat-icon-likes {
    color: #e53e3e;
}

/* --- Gradient action button --- */
.btn-gradient {
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 55%, #7c3aed 100%) !important;
    color: #fff !important;
    font-weight: 600;
    box-shadow: 0 10px 20px -10px rgba(37, 99, 235, 0.6) !important;
}

/* --- Table card wrapper (admin list pages) --- */
.table-card {
    border-radius: var(--tg-radius-xl);
    overflow: hidden;
    border: 1px solid var(--tg-border);
}

/* --- Row action icons --- */
.icon-edit {
    color: #38a169 !important;
}

.icon-delete {
    color: #e53e3e !important;
}

.icon-view {
    color: var(--tg-primary) !important;
}

.icon-publish {
    color: #d69e2e !important;
}

/* --- Status chips (override MudBlazor filled defaults) --- */
.chip-success {
    background: #c6f6d5 !important;
    color: #22543d !important;
    font-weight: 600;
}

.chip-warning {
    background: #fef5e7 !important;
    color: #c05621 !important;
    font-weight: 600;
}

.chip-error {
    background: #fed7d7 !important;
    color: #c53030 !important;
    font-weight: 600;
}

.chip-neutral {
    background: #edf2f7 !important;
    color: #718096 !important;
    font-weight: 600;
}

/* Tinted chip — colour + soft background passed inline as --accent / --accent-soft */
.tint-chip {
    background: var(--accent-soft) !important;
    color: var(--accent) !important;
    font-weight: 600;
}

/* Category chip — solid colour passed inline as --chip */
.category-chip {
    background-color: var(--chip) !important;
    color: #fff !important;
    border-radius: 5px;
}

/* --- Dynamic accent helpers ---
   Pass the accent colour inline as a CSS variable, e.g.
   Style="--accent: #4299e1;"  (optionally --accent-soft for the tint) */
.accent-icon {
    color: var(--accent);
}

.accent-icon-box {
    background: var(--accent-soft, color-mix(in srgb, var(--accent) 13%, transparent));
    border-radius: 12px;
    padding: 12px;
}

.accent-icon-box--sm {
    padding: 10px;
    border-radius: 10px;
}

/* --- Stat / KPI card --- */
.stat-card {
    border: 1px solid var(--tg-border);
    border-radius: var(--tg-radius-xl);
    border-left: 4px solid var(--accent);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
    height: 100%;
}

/* --- Error boundary fallback ---
   Friendly UI shown when an unexpected error is caught while rendering a page. */
.error-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
    min-height: 50vh;
    padding: 40px 20px;
}

.error-fallback__icon {
    font-size: 56px;
    color: #dc2626;
}

.error-fallback__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--tg-text);
    margin: 0;
}

.error-fallback__text {
    color: var(--tg-text-muted);
    max-width: 460px;
    margin: 0;
}

.error-fallback__btn {
    margin-top: 8px;
    padding: 10px 22px;
    border: none;
    border-radius: var(--tg-radius-lg);
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 55%, #7c3aed 100%);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.error-fallback__btn:hover {
    opacity: 0.92;
}

.stat-value {
    font-weight: 700;
    color: var(--tg-text);
    margin: 4px 0;
}

/* --- Admin drawer (brand + navigation) --- */
.admin-drawer.mud-drawer {
    border-right: 1px solid var(--tg-border);
    background: var(--tg-bg-elev);
}

.admin-brand.mud-drawer-header {
    padding: 1rem 0.75rem;
    min-height: 4.25rem;
}

.admin-brand__link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--tg-text);
    width: 100%;
    overflow: hidden;
}

.admin-brand__mark {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: var(--tg-radius-lg);
    background: linear-gradient(to bottom right, #0a1f4a, #1d4ed8);
    box-shadow: 0 10px 15px -6px rgba(29, 78, 216, 0.45);
    overflow: hidden;
}

.admin-brand__mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: scale(2.2);
}

.admin-brand__text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
    white-space: nowrap;
}

.admin-brand__name {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--tg-text);
}

.admin-brand__sub {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--tg-text-muted);
}

.admin-drawer.mud-drawer--closed .admin-brand__text {
    opacity: 0;
    pointer-events: none;
}

.admin-nav .mud-nav-link {
    margin: 2px 8px;
    border-radius: var(--tg-radius-lg);
    font-weight: 600;
    color: var(--tg-text);
    transition: background-color 0.18s ease, color 0.18s ease;
}

.admin-nav .mud-nav-link:hover {
    background-color: var(--tg-bg-elev-2);
    color: var(--tg-primary);
}

.admin-nav .mud-nav-link.active {
    background-color: var(--tg-accent);
    color: var(--tg-primary);
    font-weight: 700;
}

.admin-nav .mud-nav-link.active::before {
    background-color: transparent;
}

.admin-nav .mud-nav-group .mud-nav-link {
    font-weight: 500;
}

.admin-nav .mud-nav-group > button {
    margin: 2px 8px;
    border-radius: var(--tg-radius-lg);
    font-weight: 600;
    color: var(--tg-text);
}

.admin-nav .mud-nav-group > button:hover {
    background-color: var(--tg-bg-elev-2);
}
