/* FullPage layout – spacing, typography and structure using global design tokens */

.memori-widget.memori-layout-fullpage {
    /* max-width: var(--memori-layout-max-width); */
    /* min-height: 100vh;
    min-height: 100dvh; */
    padding: var(--memori-spacing-md);
    margin-right: auto;
    margin-left: auto;
}

.memori-widget.memori-layout-fullpage > .memori-spin {
    display: flex;
    height: calc(100vh - 50px);
    height: calc(100dvh - 50px);
    min-height: 0;
    flex-direction: column;
    gap: 0;
}
/* "Powered by" is rendered inside .memori--grid-column-left and pinned to its bottom-left corner
   via the default absolute positioning defined in PoweredBy.css. */
.memori-widget.memori-layout-fullpage .memori--grid-column-left > .memori--powered-by {
    bottom: 1rem;
    left: 1rem;
}

/* Header spacing + fullpage chrome (brand + actions bar) */
.memori-widget.memori-layout-fullpage .memori-fullpage-top-header {
    position: relative;
    z-index: 6;
    width: 100%;
    flex-shrink: 0;
    padding: 0 var(--memori-spacing-md);
    padding-bottom: 0;
    margin-bottom: var(--memori-spacing-sm);
}

.memori-widget.memori-layout-fullpage .memori-chat-layout--header {
    min-width: 100%;
    flex-shrink: 0;
    /* padding: 0.625rem 0.9rem; */
    border-bottom: 1px solid color-mix(in srgb, var(--memori-text-color, #111827) 12%, transparent);
    /* border-radius: 0.9rem; */
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    background: color-mix(in oklch, var(--memori-secondary-background), transparent 8%);
    /* box-shadow: 0 10px 26px rgba(15, 23, 42, 0.08); */
}

.memori-widget.memori-layout-fullpage .memori-chat-layout--controls .memori-chat--history {
    border: 1px solid color-mix(in srgb, var(--memori-text-color, #111827) 12%, transparent);
}

.memori-widget.memori-layout-fullpage .memori-fullpage-header-row,
.memori-widget.memori-layout-chat .memori-fullpage-header-row {
    display: flex;
    width: 100%;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    padding: var(--memori-spacing-md);
    gap: var(--memori-spacing-md);
}

.memori-widget.memori-layout-fullpage .memori-fullpage-header-brand,
.memori-widget.memori-layout-chat .memori-fullpage-header-brand {
    display: inline-flex;
    overflow: hidden;
    min-width: 0;
    flex: 1 1 auto;
    align-items: center;
    gap: 0.625rem;
}

.memori-widget.memori-layout-fullpage .memori-fullpage-header-brand-icon,
.memori-widget.memori-layout-chat .memori-fullpage-header-brand-icon {
    display: block;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(145deg, #6d28d9 0%, #534ab7 52%, #4338ca 100%);
    box-shadow: 0 1px 4px rgba(109, 40, 217, 0.35);
}

.memori-widget.memori-layout-fullpage .memori-fullpage-header-brand-icon--avatar,
.memori-widget.memori-layout-chat .memori-fullpage-header-brand-icon--avatar {
    flex-shrink: 0;
    border: 0;
    background: none;
    box-shadow: 0 1px 4px rgba(109, 40, 217, 0.2);
    object-fit: cover;
}

.memori-widget.memori-layout-fullpage .memori-fullpage-header-brand-name,
.memori-widget.memori-layout-chat .memori-fullpage-header-brand-name {
    display: block;
    overflow: hidden;
    min-width: 0;
    max-width: 100%;
    flex: 1 1 auto;
    color: var(--memori-text-color, #1f2937);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.memori-widget.memori-layout-fullpage .memori-fullpage-header-actions,
.memori-widget.memori-layout-chat .memori-fullpage-header-actions {
    display: flex;
    min-width: 0;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
}

/* FullPage header controls: compact square actions + rounded login CTA */
.memori-widget.memori-layout-fullpage .memori-header.memori-header--fullpage {
    min-width: 0;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

.memori-widget.memori-layout-fullpage .memori-header--fullpage-primary,
.memori-widget.memori-layout-fullpage .memori-header--fullpage-secondary {
    flex-wrap: nowrap;
    gap: 0.5rem;
}

.memori-widget.memori-layout-fullpage .memori-header--fullpage-divider {
    min-height: 26px;
    margin: 0;
}

/* CHAT: title block a sinistra, controlli allineati a destra */
.memori-widget.memori-layout-chat .memori-fullpage-header-row {
    justify-content: flex-end;
    background: var(--memori-secondary-background);
}

.memori-widget.memori-layout-chat .memori-fullpage-header-brand {
    margin-right: auto;
}

.memori-widget.memori-layout-chat .memori-fullpage-header-actions {
    flex: 0 0 auto;
}

/* Full-height flex row: [grid] [artifact column] — outside the grid so artifact
   spans the entire content height without inheriting grid padding/max-width */
.memori-widget.memori-layout-fullpage .memori-fullpage-content-row {
    display: flex;
    overflow: hidden;
    min-height: 0;
    flex: 1 1 auto;
    flex-direction: row;
    align-items: stretch;
}

/* Grid: main + left column (avatar) */
.memori-widget.memori-layout-fullpage .memori--grid {
    display: flex;
    width: 100%;
    max-width: var(--memori-layout-max-width);
    height: 100%;
    min-height: 0;
    flex: 1 1 auto;
    align-items: stretch;
    justify-content: center;
    padding: 0 var(--memori-spacing-md) var(--memori-spacing-md);
    padding-top: var(--memori-spacing-md);
    padding-bottom: var(--memori-spacing-xl);
    margin: 0 auto;
    gap: var(--memori-spacing-md);
}

.memori-widget.memori-layout-fullpage .memori--grid-column-left {
    overflow: hidden;
    width: 50%;
    max-width: 420px;
    flex-shrink: 0;
    border: 1px solid color-mix(in srgb, var(--memori-text-color, #111827) 10%, transparent);
    border-radius: 0.9rem;
    margin-right: 0;
    backdrop-filter: blur(10px);
    background: var(--memori-bg-color, #f4f7fa23);
}

.memori-widget.memori-layout-fullpage .memori--grid-column-left .memori--avatar-wrapper {
    align-items: flex-start;
    padding-top: clamp(1.25rem, 3vw, 2rem);
}

.memori-widget.memori-layout-fullpage .memori--grid-column-left .memori--avatar-wrapper model-viewer,
.memori-widget.memori-layout-fullpage .memori--grid-column-left .memori--avatar-wrapper canvas,
.memori-widget.memori-layout-fullpage .memori--grid-column-left .memori--avatar-wrapper > div {
    max-width: 100%;
}

.memori-widget.memori-layout-fullpage .memori-chat-layout--main {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    align-items: stretch;
    justify-content: stretch;
}

/* Artifact column — flex sibling of .memori--grid inside .memori-fullpage-content-row.
   Sits outside the padded grid so it spans the full content height with no padding gaps. */
.memori-widget.memori-layout-fullpage .memori--grid-column-artifact {
    overflow: hidden;
    width: 0;
    min-width: 0;
    flex-shrink: 0;
    transition: width 0.25s ease;
}

.memori-widget.memori-layout-fullpage .memori--grid-column-artifact--open {
    width: 600px;
    border-left: 1px solid color-mix(in srgb, var(--memori-text-color, #111827) 10%, transparent);
    background: var(--memori-secondary-background);
}

/* Hide avatar column when artifact drawer is open.
   Selector updated: artifact is now a sibling of .memori--grid, not inside it. */
.memori-widget.memori-layout-fullpage
    .memori-fullpage-content-row:has(.memori--grid-column-artifact--open)
    .memori--grid-column-left {
    display: none;
}

@media (max-width: 1260px) {
    .memori-widget.memori-layout-fullpage .memori--grid-column-artifact {
        display: none;
    }
}

.memori-widget.memori-layout-fullpage .memori-chat-layout--controls {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
}

.memori-widget.memori-layout-fullpage .memori-chat-layout--controls .memori--start-panel,
.memori-widget.memori-layout-fullpage .memori-chat-layout--controls .memori-chat--wrapper {
    width: 100%;
    max-width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0 !important;
    margin-right: 0;
    margin-left: 0;
}

/* Typography: title and description in fullpage left column */
.memori-widget.memori-layout-fullpage .memori--title {
    margin-bottom: var(--memori-spacing-xs);
    color: var(--memori-text-color);
    font-size: var(--memori-text-size-heading-large);
    font-weight: var(--memori-text-weight-semibold);
    line-height: var(--memori-text-line-tight);
}

.memori-widget.memori-layout-fullpage .memori--description,
.memori-widget.memori-layout-fullpage .memori--needsPosition {
    padding: var(--memori-spacing-lg);
    padding-top: var(--memori-spacing-xs);
    color: var(--memori-text-color);
    font-size: var(--memori-text-size-base);
    line-height: var(--memori-text-line-relaxed);
}

/* Fullpage: Memori brand lives in the header; no footer watermark. */

/* FullPage + dark: main surface on inputs (ancestor or widget may carry data-theme). */
.memori-widget.memori-layout-fullpage[data-theme='dark'] .memori-chat-inputs,
[data-theme='dark'] .memori-widget.memori-layout-fullpage .memori-chat-inputs {
    background-color: var(--memori-main-background);
}

.memori-widget.memori-layout-fullpage[data-theme='dark'] .memori-chat-textarea,
[data-theme='dark'] .memori-widget.memori-layout-fullpage .memori-chat-textarea {
    background-color: var(--memori-main-background);
}

.memori-widget.memori-layout-fullpage[data-theme='dark'] .memori-chat-textarea--inner,
[data-theme='dark'] .memori-widget.memori-layout-fullpage .memori-chat-textarea--inner {
    background-color: var(--memori-main-background);
}

.memori-widget.memori-layout-fullpage[data-theme='dark'] textarea.memori-chat-textarea--input,
[data-theme='dark'] .memori-widget.memori-layout-fullpage textarea.memori-chat-textarea--input {
    background-color: var(--memori-main-background);
}

@media (max-width: 870px) {
    .memori-widget.memori-layout-fullpage {
        padding: var(--memori-spacing-sm);
    }
    /* 
    .memori-widget.memori-layout-fullpage > .memori-spin {
        height: calc(100vh - 100px);
        height: calc(100dvh - 100px);
        gap: var(--memori-spacing-md);
    } */

    .memori-widget.memori-layout-fullpage .memori-fullpage-top-header {
        padding: 0 var(--memori-spacing-sm);
        padding-bottom: 0;
        margin-bottom: var(--memori-spacing-md);
    }

    .memori-widget.memori-layout-fullpage .memori--grid-column-left {
        display: none;
    }

    .memori-widget.memori-layout-fullpage .memori--grid {
        padding: 0 var(--memori-spacing-sm) var(--memori-spacing-sm);
        gap: var(--memori-spacing-sm);
    }

    .memori-widget.memori-layout-fullpage .memori-chat-layout--controls {
        padding: 0;
    }
}

@media (max-width: 480px) {
    .memori-widget.memori-layout-fullpage .memori-fullpage-top-header {
        padding: 0 var(--memori-spacing-xs);
        padding-bottom: 0;
    }

    .memori-widget.memori-layout-fullpage .memori-fullpage-header-brand-name {
        font-size: 1.1rem;
    }

    .memori-widget.memori-layout-fullpage .memori-chat-layout--controls {
        padding: 0;
    }

    .memori-widget.memori-layout-fullpage .memori--grid {
        padding: 0 var(--memori-spacing-xs) var(--memori-spacing-xs);
    }

    .memori-widget.memori-layout-fullpage .memori-fullpage-header-row,
    .memori-widget.memori-layout-chat .memori-fullpage-header-row {
        /* flex-wrap: wrap; */
        align-items: flex-start;
    }

    .memori-widget.memori-layout-fullpage .memori-fullpage-header-brand,
    .memori-widget.memori-layout-chat .memori-fullpage-header-brand {
        min-width: 0;
        max-width: calc(100% - 6.5rem);
        flex: 1 1 auto;
    }

    .memori-widget.memori-layout-fullpage .memori-fullpage-header-actions,
    .memori-widget.memori-layout-chat .memori-fullpage-header-actions {
        flex: 0 0 auto;
        justify-content: flex-end;
    }

    /* CHAT: keep agent title + toolbar on one row on small phones */
    .memori-widget.memori-layout-chat .memori-fullpage-header-row {
        flex-wrap: nowrap;
        align-items: center;
    }

    .memori-widget.memori-layout-chat .memori-fullpage-header-actions {
        min-width: 0;
        flex: 0 0 auto;
        flex-wrap: nowrap;
        justify-content: flex-end;
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .memori-widget.memori-layout-chat .memori-fullpage-header-actions .memori-header.memori-header--fullpage {
        min-width: 0;
        flex-wrap: nowrap;
    }
}
