/* ============================================================
   EGKitsPublic – Customer Portal Layout Styles
   ============================================================ */

.portal-shell {
    min-height: 100vh;
    background: var(--mud-palette-background);
}

.portal-brand-title { line-height: 1; font-weight: 700; letter-spacing: -0.4px; }
.portal-brand-subtitle { line-height: 1; opacity: 0.85; font-weight: 500; }
.portal-main { background: var(--mud-palette-background); min-height: 100vh; }
.portal-content { direction: inherit; }

/* ===================== Portal design system ===================== */
.portal-hero {
    position: relative;
    border-radius: 22px;
    padding: 30px 34px;
    color: var(--egk-on-brand);
    background:
        radial-gradient(circle at 82% -30%, rgba(94, 234, 212, 0.38), transparent 46%),
        radial-gradient(circle at 8% 130%, rgba(37, 99, 235, 0.55), transparent 52%),
        linear-gradient(120deg, #172554 0%, #1e3a8a 42%, #2563eb 78%, #0f766e 140%);
    overflow: hidden;
    box-shadow: 0 26px 60px -30px rgba(37, 99, 235, 0.9);
}

/* Faint mesh grid for depth (kept extremely subtle so text stays crisp). */
.portal-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 46px 46px;
    -webkit-mask-image: radial-gradient(circle at 78% 10%, #000, transparent 70%);
    mask-image: radial-gradient(circle at 78% 10%, #000, transparent 70%);
    pointer-events: none;
}

.portal-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 92% -20%, rgba(255, 255, 255, 0.26), transparent 42%),
                radial-gradient(circle at 12% 120%, rgba(255, 255, 255, 0.10), transparent 40%);
    pointer-events: none;
}

.portal-hero > * { position: relative; z-index: 1; }
.portal-hero__title { font-weight: 800; letter-spacing: -0.5px; }
.portal-hero__subtitle { opacity: 0.9; font-weight: 400; }

.portal-hero .mud-button-filled {
    background: var(--egk-cta-on-gradient-hover-bg) !important;
    color: var(--egk-on-brand) !important;
    backdrop-filter: blur(4px);
    border: 1px solid var(--egk-cta-on-gradient-border) !important;
}

.portal-hero .mud-button-filled:hover {
    background: rgba(255, 255, 255, 0.26) !important;
}

.portal-card {
    position: relative;
    border-radius: 18px !important;
    border: 1px solid var(--mud-palette-lines-default) !important;
    background: var(--mud-palette-surface);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 30px -26px rgba(15, 23, 42, 0.5);
    transition: transform 0.2s cubic-bezier(.2, .7, .3, 1), box-shadow 0.2s ease, border-color 0.2s ease;
}

.portal-card--hover { cursor: default; }

.portal-card--hover:hover {
    transform: translateY(-4px);
    box-shadow:
        0 24px 55px -30px rgba(15, 23, 42, 0.55),
        0 0 0 1px rgba(var(--mud-palette-primary-rgb), 0.10);
    border-color: rgba(var(--mud-palette-primary-rgb), 0.42) !important;
}

/* Accent cards: a gradient hairline seam at the top instead of a flat line. */
.portal-card--accent {
    border-top-color: transparent !important;
    overflow: hidden;
}

.portal-card--accent::before {
    content: "";
    position: absolute;
    inset-inline: 0;
    inset-block-start: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--mud-palette-primary), var(--mud-palette-secondary));
    z-index: 1;
}

