/* ================================================================
   Admin Portal — shell + login chrome
   Editorial Light direction. Palette from Parfym "pfour" tokens.
   ================================================================ */

:root {
    --ap-ink: #111;
    --ap-surface: #fff;
    --ap-canvas: #FAFAF8;
    --ap-warm: #F2F1EC;
    --ap-line: #eae9e7;
    --ap-muted: #727272;
    --ap-faint: #adadad;
    --ap-active-fill: #FFF0F5;
    --ap-active-bar: #e0489a;
    --ap-font: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --ap-sidebar-w: 288px;
    --ap-topbar-h: 56px;
    --ap-card-pad-x: 26px;
    --ap-card-pad-y: 22px;
}

/* ---- App shell layout ---- */
.ap-shell {
    font-family: var(--ap-font);
    color: var(--ap-ink);
    min-height: 100vh;
    background: var(--ap-warm);
}

/* Top bar */
.ap-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--ap-topbar-h);
    background: var(--ap-ink);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 20px;
    z-index: 200;
}

.ap-burger {
    background: none;
    border: 0;
    color: #fff;
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ap-burger:hover { background: rgba(255, 255, 255, .12); }

.ap-title {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ap-topbar .ap-spacer { flex: 1; }

.ap-user {
    display: flex;
    align-items: center;
    gap: 9px;
}

.ap-chip {
    background: rgba(255, 255, 255, .12);
    border-radius: 20px;
    padding: 5px 12px 5px 6px;
    font-size: 12.5px;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 260px;
    overflow: hidden;
    color: #fff;
    text-decoration: none;
}

.ap-chip:hover { background: rgba(255, 255, 255, .2); }

.ap-chip .ap-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ap-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #FDBFD5;
    color: var(--ap-ink);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    text-transform: uppercase;
}

.ap-signout {
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .18);
    color: #fff;
    border-radius: 8px;
    padding: 7px 13px;
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.ap-signout:hover { background: rgba(255, 255, 255, .2); }

/* Sidebar */
.ap-sidebar {
    position: fixed;
    top: var(--ap-topbar-h);
    bottom: 0;
    left: 0;
    width: var(--ap-sidebar-w);
    background: var(--ap-surface);
    border-right: 1px solid var(--ap-line);
    display: flex;
    flex-direction: column;
    z-index: 150;
    transition: transform .2s ease;
}

.ap-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--ap-line);
}

.ap-brand img { height: 19px; width: auto; }

.ap-brand .ap-tag {
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ap-muted);
    font-weight: 600;
    border-left: 1px solid var(--ap-line);
    padding-left: 12px;
}

.ap-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 10px 24px;
}

.ap-nav-footer {
    border-top: 1px solid var(--ap-line);
    padding: 10px;
}

/* Nav groups & items */
.ap-group { margin: 1px 0; }

.ap-ghead {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 11px 14px;
    border: 0;
    background: none;
    border-radius: 9px;
    cursor: pointer;
    color: var(--ap-ink);
    font: inherit;
    font-weight: 600;
    font-size: 14.5px;
    text-align: left;
}

.ap-ghead:hover { background: var(--ap-warm); }

.ap-ghead .ap-ic {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ap-ink);
    flex-shrink: 0;
}

.ap-ghead .ap-ic svg { width: 18px; height: 18px; }

.ap-ghead .ap-count {
    margin-left: auto;
    font-size: 11px;
    color: var(--ap-faint);
    font-weight: 600;
}

.ap-ghead .ap-chev {
    margin-left: 8px;
    color: #c9c9c9;
    transition: transform .15s ease;
    display: flex;
}

.ap-ghead .ap-chev svg { width: 13px; height: 13px; }

.ap-group.open .ap-chev { transform: rotate(90deg); }

/* single top-level link (Overview) — reuses ghead look, is an <a> */
a.ap-ghead { text-decoration: none; }

a.ap-ghead.active {
    background: var(--ap-active-fill);
    color: var(--ap-ink);
}

.ap-sub {
    padding: 2px 0 8px 46px;
    display: none;
}

.ap-group.open .ap-sub { display: block; }

.ap-subhead {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ap-faint);
    font-weight: 700;
    padding: 9px 12px 3px;
}

.ap-item {
    position: relative;
    display: block;
    padding: 8px 12px;
    border-radius: 7px;
    color: #555;
    font-size: 13.5px;
    text-decoration: none;
}

.ap-item:hover {
    background: var(--ap-warm);
    color: var(--ap-ink);
}

.ap-item.active {
    background: var(--ap-active-fill);
    color: var(--ap-ink);
    font-weight: 600;
}

.ap-item.active::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 3px;
    background: var(--ap-active-bar);
}

/* Content region */
.ap-content {
    margin-left: var(--ap-sidebar-w);
    padding-top: var(--ap-topbar-h);
    min-height: 100vh;
}

/* Framed-card page chrome: each page's content sits in one white rounded card
   floating on the warm canvas. ControlsBar full-bleeds to the card edges via
   the --ap-card-pad-* tokens. */
.ap-content-inner {
    background: var(--ap-surface);
    border: 1px solid var(--ap-line);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(17, 17, 17, .05);
    margin: 24px 28px;
    padding: var(--ap-card-pad-y) var(--ap-card-pad-x);
    min-height: calc(100vh - var(--ap-topbar-h) - 48px);
}

/* Material's floating elevation looks out of place inside the card — flatten
   tables/panels to hairline frames instead. */
.ap-content-inner .mat-elevation-z5 {
    box-shadow: none;
    border: 1px solid var(--ap-line);
    border-radius: 8px;
}

@media (max-width: 900px) {
    .ap-content-inner {
        margin: 12px 10px;
        --ap-card-pad-x: 14px;
        --ap-card-pad-y: 14px;
    }
}

