/* The drawer: the detail of the selected entry or note. Closed until something is chosen, and then it opens on
   the right, next to the tiles on a wide screen, over them on a medium one, and over everything on a phone. */

.pv-drawer {
    display: none;
    width: var(--drawer-width);
    min-height: 0;
    overflow-y: auto;
    border-left: 1px solid var(--border-subtle);
    background: var(--bg-sidebar);
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.pv-page[data-vault-detail="open"] .pv-drawer {
    display: block;
}

.pv-detail {
    padding: var(--space-5);
}

.pv-detail[hidden] {
    display: none;
}

/* --- The head ------------------------------------------------------------------------------------------------ */

.pv-detail__head {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.pv-detail__identity {
    display: grid;
    justify-items: start;
    gap: var(--space-1);
    flex: 1;
    min-width: 0;
}

.pv-detail__identity h2 {
    max-width: 100%;
    margin: 0;
    overflow: hidden;
    font-size: var(--type-subtitle);
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pv-detail__close {
    order: 3;
    margin-left: auto;
}

.pv-detail__close-narrow {
    display: none;
}

.pv-detail__meta {
    margin: 0 0 var(--space-4);
    color: var(--text-tertiary);
    font-size: var(--type-caption);
}

/* --- The fields ---------------------------------------------------------------------------------------------- */

.pv-fields {
    margin: 0;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-tile);
    background: var(--surface-1);
}

.pv-field {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}

.pv-field:last-child {
    border-bottom: 0;
}

.pv-field[hidden] {
    display: none;
}

.pv-field dt {
    margin-bottom: var(--space-1);
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.pv-field dd {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    min-width: 0;
    margin: 0;
    color: var(--text-primary);
    font-size: var(--type-body);
}

.pv-field__value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pv-field--block dd {
    display: block;
    color: var(--text-secondary);
    line-height: 1.6;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.pv-field--block dd.pv-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

/* The password: a mask until it is revealed, and then the text itself in the monospace face. */
.pv-secret {
    flex: 1;
    min-width: 0;
    color: var(--text-secondary);
    font-size: 1rem;
    letter-spacing: 0.12em;
    overflow-wrap: anywhere;
}

.pv-secret.is-revealed {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    letter-spacing: 0;
    word-break: break-all;
}

/* The seconds a revealed password has left. */
.pv-timer {
    flex: 0 0 auto;
    color: var(--accent-text);
    font-size: var(--type-caption);
    font-variant-numeric: tabular-nums;
}

.pv-timer[hidden] {
    display: none;
}

.pv-feedback {
    min-height: 20px;
    margin: var(--space-3) 0 0;
    color: var(--danger-text);
    font-size: var(--type-caption);
    line-height: 1.5;
}

.pv-feedback.is-positive {
    color: var(--success);
}

/* A 409: the owner picks, so both choices sit side by side, neither one styled as the "default". */
.pv-conflict {
    display: grid;
    gap: var(--space-2);
    margin-top: var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--danger-text);
    border-radius: var(--radius-tile);
}

.pv-conflict p {
    margin: 0;
    color: var(--danger-text);
    font-size: var(--type-caption);
}

.pv-conflict[hidden] {
    display: none;
}

/* A note: its text as written, wrapped, never reformatted. */
.pv-note {
    margin: 0;
    padding: var(--space-4);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-tile);
    background: var(--surface-1);
    color: var(--text-secondary);
    font: inherit;
    font-size: var(--type-body);
    line-height: 1.7;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

/* --- Sizes --------------------------------------------------------------------------------------------------- */

/* Medium: the drawer floats over the right edge instead of taking room from the tiles. */
@media (max-width: 1100px) {
    .pv-drawer {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 5;
        box-shadow: -12px 0 32px var(--shadow-color);
    }

    .pv-app {
        position: relative;
    }
}

/* Narrow: a full screen over everything, with a way back where the thumb is. */
@media (max-width: 720px) {
    .pv-drawer {
        position: fixed;
        inset: 0;
        z-index: 20;
        width: auto;
        border-left: 0;
        box-shadow: none;
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .pv-detail__close {
        order: -1;
        margin-left: 0;
    }

    .pv-detail__close-wide {
        display: none;
    }

    .pv-detail__close-narrow {
        display: inline-flex;
    }
}

/* Em orientação horizontal e com pouca altura, o detalhe também ocupa o ecrã todo para manter os controlos acessíveis. */
@media (max-width: 1100px) and (max-height: 480px) and (orientation: landscape) {
    .pv-drawer {
        position: fixed;
        inset: 0;
        z-index: 20;
        width: auto;
        border-left: 0;
        box-shadow: none;
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .pv-detail__close { order: -1; margin-left: 0; }
    .pv-detail__close-wide { display: none; }
    .pv-detail__close-narrow { display: inline-flex; }
}
