/* REPORT A PROBLEM — page styles.
   Uses the shared theme tokens, so Light, Dark and AMOLED work without overrides.
   Loaded after admin.css, which still supplies .adm-loading, .empty-state,
   .adm-icon-btn and .adm-spin. */

.rp-page [hidden] {
    display: none !important;
}

/* ── Layout: stacked on phones/tablets/laptops, two columns on wide screens ── */
.rp-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--page-gap, 1rem);
    align-items: start;
}

@media (min-width: 1200px) {
    .rp-layout {
        grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    }
}

/* ── Form ── */
.rp-form {
    margin-top: var(--space-3);
}

.rp-fieldset {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.rp-fieldset:disabled {
    opacity: .75;
}

.rp-field {
    min-width: 0;
}

.rp-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: 6px;
}

.rp-label {
    display: block;
    margin: 0 0 6px;
    color: var(--text);
    font-size: .8rem;
    font-weight: 600;
}

.rp-label-row .rp-label {
    margin: 0;
}

.rp-req {
    color: var(--danger, #fb7185);
}

.rp-count {
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: .7rem;
    white-space: nowrap;
}

.rp-count.is-near {
    color: var(--warning, #f59e0b);
}

.rp-field .form-control,
.rp-field .form-select {
    width: 100%;
    min-height: 2.75rem;
}

.rp-field textarea.form-control {
    min-height: 8rem;
    resize: vertical;
}

.rp-field [aria-invalid="true"] {
    border-color: var(--danger, #fb7185);
}

.rp-hint {
    margin: 6px 0 0;
    color: var(--text-faint);
    font-size: .76rem;
    line-height: 1.4;
}

.rp-error {
    margin: 6px 0 0;
    color: var(--danger, #fb7185);
    font-size: .8rem;
    line-height: 1.4;
}

.rp-form-error {
    display: flex;
    gap: var(--space-2);
    margin: 0;
    padding: var(--space-3);
    border: 1px solid rgba(251, 113, 133, .4);
    border-radius: var(--radius-sm);
    background: rgba(251, 113, 133, .08);
    color: var(--text-soft);
    font-size: .84rem;
    line-height: 1.45;
}

.rp-form-error i {
    flex: 0 0 auto;
    margin-top: 2px;
    color: var(--danger, #fb7185);
}

.rp-success {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-3);
    border: 1px solid rgba(52, 211, 153, .4);
    border-radius: var(--radius-sm);
    background: rgba(52, 211, 153, .08);
    color: var(--text-soft);
    font-size: .84rem;
    line-height: 1.45;
}

.rp-success i {
    flex: 0 0 auto;
    margin-top: 2px;
    color: var(--success, #34d399);
}

.rp-success strong {
    color: var(--text);
    font-family: var(--font-mono);
    font-size: .8rem;
}

.rp-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    width: 100%;
    min-height: 2.75rem;
}

@media (max-width: 720px) {
    /* 16px inputs stop iOS from zooming the page when a field is focused. */
    .rp-field .form-control,
    .rp-field .form-select {
        font-size: 1rem;
    }
}

/* ── Your reports: header ── */
.rp-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.rp-count-pill {
    color: var(--text-faint);
    font-size: .78rem;
    white-space: nowrap;
}

/* ── Your reports: the list adapts to the width of its own card, not the screen ── */
.rp-reports {
    container-type: inline-size;
    min-width: 0;
}

.rp-empty > i {
    display: block;
    margin-bottom: var(--space-2);
    font-size: 1.6rem;
    opacity: .5;
}

.rp-empty p {
    margin: 0;
}

.rp-empty-title {
    color: var(--text-soft);
    font-weight: 600;
}

.rp-empty-hint {
    margin-top: 2px !important;
    font-size: .8rem;
}

.rp-error-box {
    text-align: center;
    padding: var(--space-5) 0;
    color: var(--text-faint);
    font-size: .88rem;
}

.rp-error-box > i {
    display: block;
    margin-bottom: var(--space-2);
    color: var(--danger, #fb7185);
    font-size: 1.4rem;
}

.rp-error-box p {
    margin: 0 0 var(--space-3);
}

/* Wide layout: one row per report */
.rp-table-wrap {
    overflow-x: auto;
}

.rp-list {
    display: none;
    margin: 0;
    padding: 0;
    list-style: none;
}

.rp-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: .86rem;
}

.rp-table th {
    padding: .5rem .6rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: .66rem;
    font-weight: 400;
    letter-spacing: .06em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.rp-table td {
    padding: .7rem .6rem;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
    white-space: nowrap;
}

.rp-row {
    cursor: pointer;
}

.rp-row:hover {
    background: var(--surface-2);
}

.rp-row:last-child td {
    border-bottom: 0;
}

.rp-col-ticket {
    display: none;
    width: 7.5rem;
}

.rp-col-date {
    display: none;
    width: 8.25rem;
}

.rp-col-cat {
    width: 10.5rem;
}

.rp-col-status {
    width: 7.5rem;
}

.rp-col-act {
    width: 3rem;
    text-align: right !important;
}

.rp-col-subject {
    font-weight: 600;
}

.rp-ref {
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: .74rem;
}

@container (min-width: 42rem) {
    .rp-col-date {
        display: table-cell;
    }
}

@container (min-width: 56rem) {
    .rp-col-ticket {
        display: table-cell;
    }
}

/* Category badge */
.rp-badge {
    display: inline-block;
    max-width: 100%;
    padding: 2px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--text-soft);
    font-size: .7rem;
    font-weight: 600;
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
    white-space: nowrap;
}

/* Narrow layout: stacked list, dividers only, no nested cards */
@container (max-width: 29.99rem) {
    .rp-table-wrap {
        display: none;
    }

    .rp-list {
        display: block;
    }
}

.rp-item {
    padding: .85rem 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.rp-item:first-child {
    padding-top: .25rem;
}

.rp-item:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.rp-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .85rem 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.rp-item-main {
    flex: 1 1 auto;
    min-width: 0;
}

.rp-item-subject {
    overflow: hidden;
    color: var(--text);
    font-size: .92rem;
    font-weight: 700;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rp-item-meta {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: .5rem;
    min-width: 0;
    margin-top: .25rem;
    overflow: hidden;
    color: var(--text-faint);
    font-size: .74rem;
    white-space: nowrap;
}

.rp-item-side {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: .5rem;
}

.rp-item-side .rp-badge {
    max-width: 8.5rem;
}

.rp-item-side .adm-icon-btn {
    flex: 0 0 auto;
}

/* ── Report details dialog: always fits inside the viewport ── */
.rp-modal {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - 2rem);
}

.rp-modal-head {
    display: flex;
    flex: 0 0 auto;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.rp-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.rp-detail {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: .5rem 1rem;
    margin: 0 0 var(--space-4);
    font-size: .86rem;
}

.rp-detail dt {
    color: var(--text-faint);
    font-size: .72rem;
    font-weight: 400;
    letter-spacing: .04em;
    text-transform: uppercase;
    align-self: center;
}

.rp-detail dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.rp-detail-subject {
    margin: 0 0 var(--space-2);
    color: var(--text);
    font-size: .92rem;
    font-weight: 700;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.rp-detail-text {
    padding: var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-soft);
    font-size: .88rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.rp-ticket-title {
    font-family: var(--font-mono);
    font-size: .82rem;
}

@media (max-width: 480px) {
    .rp-detail {
        grid-template-columns: minmax(0, 1fr);
        gap: .15rem;
    }

    .rp-detail dd {
        margin-bottom: .5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .rp-row {
        transition: none;
    }
}