/* Portal del residente: cromo autenticado (PortalShell) y UserHome. Usa las variables de marca
   de home.css (--landing-*). Prefijo .portal para no chocar con el cromo compartido de NAI/MDX. */
.portal {
    --portal-sidebar-w: 205px;
    --portal-sidebar-bg: #f3f3f4;
    --portal-active-bg: #c9d0d9;
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    color: var(--landing-text);
    background: #fff;
}

.portal-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

/* Menú lateral */
.portal-nav-toggle {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.portal-sidebar {
    position: sticky;
    top: 0;
    flex: 0 0 var(--portal-sidebar-w);
    align-self: flex-start;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--portal-sidebar-bg);
}

.portal-sidebar-top {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3.5rem 1rem 3.75rem;
}

.portal-logo img {
    display: block;
    width: 160px;
    max-width: 100%;
    height: auto;
    max-height: 70px;
    object-fit: contain;
}

.portal-nav-button {
    display: none;
}

.portal-nav {
    display: flex;
    flex-direction: column;
}

.portal-nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .7rem 1.5rem;
    color: var(--landing-text) !important;
    font-size: 1rem;
    text-decoration: none !important;
    transition: background-color .15s ease;
}

.portal-nav-link:first-child {
    padding-top: .9rem;
    padding-bottom: .9rem;
}

.portal-nav-link:hover {
    background: color-mix(in srgb, var(--portal-active-bg) 55%, transparent);
}

.portal-nav-link.is-active {
    background: var(--portal-active-bg);
}

/* Columna principal */
.portal-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.portal-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    min-height: 84px;
    padding: .9rem 2.25rem;
}

.portal-user {
    position: relative;
}

.portal-user-trigger {
    display: flex;
    align-items: center;
    gap: .6rem;
    list-style: none;
    cursor: pointer;
    font-size: 1rem;
    color: #1b1f24;
}

.portal-user-trigger::-webkit-details-marker {
    display: none;
}

.portal-user-chevron {
    width: 20px;
    height: 20px;
    margin-right: 1.25rem;
    transition: transform .15s ease;
}

.portal-user[open] .portal-user-chevron {
    transform: rotate(180deg);
}

.portal-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--portal-active-bg);
    color: var(--landing-text);
    font-size: 1.1rem;
    font-weight: 500;
}

.portal-user-menu {
    position: absolute;
    right: 0;
    top: calc(100% + .5rem);
    z-index: 40;
    min-width: 220px;
    margin: 0;
    padding: .4rem 0;
    list-style: none;
    background: #fff;
    border: 1px solid #e3e6ea;
    border-radius: .6rem;
    box-shadow: 0 10px 30px rgba(15, 30, 50, .12);
}

.portal-user-menu a {
    display: block;
    padding: .55rem 1rem;
    color: var(--landing-text) !important;
    font-size: .95rem;
    text-decoration: none !important;
}

.portal-user-menu a:hover {
    background: var(--portal-sidebar-bg);
}

.portal-user-divider {
    height: 1px;
    margin: .35rem 0;
    background: #e3e6ea;
}

.portal-user-menu .portal-user-signout {
    color: #b42318 !important;
}

.portal-content {
    flex: 1;
    width: 100%;
    max-width: 1100px;
    padding: 0 2.25rem 3rem 3.5rem;
}

/* UserHome */
.portal-greeting {
    margin: 1rem 0 .5rem;
    font-size: 1.65rem;
    font-weight: 600;
    color: var(--landing-text);
}

.portal-intro {
    margin: 0 0 2rem;
    font-size: 1.1rem;
    color: #1f2d3d;
}

.portal-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .6rem;
}

.portal-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2.25rem 1.5rem 2.25rem;
    text-align: center;
    background: #fff;
    border: 1px solid #d9dde2;
    border-radius: .5rem;
    box-shadow: 0 6px 18px rgba(15, 30, 50, .06);
}

.portal-card-icon {
    width: 46px;
    height: 46px;
    margin-bottom: .9rem;
    color: var(--landing-primary);
}

.portal-card h2 {
    margin: 0 0 .9rem;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--landing-text);
}

.portal-card p {
    flex-grow: 1;
    max-width: 15rem;
    margin: 0 0 1.4rem;
    font-size: .92rem;
    line-height: 1.6;
    color: #1f2d3d;
}

