/*
 * Etapa 6B-4: Portal do Cliente - shared stylesheet for /entrar/, /criar-conta/,
 * /verificar-email/ and /minha-conta/.
 *
 * Tokens below are taken directly from the WPF app's own Dark theme
 * (IdleHub/Resources/Themes/DarkTheme.xaml) rather than the marketing landing page's palette -
 * the Portal is a functional extension of the product itself, so it should feel like the app,
 * not like the "coming soon" site.
 */

:root {
    --portal-bg: #10131a;
    --portal-surface: #1e242b;
    --portal-surface-elevated: #252c34;
    --portal-border: #303842;
    --portal-border-subtle: #252b33;
    --portal-text: #f3f0ea;
    --portal-text-secondary: #c9c5bc;
    --portal-text-muted: #8e928f;
    --portal-accent: #d7b56d;
    --portal-accent-hover: #e0c17f;
    --portal-accent-pressed: #b8934a;
    --portal-accent-text: #171209;
    --portal-danger: #c0392b;
    --portal-danger-hover: #d8483a;
    --portal-danger-text: #fbeae7;
    --portal-success: #4caf7d;
    --portal-radius: 16px;
    --portal-radius-sm: 10px;
}

* {
    box-sizing: border-box;
}

html {
    background: var(--portal-bg);
}

body.portal-body {
    margin: 0;
    min-height: 100vh;
    min-height: 100svh;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    color: var(--portal-text);
    background: var(--portal-bg);
}

a {
    color: var(--portal-accent);
}

a:hover,
a:focus-visible {
    color: var(--portal-accent-hover);
}

/* Focus visibility - never suppressed, per item 26 of the 6B-4 task. */
a:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--portal-accent);
    outline-offset: 2px;
}

/* ---- Auth pages (entrar/criar-conta/verificar-email) ------------------------------------- */

.portal-auth-shell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100svh;
    padding: clamp(18px, 4vw, 48px);
    gap: 24px;
}

.portal-card {
    width: min(100%, 420px);
    padding: clamp(24px, 5vw, 40px);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    background: var(--portal-surface);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

.portal-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
    text-decoration: none;
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--portal-text);
}

.portal-brand img {
    display: block;
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.portal-title {
    margin: 0 0 6px;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.portal-subtitle {
    margin: 0 0 24px;
    color: var(--portal-text-secondary);
    font-size: 0.9375rem;
    line-height: 1.6;
}

.portal-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* .portal-form's own `display: flex` (author stylesheet) otherwise overrides the browser's
   default `[hidden] { display: none }` (user-agent stylesheet) - without this rule, a form with
   both the `hidden` attribute and this class stays fully visible, overlapping whatever is shown
   next to it (see esqueci-senha/redefinir-senha/verificar-email, which all toggle
   `form.hidden = true` on success). */
.portal-form[hidden] {
    display: none;
}

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

.portal-field label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--portal-text-secondary);
}

.portal-field input {
    padding: 11px 14px;
    border-radius: var(--portal-radius-sm);
    border: 1px solid var(--portal-border);
    background: var(--portal-bg);
    color: var(--portal-text);
    font-size: 0.9375rem;
    font-family: inherit;
}

.portal-field input::placeholder {
    color: var(--portal-text-muted);
}

.portal-field input:focus-visible {
    outline: 2px solid var(--portal-accent);
    outline-offset: 1px;
    border-color: var(--portal-accent);
}

.portal-field-hint {
    font-size: 0.75rem;
    color: var(--portal-text-muted);
}

.portal-button {
    padding: 12px 18px;
    border-radius: var(--portal-radius-sm);
    border: 1px solid transparent;
    font-size: 0.9375rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.portal-button:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.portal-button-primary {
    background: var(--portal-accent);
    color: var(--portal-accent-text);
}

.portal-button-primary:hover:not(:disabled),
.portal-button-primary:focus-visible:not(:disabled) {
    background: var(--portal-accent-hover);
    /* Without this, an <a class="portal-button portal-button-primary"> (e.g. "Já tenho o
       código") falls back to the generic `a:hover { color: ... }` rule above, which beats the
       non-hover .portal-button-primary rule's `color` for specificity - the text turns the same
       gold tone as the hover background and disappears. <button> elements are unaffected (this
       only ever mattered for the secondary/danger variants below, which both already
       redeclared color for exactly this reason). */
    color: var(--portal-accent-text);
}

.portal-button-primary:active:not(:disabled) {
    background: var(--portal-accent-pressed);
    color: var(--portal-accent-text);
}

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

.portal-button-secondary:hover:not(:disabled),
.portal-button-secondary:focus-visible:not(:disabled) {
    border-color: var(--portal-accent);
    color: var(--portal-accent);
}

.portal-button-danger {
    background: transparent;
    border-color: var(--portal-danger);
    color: var(--portal-danger);
}

.portal-button-danger:hover:not(:disabled),
.portal-button-danger:focus-visible:not(:disabled) {
    background: var(--portal-danger);
    color: var(--portal-danger-text);
}

/* Etapa 6B-7G-B: "ou" separator between the password form and "Continuar com Google". */
.portal-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--portal-text-muted);
    font-size: 0.8125rem;
}

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