.portal-plan-card {
    position: relative;
    border-radius: 18px !important;
    color: var(--egk-on-brand);
    background:
        radial-gradient(circle at 88% -10%, rgba(94, 234, 212, 0.32), transparent 48%),
        linear-gradient(135deg, #172554 0%, #1e3a8a 46%, #2563eb 82%, #1d4ed8 120%);
    box-shadow: 0 24px 50px -28px rgba(37, 99, 235, 0.95);
    overflow: hidden;
}

/* Soft mesh + corner sheen so the plan card reads as the premium focal element. */
.portal-plan-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 40px 40px;
    -webkit-mask-image: radial-gradient(circle at 85% 8%, #000, transparent 68%);
    mask-image: radial-gradient(circle at 85% 8%, #000, transparent 68%);
    pointer-events: none;
}

.portal-plan-card > * { position: relative; z-index: 1; }
.portal-plan-card .mud-typography { color: var(--egk-on-brand) !important; }
.portal-plan-card .mud-icon-root { color: var(--egk-on-brand-muted) !important; }

.portal-plan-card .mud-button-filled {
    background: var(--egk-cta-surface) !important;
    color: var(--egk-cta-on-surface-label) !important;
    font-weight: 700;
}

.portal-plan-card .mud-button-outlined {
    border-color: var(--egk-cta-on-gradient-border) !important;
    color: var(--egk-on-brand) !important;
}

.portal-stat__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }

.portal-stat__label {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--mud-palette-text-secondary);
}

.portal-stat__value { font-size: 1.85rem; font-weight: 800; line-height: 1.15; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.portal-stat__suffix { font-size: 0.92rem; font-weight: 500; color: var(--egk-on-brand-muted); }

.portal-badge {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    transition: transform 0.2s cubic-bezier(.2, .7, .3, 1);
}

.portal-badge .mud-icon-root { font-size: 1.4rem; }
.portal-badge--primary {
    background: linear-gradient(135deg, rgba(var(--mud-palette-primary-rgb), 0.18), rgba(var(--mud-palette-primary-rgb), 0.08));
    color: var(--mud-palette-primary);
    box-shadow: inset 0 0 0 1px rgba(var(--mud-palette-primary-rgb), 0.12);
}
.portal-badge--secondary {
    background: linear-gradient(135deg, rgba(var(--mud-palette-secondary-rgb), 0.18), rgba(var(--mud-palette-secondary-rgb), 0.08));
    color: var(--mud-palette-secondary);
    box-shadow: inset 0 0 0 1px rgba(var(--mud-palette-secondary-rgb), 0.12);
}
.portal-badge--info {
    background: linear-gradient(135deg, rgba(var(--mud-palette-info-rgb), 0.18), rgba(var(--mud-palette-info-rgb), 0.08));
    color: var(--mud-palette-info);
    box-shadow: inset 0 0 0 1px rgba(var(--mud-palette-info-rgb), 0.12);
}
.portal-badge--success {
    background: linear-gradient(135deg, rgba(var(--mud-palette-success-rgb), 0.18), rgba(var(--mud-palette-success-rgb), 0.08));
    color: var(--mud-palette-success);
    box-shadow: inset 0 0 0 1px rgba(var(--mud-palette-success-rgb), 0.12);
}
.portal-badge--warning {
    background: linear-gradient(135deg, rgba(var(--mud-palette-warning-rgb), 0.22), rgba(var(--mud-palette-warning-rgb), 0.10));
    color: var(--mud-palette-warning);
    box-shadow: inset 0 0 0 1px rgba(var(--mud-palette-warning-rgb), 0.14);
}

.portal-section-title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
    color: var(--mud-palette-text-primary);
    -webkit-text-fill-color: currentColor;
}

.portal-section-title::before {
    content: "";
    width: 4px;
    height: 18px;
    border-radius: 4px;
    background: linear-gradient(180deg, var(--mud-palette-primary), var(--mud-palette-secondary));
    display: inline-block;
}

.portal-progress { height: 8px !important; border-radius: 999px !important; overflow: hidden; }

/* Gradient fill for the linear progress bars (primary → secondary sheen). */
.portal-card .portal-progress .mud-progress-linear-bar,
.portal-progress.mud-progress-linear .mud-progress-linear-bar {
    background-image: linear-gradient(90deg, var(--mud-palette-primary), var(--mud-palette-secondary)) !important;
}

