/* =============================================================================
   app/portal/static/css/portal.css
============================================================================= */


/* ======================================================
   RESET
====================================================== */

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;

    display: flex;
    flex-direction: column;

    background: var(--portal-background);
    color: var(--portal-dark);

    font-family:
        Inter,
        Arial,
        Helvetica,
        sans-serif;

    font-size: 15px;
    line-height: 1.5;
}

button,
input {
    font: inherit;
}

a {
    color: inherit;
}


/* ======================================================
   HEADER
====================================================== */

.portal-header {
    position: relative;
    z-index: 100;

    background: var(--portal-surface);
    border-bottom: 1px solid var(--portal-border);
}

.portal-header__inner {
    width: min(1180px, calc(100% - 32px));
    min-height: 76px;
    margin: 0 auto;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.portal-brand {
    display: inline-flex;
    align-items: center;

    color: var(--portal-dark);
    text-decoration: none;
}

.portal-brand__logo {
    display: block;
    width: auto;
    max-width: 250px;
    height: 50px;
    object-fit: contain;
}


/* ======================================================
   PROFILE MENU
====================================================== */

.portal-profile {
    position: relative;
}

.portal-profile__trigger {
    min-width: 52px;
    min-height: 46px;
    padding: 3px 6px 3px 3px;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;

    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;

    cursor: pointer;
}

.portal-profile__trigger:hover,
.portal-profile__trigger[aria-expanded="true"] {
    background: var(--portal-background);
    border-color: var(--portal-border);
}

.portal-profile__trigger:focus-visible {
    outline: 3px solid rgba(15, 118, 110, 0.16);
    outline-offset: 2px;
}

.portal-profile__avatar {
    width: auto;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 auto;

    background: color-mix(
        in srgb,
        var(--portal-tech) 60%,
        transparent
    );

    color: #FFFFFF;

    border-radius: 999px;

    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.portal-profile__avatar {
    min-width: 38px;
    height: 38px;
    padding: 0 11px;
}

.portal-profile__chevron {
    width: 15px;
    height: 15px;

    fill: none;
    stroke: var(--portal-text-secondary);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;

    transition: transform 0.15s ease;
}

.portal-profile__trigger[aria-expanded="true"]
.portal-profile__chevron {
    transform: rotate(180deg);
}

.portal-profile__dropdown {
    position: absolute;
    top: calc(100% + 9px);
    right: 0;
    z-index: 200;

    width: 290px;

    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: 12px;

    box-shadow: 0 16px 40px rgba(17, 24, 39, 0.14);
}

.portal-profile__identity {
    padding: 16px;

    display: flex;
    flex-direction: column;
    gap: 3px;
}

.portal-profile__identity strong {
    overflow: hidden;

    color: var(--portal-dark);

    font-size: 14px;
    line-height: 1.4;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.portal-profile__identity span {
    overflow: hidden;

    color: var(--portal-text-secondary);

    font-size: 12px;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.portal-profile__divider {
    height: 1px;
    background: var(--portal-border);
}

.portal-profile__actions {
    padding: 6px;

    display: flex;
    flex-direction: column;
}

.portal-profile__logout-form {
    margin: 0;
}

.portal-profile__item {
    width: 100%;
    min-height: 40px;
    padding: 9px 10px;

    display: flex;
    align-items: center;
    gap: 10px;

    background: transparent;
    color: var(--portal-dark);

    border: 0;
    border-radius: 8px;

    font-size: 13px;
    font-weight: 600;
    text-align: left;
    text-decoration: none;

    cursor: pointer;
}

.portal-profile__item:hover {
    background: var(--portal-background);
    color: var(--portal-tech);
}

.portal-profile__item:focus-visible {
    outline: 2px solid rgba(15, 118, 110, 0.18);
    outline-offset: -1px;
}

.portal-profile__item svg {
    width: 17px;
    height: 17px;

    flex: 0 0 auto;

    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.portal-profile__item--logout {
    color: #B91C1C;
}

.portal-profile__item--logout:hover {
    background: rgba(220, 38, 38, 0.07);
    color: #B91C1C;
}

[hidden] {
    display: none !important;
}


/* ======================================================
   MAIN
====================================================== */

.portal-main {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;

    flex: 1;
}

.portal-page {
    width: 100%;
}

.portal-page--center {
    min-height: 60vh;

    display: flex;
    align-items: center;
    justify-content: center;
}

.portal-page-header {
    margin-bottom: 24px;

    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.portal-page-header h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.2;
}

.portal-page-header p {
    margin: 8px 0 0;
    color: var(--portal-text-secondary);
}

.portal-page-header__actions {
    display: flex;
    align-items: center;
    gap: 10px;
}


/* ======================================================
   CARDS
====================================================== */

.portal-card {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(17, 24, 39, 0.05);
}

.portal-form-card {
    padding: 28px;
}

.portal-form-section + .portal-form-section {
    margin-top: 32px;
    padding-top: 28px;
    border-top: 1px solid var(--portal-border);
}

.portal-form-section h2 {
    margin: 0;
    font-size: 19px;
}

.portal-form-section > p {
    margin: 6px 0 20px;
}

.portal-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}


/* ======================================================
   FORM FIELDS
====================================================== */

.portal-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.portal-field label {
    color: var(--portal-dark);
    font-size: 14px;
    font-weight: 600;
}

.portal-field input[type="text"],
.portal-field input[type="email"],
.portal-field input[type="password"],
.portal-field input[type="number"] {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;

    background: var(--portal-surface);
    color: var(--portal-dark);

    border: 1px solid var(--portal-border);
    border-radius: 8px;

    outline: none;
}

.portal-field input:focus {
    border-color: var(--portal-signature);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.12);
}

.portal-field small {
    color: var(--portal-text-secondary);
    font-size: 12px;
}

.portal-color-field__control {
    display: grid;
    grid-template-columns: 1fr 48px;
    gap: 10px;
}

.portal-color-field input[type="color"] {
    width: 48px;
    height: 42px;
    padding: 3px;

    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: 8px;

    cursor: pointer;
}


/* ======================================================
   BUTTONS AND LINKS
====================================================== */

.portal-button {
    min-height: 42px;
    padding: 10px 18px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    background: var(--portal-signature);
    color: #FFFFFF;

    border: 1px solid var(--portal-signature);
    border-radius: 9px;

    font-weight: 600;
    text-decoration: none;

    cursor: pointer;
    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        transform 0.15s ease;
}

.portal-button:hover {
    background: var(--portal-warm);
    border-color: var(--portal-warm);
}

.portal-button:active {
    transform: translateY(1px);
}

.portal-button--secondary {
    background: var(--portal-surface);
    color: var(--portal-dark);
    border-color: var(--portal-border);
}

.portal-button--secondary:hover {
    background: var(--portal-background);
    border-color: var(--portal-border);
}

.portal-link {
    color: var(--portal-tech);
    font-weight: 600;
    text-decoration: none;
}

.portal-link:hover {
    text-decoration: underline;
}

.portal-link--button {
    padding: 0;
    background: none;
    border: 0;
    cursor: pointer;
}


/* ======================================================
   ALERTS
====================================================== */

.portal-alert {
    margin-bottom: 20px;
    padding: 13px 16px;

    border: 1px solid;
    border-radius: 10px;
}

.portal-alert--success {
    background: rgba(15, 118, 110, 0.08);
    color: var(--portal-tech);
    border-color: rgba(15, 118, 110, 0.25);
}

.portal-alert--error {
    background: rgba(220, 38, 38, 0.07);
    color: #B91C1C;
    border-color: rgba(220, 38, 38, 0.22);
}


/* ======================================================
   PALETTE PREVIEW
====================================================== */

.portal-palette-preview {
    margin-top: 30px;
    padding: 22px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;

    background: var(--portal-background);
    border: 1px solid var(--portal-border);
    border-radius: 12px;
}

.portal-palette-preview h3 {
    margin: 4px 0;
}

.portal-palette-preview p {
    margin: 0;
    color: var(--portal-text-secondary);
}


/* ======================================================
   ACTIONS
====================================================== */

.portal-actions {
    margin-top: 26px;

    display: flex;
    justify-content: flex-end;
    gap: 12px;
}


/* ======================================================
   ERROR
====================================================== */

.portal-error-card {
    width: min(520px, 100%);
    padding: 38px;

    text-align: center;
}

.portal-error-card__code {
    color: var(--portal-signature);
    font-size: 44px;
    font-weight: 800;
}

.portal-error-card h1 {
    margin: 8px 0 10px;
}


/* ======================================================
   BADGES
====================================================== */

.portal-badge {
    padding: 4px 9px;

    display: inline-flex;
    align-items: center;

    background: var(--portal-background);
    color: var(--portal-text-secondary);

    border: 1px solid var(--portal-border);
    border-radius: 999px;

    font-size: 12px;
    font-weight: 600;
}

.portal-badge--success {
    background: rgba(15, 118, 110, 0.08);
    color: var(--portal-tech);
    border-color: rgba(15, 118, 110, 0.2);
}

.portal-badge--warning {
    background: rgba(249, 115, 22, 0.08);
    color: var(--portal-warm);
    border-color: rgba(249, 115, 22, 0.2);
}


/* ======================================================
   EMPTY STATE
====================================================== */

.portal-empty {
    padding: 44px 24px;
    text-align: center;
}

.portal-empty h2 {
    margin: 0 0 8px;
}

.portal-empty p {
    max-width: 520px;
    margin: 0 auto 20px;
    color: var(--portal-text-secondary);
}


/* ======================================================
   HELPERS
====================================================== */

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


/* ======================================================
   FOOTER
====================================================== */

.portal-footer {
    min-height: 58px;
    padding: 16px 24px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    color: var(--portal-text-secondary);
    border-top: 1px solid var(--portal-border);

    font-size: 12px;
}

.portal-footer span + span::before {
    content: "•";
    margin-right: 8px;
}


/* ======================================================
   RESPONSIVE
====================================================== */

@media (max-width: 760px) {

    .portal-header__inner {
        min-height: 70px;
    }

    .portal-brand__logo {
        max-width: 220px;
        height: 44px;
    }

    .portal-page-header {
        flex-direction: column;
    }

    .portal-form-grid {
        grid-template-columns: 1fr;
    }

    .portal-palette-preview {
        align-items: flex-start;
        flex-direction: column;
    }

    .portal-actions {
        justify-content: stretch;
    }

    .portal-actions .portal-button {
        width: 100%;
    }

}


@media (max-width: 560px) {

    .portal-header__inner {
        width: min(100% - 24px, 1180px);
        min-height: 66px;

        flex-direction: row;
        align-items: center;
        gap: 12px;
    }

    .portal-brand {
        min-width: 0;
        flex: 1;
    }

    .portal-brand__logo {
        max-width: min(195px, calc(100vw - 90px));
        height: 40px;
    }

    .portal-profile__trigger {
        min-width: 42px;
        min-height: 42px;
        padding: 1px;
    }

    .portal-profile__chevron {
        display: none;
    }

    .portal-profile__dropdown {
        width: min(290px, calc(100vw - 24px));
    }

    .portal-main {
        width: min(100% - 24px, 1180px);
        padding-top: 22px;
    }

    .portal-form-card {
        padding: 20px;
    }

}
/* ==========================================================================
   BREADCRUMB / CONTEXT BAR
   ========================================================================== */

   .portal-context {
    position: relative;
    z-index: 20;

    width: 100%;
    margin: 0;

    background: var(--portal-surface);

    border-top:
        1px solid
        color-mix(
            in srgb,
            var(--portal-border) 78%,
            var(--portal-tech) 22%
        );

    border-bottom:
        1px solid
        color-mix(
            in srgb,
            var(--portal-border) 78%,
            var(--portal-tech) 22%
        );

    box-shadow:
        0 4px 14px rgba(15, 23, 42, 0.05);

    overflow: hidden;
}


/* Conteúdo interno */

.portal-context__inner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;

    width: min(1200px, calc(100% - 40px));
    min-height: 48px;

    margin: 0 auto;
    padding: 8px 0;

    color: var(--portal-dark);

    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0.01em;
}


/* Links dos níveis anteriores */

.portal-context a {
    position: relative;

    display: inline-flex;
    align-items: center;

    color: var(--portal-dark);

    font-weight: 600;
    text-decoration: none;

    transition:
        color 0.2s ease,
        transform 0.2s ease;
}

.portal-context a:hover {
    color: var(--portal-warm);
    transform: translateY(-1px);
}

.portal-context a:focus-visible {
    outline: 2px solid var(--portal-signature);
    outline-offset: 4px;
    border-radius: 4px;
}


/* Separadores */

.portal-context__inner > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    color: var(--portal-text-secondary);

    font-size: 0.72rem;
    font-weight: 500;

    opacity: 0.7;
}


/* Página atual */

.portal-context strong {
    display: inline-flex;
    align-items: center;

    padding: 0;

    color: var(--portal-warm);
    background: transparent;
    border: 0;
    border-radius: 0;

    font-size: 0.76rem;
    font-weight: 750;
    line-height: 1.4;

    box-shadow: none;
}


/* Integração com o cabeçalho */

.portal-header {
    margin-bottom: 0;
}


/* ==========================================================================
   RESPONSIVO
   ========================================================================== */

@media (max-width: 720px) {

    .portal-context__inner {
        width: calc(100% - 28px);
        min-height: 44px;

        gap: 7px;
        padding: 7px 0;

        font-size: 0.7rem;
    }

    .portal-context__inner > span {
        font-size: 0.68rem;
    }

    .portal-context strong {
        padding: 0;
        font-size: 0.7rem;
    }

}