/* Sidebar scrim (mobile overlay) */
.ap-scrim {
    display: none;
    position: fixed;
    inset: var(--ap-topbar-h) 0 0 0;
    background: rgba(0, 0, 0, .35);
    z-index: 140;
}

/* Collapsed state (desktop: push content full width) */
.ap-shell.nav-collapsed .ap-sidebar { transform: translateX(-100%); }
.ap-shell.nav-collapsed .ap-content { margin-left: 0; }

/* Mobile: sidebar overlays, scrim shows when open */
@media (max-width: 900px) {
    .ap-content { margin-left: 0; }
    .ap-sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0,0,0,.15); }
    .ap-shell.nav-open .ap-sidebar { transform: translateX(0); }
    .ap-shell.nav-open .ap-scrim { display: block; }
}

/* ================================================================
   Login page
   ================================================================ */
.ap-login {
    font-family: var(--ap-font);
    min-height: 100vh;
    display: flex;
    color: var(--ap-ink);
}

.ap-login-brand {
    width: 42%;
    max-width: 520px;
    background: var(--ap-ink);
    color: #fff;
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.ap-login-brand img {
    height: 22px;
    width: auto;
    align-self: flex-start;
    filter: invert(1) brightness(2);
}

.ap-login-tagline {
    font-size: 28px;
    font-weight: 600;
    line-height: 1.22;
}

.ap-login-strip {
    display: flex;
    gap: 8px;
    margin-top: 22px;
}

.ap-login-strip span {
    height: 9px;
    border-radius: 5px;
}

.ap-login-foot {
    font-size: 11.5px;
    color: #8a8a8a;
}

.ap-login-form {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: var(--ap-surface);
}

.ap-login-form .inner { width: 300px; max-width: 100%; }

.ap-login-form h1 {
    font-size: 23px;
    font-weight: 600;
    margin: 0 0 4px;
}

.ap-login-form .sub {
    font-size: 13px;
    color: var(--ap-muted);
    margin: 0 0 24px;
}

.ap-field-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ap-muted);
    font-weight: 700;
    margin: 0 0 6px;
}

.ap-input {
    width: 100%;
    height: 44px;
    border: 1px solid var(--ap-line);
    border-radius: 9px;
    padding: 0 14px;
    font: inherit;
    font-size: 14px;
    color: var(--ap-ink);
    margin-bottom: 14px;
    background: #fff;
    box-sizing: border-box;
}

.ap-input:focus {
    outline: none;
    border-color: var(--ap-ink);
}

.ap-btn-primary {
    width: 100%;
    height: 46px;
    border: 0;
    border-radius: 9px;
    background: var(--ap-ink);
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
}

.ap-btn-primary:hover { background: #000; }

.ap-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ap-faint);
    font-size: 11px;
    margin: 18px 0 16px;
}

.ap-divider::before,
.ap-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--ap-line);
}

.ap-sso { display: inline-block; line-height: 0; }
.ap-sso img { width: 100%; max-width: 240px; height: auto; cursor: pointer; }

.ap-login-error {
    background: #FFF0F0;
    border: 1px solid #f3caca;
    color: #b3261e;
    border-radius: 9px;
    padding: 11px 14px;
    font-size: 12.5px;
    margin-bottom: 18px;
    display: flex;
    gap: 9px;
    align-items: flex-start;
}

.ap-login-error svg { flex-shrink: 0; margin-top: 1px; }

@media (max-width: 760px) {
    .ap-login { flex-direction: column; }
    .ap-login-brand {
        width: auto;
        max-width: none;
        padding: 20px 24px;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
    }
    .ap-login-tagline, .ap-login-strip, .ap-login-foot { display: none; }
    .ap-login-form { padding: 32px 24px; align-items: flex-start; }
}

/* ================================================================
   Navigation feedback — top progress bar + Blazor boot overlay.
   Included on both the MVC layout and the Blazor _Host so moving
   between fast (MVC) and slow (Blazor) pages never looks dead.
   ================================================================ */
html, body { background: var(--ap-warm); }

#nav-progress {
    position: fixed;
    top: 0; left: 0;
    height: 3px; width: 0;
    background: var(--ap-active-bar);
    box-shadow: 0 0 8px rgba(224, 72, 154, .55);
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: width .25s ease, opacity .2s ease;
}
#nav-progress.active { opacity: 1; }

/* Full-screen spinner shown until the Blazor circuit renders the app. */
.app-loading {
    position: fixed;
    inset: 0;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    background: var(--ap-warm);
    transition: opacity .3s ease;
}
.app-loading.hidden { opacity: 0; visibility: hidden; }
.app-loading img { height: 20px; width: auto; opacity: .9; }
.app-loading .app-spinner {
    width: 34px; height: 34px;
    border: 3px solid #e6dfe2;
    border-top-color: var(--ap-active-bar);
    border-radius: 50%;
    animation: app-spin .8s linear infinite;
}
.app-loading .app-loading-text { font-size: 13px; color: var(--ap-muted); font-family: var(--ap-font); }
@keyframes app-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .app-loading .app-spinner { animation-duration: 1.6s; }
    #nav-progress { transition: opacity .2s ease; }
}

/* ---- MatTable image thumbnails ----
   .banner-img used to be defined locally in BannerDetails.razor's own <style>
   block, so it only applied there — other MatTable list pages (auto coupon
   campaigns, campaign details) rendered full-size images and blew out the
   table width. Defined globally here so every page gets it. */
.banner-img {
    max-width: 50px;
    max-height: 50px;
    object-fit: contain;
}

.visualitems-table img,
.mat-table img {
    max-width: 50px;
    max-height: 50px;
    object-fit: contain;
}