.portal-count-pill {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 11px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(var(--mud-palette-primary-rgb), 0.16), rgba(var(--mud-palette-secondary-rgb), 0.12));
    color: var(--mud-palette-primary);
    box-shadow: inset 0 0 0 1px rgba(var(--mud-palette-primary-rgb), 0.14);
}

/* Premium page banner: a soft glass surface with a gradient wash and a
   gradient-filled icon tile. Shared by every secondary portal page, so it lifts
   Billing, Users, Usage, Security, Account, Settings, and Tickets in one place. */
.portal-page-header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 26px;
    padding: 20px 24px;
    border-radius: 18px;
    overflow: hidden;
    background:
        linear-gradient(120deg, rgba(var(--mud-palette-primary-rgb), 0.09), rgba(var(--mud-palette-secondary-rgb), 0.06) 70%, transparent),
        var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 16px 40px -32px rgba(15, 23, 42, 0.55);
}

.portal-page-header::before {
    content: "";
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--mud-palette-primary), var(--mud-palette-secondary));
}

.portal-page-header::after {
    content: "";
    position: absolute;
    inset-block-start: -60%;
    inset-inline-end: -4%;
    width: 220px;
    height: 220px;
    background: radial-gradient(circle, rgba(var(--mud-palette-primary-rgb), 0.14), transparent 62%);
    pointer-events: none;
}

.portal-page-header > * { position: relative; z-index: 1; }

.portal-page-header__icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    background: linear-gradient(135deg, var(--mud-palette-primary), color-mix(in srgb, var(--mud-palette-secondary) 82%, var(--mud-palette-primary))) !important;
    color: #fff !important;
    box-shadow: 0 12px 26px -14px rgba(var(--mud-palette-primary-rgb), 0.9);
}