/* Etapa 6B-7G-B: reuses .portal-button-secondary's colors as-is (no new color token) - only adds
 * the flex layout needed to sit an icon next to the label and stretch to the card's full width,
 * matching a <button> inside .portal-form. */
.portal-button-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    text-decoration: none;
}

.portal-button-google svg {
    flex-shrink: 0;
}

.portal-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 20px;
    font-size: 0.875rem;
}

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

.portal-alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: var(--portal-radius-sm);
    font-size: 0.875rem;
    line-height: 1.5;
    border: 1px solid transparent;
}

.portal-alert-error {
    background: rgba(192, 57, 43, 0.12);
    border-color: rgba(192, 57, 43, 0.35);
    color: #f3b6ae;
}

.portal-alert-success {
    background: rgba(76, 175, 125, 0.12);
    border-color: rgba(76, 175, 125, 0.35);
    color: #a9e3c6;
}

.portal-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    justify-content: center;
    font-size: 0.8125rem;
    color: var(--portal-text-muted);
}

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

.portal-footer a:hover,
.portal-footer a:focus-visible {
    color: var(--portal-accent);
}

/* ---- Dashboard (/minha-conta/) ------------------------------------------------------------ */

.portal-app-shell {
    min-height: 100vh;
    min-height: 100svh;
}

.portal-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px clamp(18px, 4vw, 40px);
    border-bottom: 1px solid var(--portal-border-subtle);
    background: var(--portal-surface);
}

.portal-nav {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 0.9375rem;
    flex-wrap: wrap;
}

.portal-nav-current {
    color: var(--portal-text);
    font-weight: 700;
}

.portal-nav-link {
    color: var(--portal-text-secondary);
    text-decoration: none;
    padding: 6px 2px;
    border-bottom: 2px solid transparent;
}

.portal-nav-link:hover,
.portal-nav-link:focus-visible {
    color: var(--portal-text);
}

.portal-nav-link.is-active {
    color: var(--portal-text);
    font-weight: 700;
    border-bottom-color: var(--portal-accent);
}

.portal-main {
    max-width: 960px;
    margin: 0 auto;
    padding: clamp(20px, 4vw, 40px);
}

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

.portal-panel {
    padding: 24px;
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    background: var(--portal-surface);
}

.portal-panel h2 {
    margin: 0 0 16px;
    font-size: 1.0625rem;
    font-weight: 800;
}

.portal-kv {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 16px;
    margin: 0;
}

.portal-kv dt {
    color: var(--portal-text-muted);
    font-size: 0.8125rem;
    font-weight: 600;
}

.portal-kv dd {
    margin: 0;
    font-size: 0.9375rem;
    text-align: right;
}

.portal-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.portal-badge-success {
    background: rgba(76, 175, 125, 0.16);
    color: #7fdba9;
}

.portal-badge-warning {
    background: rgba(215, 181, 109, 0.16);
    color: var(--portal-accent);
}

.portal-badge-danger {
    background: rgba(192, 57, 43, 0.16);
    color: #e58f84;
}

.portal-empty-entitlement {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.portal-empty-entitlement p {
    margin: 0;
    color: var(--portal-text-secondary);
    line-height: 1.6;
}

.portal-loading {
    padding: 40px;
    text-align: center;
    color: var(--portal-text-muted);
}

.portal-empty-state {
    padding: 12px 0;
    color: var(--portal-text-muted);
    font-size: 0.9375rem;
}

/* ---- Devices / Orders / Subscriptions item cards (6B-5) ------------------------------------ */

.portal-card-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.portal-item-card {
    padding: 18px;
    border: 1px solid var(--portal-border-subtle);
    border-radius: var(--portal-radius-sm);
    background: var(--portal-surface-elevated);
}

.portal-item-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-bottom: 10px;
}

.portal-item-card-title {
    font-weight: 700;
    font-size: 0.9375rem;
}

.portal-item-card-actions {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.portal-item-card-note {
    margin: 14px 0 0;
    font-size: 0.8125rem;
    color: var(--portal-text-muted);
}

/* ---- Device revoke confirmation dialog ------------------------------------------------------ */

.portal-dialog {
    width: min(90vw, 440px);
    padding: 24px;
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    background: var(--portal-surface);
    color: var(--portal-text);
}

.portal-dialog::backdrop {
    background: rgba(6, 8, 11, 0.6);
}

.portal-dialog p {
    margin: 0 0 16px;
    font-size: 0.9375rem;
    line-height: 1.6;
}

.portal-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

@media (max-width: 720px) {
    .portal-grid {
        grid-template-columns: 1fr;
    }

    .portal-kv {
        grid-template-columns: 1fr;
        gap: 2px 0;
    }

    .portal-kv dd {
        text-align: left;
        margin-bottom: 8px;
    }

    .portal-topbar {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .portal-links {
        flex-direction: column;
        align-items: flex-start;
    }
}