.portal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    min-width: 148px;
    padding: .85rem 1.6rem;
    border-radius: 999px;
    background: var(--landing-primary);
    color: #fff !important;
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .02em;
    text-decoration: none !important;
    transition: background-color .15s ease;
}

.portal-btn:hover,
.portal-btn:focus-visible {
    background: var(--landing-primary-hover);
}

.portal-btn-arrow {
    width: 18px;
    height: 10px;
}

/* «Have a question?» */
.portal-question {
    display: grid;
    grid-template-columns: minmax(0, 41%) minmax(0, 1fr);
    margin-top: 2.5rem;
    overflow: hidden;
    background: #fff;
    border: 1px solid #d9dde2;
    border-radius: .5rem;
    box-shadow: 0 6px 18px rgba(15, 30, 50, .06);
}

.portal-question-photo {
    min-height: 300px;
    background-size: cover;
    background-position: 35% center;
}

.portal-question-body {
    padding: 2rem 2.25rem 2rem 2.5rem;
}

.portal-question-body h2 {
    margin: 0 0 .5rem;
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--landing-text);
}

.portal-question-body > p {
    max-width: 22rem;
    margin: 0 0 1.1rem;
    font-size: .95rem;
    line-height: 1.45;
    color: #1b1f24;
}

.portal .tenant-message-input {
    display: block;
    width: 100%;
    min-height: 125px;
    padding: .55rem .6rem;
    font: inherit;
    font-size: 1rem;
    color: #1b1f24;
    border: 1px solid #8a9099;
    border-radius: .4rem;
    resize: vertical;
    box-sizing: border-box;
}

.portal .tenant-message-input::placeholder {
    color: #8a9099;
}

.portal .tenant-message-input:focus {
    outline: 0;
    border-color: var(--landing-primary);
    box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--landing-primary) 22%, transparent);
}

.portal .tenant-message-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    width: 100%;
    min-height: 3.1rem;
    margin-top: 1rem;
    border: 0;
    border-radius: 999px;
    background: var(--landing-primary);
    color: #fff;
    font: inherit;
    font-size: .95rem;
    font-weight: 500;
    cursor: pointer;
}

.portal .tenant-message-btn:hover:not(:disabled) {
    background: var(--landing-primary-hover);
}

.portal .tenant-message-btn:disabled {
    opacity: .75;
    cursor: not-allowed;
}

.portal .tenant-message-spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: portal-spin .7s linear infinite;
}

@keyframes portal-spin {
    to { transform: rotate(360deg); }
}

.portal .tenant-message-alert {
    margin-bottom: .75rem;
    padding: .55rem .75rem;
    border: 1px solid transparent;
    border-radius: .4rem;
    font-size: .92rem;
}

.portal .tenant-message-alert--error {
    color: #842029;
    background: #f8d7da;
    border-color: #f5c2c7;
}

.portal .tenant-message-alert--success {
    color: #0f5132;
    background: #d1e7dd;
    border-color: #badbcc;
}

/* Tablet */
@media (max-width: 1024px) {
    .portal-content {
        padding: 0 1.5rem 2.5rem;
    }

    .portal-cards {
        grid-template-columns: 1fr;
    }

    .portal-question {
        grid-template-columns: 1fr;
    }

    .portal-question-photo {
        min-height: 200px;
    }
}

/* Móvil: el menú lateral pasa a barra superior con botón */
@media (max-width: 768px) {
    .portal {
        flex-direction: column;
    }

    .portal-sidebar {
        position: static;
        flex: none;
        width: 100%;
        min-height: 0;
    }

    .portal-sidebar-top {
        justify-content: space-between;
        padding: .9rem 1rem;
    }

    .portal-logo img {
        width: 130px;
        max-height: 48px;
    }

    .portal-nav-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        border-radius: .5rem;
        color: var(--landing-text);
        cursor: pointer;
    }

    .portal-nav-button svg {
        width: 24px;
        height: 24px;
    }

    .portal-nav {
        display: none;
        padding-bottom: .5rem;
    }

    .portal-nav-toggle:checked ~ .portal-sidebar .portal-nav {
        display: flex;
    }

    .portal-header {
        min-height: 0;
        padding: .75rem 1rem;
    }

    .portal-avatar {
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }

    .portal-user-chevron {
        margin-right: .5rem;
    }

    .portal-content {
        padding: 0 1rem 2rem;
    }

    .portal-question-body {
        padding: 1.5rem 1.25rem;
    }
}