.portal-page-header__icon .mud-icon-root { font-size: 1.7rem; color: #fff !important; }

.portal-page-header__title {
    font-weight: 800;
    letter-spacing: -0.4px;
    line-height: 1.15;
    color: var(--mud-palette-text-primary);
    -webkit-text-fill-color: currentColor;
}

/* Action cluster pinned to the trailing edge of the page banner. */
.portal-page-header__actions {
    margin-inline-start: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

@media (max-width: 640px) {
    .portal-page-header {
        flex-wrap: wrap;
        padding: 18px 18px;
    }
    .portal-page-header__actions { margin-inline-start: 0; width: 100%; }
}

.portal-drawer .mud-navmenu .mud-nav-link {
    border-radius: 10px;
    margin: 2px 8px;
    padding-top: 9px;
    padding-bottom: 9px;
    transition: background 0.15s ease, color 0.15s ease;
}

.portal-drawer .mud-navmenu .mud-nav-link:hover {
    background: rgba(var(--mud-palette-primary-rgb), 0.08);
}

.portal-drawer .mud-navmenu .mud-nav-link .mud-nav-link-icon {
    min-width: 38px;
}

.portal-drawer .mud-navmenu > .mud-typography {
    letter-spacing: 0.08em;
    font-weight: 700;
    opacity: 0.7;
}

.portal-card .mud-table-root .mud-table-head .mud-table-cell {
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    font-weight: 700;
    color: var(--mud-palette-text-secondary);
    background: color-mix(in srgb, var(--mud-palette-primary) 5%, var(--mud-palette-surface));
    border-bottom: 2px solid rgba(var(--mud-palette-primary-rgb), 0.18) !important;
}

/* Timeline (Usage → Recent activity): crisper dots with a soft halo and a
   softer connector line. */
.portal-main .mud-timeline .mud-timeline-item-dot .mud-timeline-item-dot-inner {
    box-shadow: 0 0 0 4px rgba(var(--mud-palette-primary-rgb), 0.10);
}
.portal-main .mud-timeline .mud-timeline-item-divider .mud-timeline-item-line,
.portal-main .mud-timeline .mud-timeline-line {
    background: rgba(var(--mud-palette-primary-rgb), 0.16) !important;
}

.portal-card .mud-table-root .mud-table-body .mud-table-row {
    transition: background-color 0.15s ease;
}

.portal-card .mud-table-root .mud-table-body .mud-table-row:hover {
    background: rgba(var(--mud-palette-primary-rgb), 0.055);
}

@keyframes portalFadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

.portal-hero,
.portal-plan-card,
.portal-card { animation: portalFadeUp 0.4s ease both; }

@media (prefers-reduced-motion: reduce) {
    .portal-hero,
    .portal-plan-card,
    .portal-card { animation: none; }
    .portal-card--hover:hover { transform: none; }
}

.portal-appbar {
    background: linear-gradient(90deg, #1e3a8a 0%, #2563eb 62%, #0f766e 140%) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 30px -20px rgba(15, 23, 42, 0.9);
}

.portal-card .mud-input.mud-input-outlined .mud-input-outlined-border { border-radius: 10px; }
.portal-card .mud-input-control .mud-input-slot { border-radius: 10px; }

.portal-quick {
    position: relative;
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 16px 18px;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

.portal-quick:hover { text-decoration: none; }
.portal-quick__text { display: flex; flex-direction: column; line-height: 1.25; }

/* Trailing chevron that slides in on hover to signal the card is a link. */
.portal-quick::after {
    content: "";
    position: absolute;
    inset-inline-end: 18px;
    width: 9px;
    height: 9px;
    border-top: 2px solid var(--mud-palette-primary);
    border-inline-end: 2px solid var(--mud-palette-primary);
    transform: rotate(45deg) translateX(-6px);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

[dir="rtl"] .portal-quick::after { transform: rotate(225deg) translateX(-6px); }

.portal-quick:hover::after {
    opacity: 1;
    transform: rotate(45deg) translateX(0);
}

[dir="rtl"] .portal-quick:hover::after { transform: rotate(225deg) translateX(0); }

/* Icon tile lifts subtly when its quick-action / stat card is hovered. */
.portal-card--hover:hover .portal-badge {
    transform: translateY(-1px) scale(1.05);
    transition: transform 0.2s cubic-bezier(.2, .7, .3, 1);
}

.portal-skeleton {
    border-radius: 16px !important;
    height: 116px;
}

/* Slim, premium scrollbars inside portal scroll regions (ticket list/thread). */
.portal-tk-list,
.portal-tk-thread {
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--mud-palette-primary-rgb), 0.35) transparent;
}
.portal-tk-list::-webkit-scrollbar,
.portal-tk-thread::-webkit-scrollbar { width: 8px; }
.portal-tk-list::-webkit-scrollbar-thumb,
.portal-tk-thread::-webkit-scrollbar-thumb {
    background: rgba(var(--mud-palette-primary-rgb), 0.28);
    border-radius: 999px;
}
.portal-tk-list::-webkit-scrollbar-thumb:hover,
.portal-tk-thread::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--mud-palette-primary-rgb), 0.45);
}

.portal-header-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.portal-header-link {
    text-transform: none;
    min-width: 0;
    white-space: nowrap;
}

.portal-drawer .mud-navmenu .mud-nav-link.active {
    background: linear-gradient(90deg, rgba(var(--mud-palette-primary-rgb), 0.16), rgba(var(--mud-palette-primary-rgb), 0.04));
    color: var(--mud-palette-primary);
    font-weight: 700;
    position: relative;
}

.portal-drawer .mud-navmenu .mud-nav-link.active::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    inset-block: 6px;
    width: 3px;
    border-radius: 0 4px 4px 0;
    background: linear-gradient(180deg, var(--mud-palette-primary), var(--mud-palette-secondary));
}

.portal-drawer .mud-navmenu .mud-nav-link.active .mud-nav-link-icon {
    color: var(--mud-palette-primary) !important;
}

@media (max-width: 768px) {
    .portal-header-link .mud-button-label {
        display: none;
    }
}

[dir="rtl"] .portal-section-title::before { margin-left: 2px; }
[dir="rtl"] .portal-stat__head { flex-direction: row-reverse; }
[dir="rtl"] .portal-page-header { text-align: right; }
[dir="rtl"] .portal-quick { flex-direction: row-reverse; text-align: right; }

[dir="rtl"] .portal-brand-button,
[dir="rtl"] .portal-user-menu-header,
[dir="rtl"] .portal-content,
[dir="rtl"] .portal-drawer {
    text-align: right;
}

[dir="rtl"] .portal-brand-row {
    flex-direction: row-reverse;
}

[dir="rtl"] .portal-brand-icon,
[dir="rtl"] .portal-user-avatar {
    margin-right: 0 !important;
    margin-left: .5rem !important;
}

[dir="rtl"] .portal-language-host,
[dir="rtl"] .portal-user-menu {
    margin-left: 0 !important;
    margin-right: .5rem !important;
}

.portal-user-menu-popover {
    min-width: 220px;
    border-radius: 12px !important;
    overflow: hidden;
}

.portal-user-menu-popover .mud-list-item {
    min-height: 40px;
}

.portal-user-menu-header {
    pointer-events: none;
}

[dir="rtl"] .portal-drawer .mud-nav-link {
    text-align: right;
}

[dir="rtl"] .portal-drawer .mud-nav-link .mud-nav-link-text {
    margin-right: .75rem;
    margin-left: 0;
}

[dir="rtl"] .portal-main .mud-paper {
    text-align: right;
}

[dir="rtl"] .portal-main .d-flex.align-center {
    flex-direction: row-reverse;
}

[dir="rtl"] .portal-main .mr-4 {
    margin-right: 0 !important;
    margin-left: 1rem !important;
}

[dir="rtl"] .portal-main .mr-2 {
    margin-right: 0 !important;
    margin-left: .5rem !important;
}

/* ===================== Interactive polish ===================== */

/* Primary filled buttons on the content surfaces get a gradient + hover lift.
   Scoped to card and page-header contexts on purpose: this never matches the
   hero ".portal-hero" or the dark plan card ".portal-plan-card", so their
   bespoke glass / white button treatments are left intact. */
.portal-card .mud-button-filled.mud-button-filled-primary,
.portal-page-header .mud-button-filled.mud-button-filled-primary {
    background: linear-gradient(135deg, var(--mud-palette-primary), color-mix(in srgb, var(--mud-palette-secondary) 55%, var(--mud-palette-primary))) !important;
    box-shadow: 0 10px 24px -14px rgba(var(--mud-palette-primary-rgb), 0.85);
    transition: transform 0.18s cubic-bezier(.2, .7, .3, 1), box-shadow 0.18s ease, filter 0.18s ease;
}

.portal-card .mud-button-filled.mud-button-filled-primary:hover,
.portal-page-header .mud-button-filled.mud-button-filled-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 30px -14px rgba(var(--mud-palette-primary-rgb), 0.95);
    filter: brightness(1.03);
}

.portal-card .mud-button-filled.mud-button-filled-primary:active,
.portal-page-header .mud-button-filled.mud-button-filled-primary:active {
    transform: translateY(0);
}

/* Status / info chips: a touch more rounding and weight for a premium pill. */
.portal-card .mud-chip,
.portal-page-header .mud-chip {
    border-radius: 999px;
    font-weight: 600;
}

/* App-bar identity: gradient avatar with a soft ring, brand tile depth. */
.portal-user-avatar {
    background: linear-gradient(135deg, #5eead4, #2563eb) !important;
    color: #0b1220 !important;
    font-weight: 800;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.28);
}

.portal-brand-icon {
    background: rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    padding: 4px;
}

/* Drawer group labels get a small gradient tick for rhythm. */
.portal-drawer .mud-navmenu > .mud-typography {
    position: relative;
    padding-inline-start: 20px !important;
}

.portal-drawer .mud-navmenu > .mud-typography::before {
    content: "";
    position: absolute;
    inset-inline-start: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 2px;
    background: linear-gradient(135deg, var(--mud-palette-primary), var(--mud-palette-secondary));
}
