/**
 * Customer dashboard — form entries.
 * The Form entries app on the site page (list, one entry, confirm dialog), the unread badge on its
 * tab and the "N new form entries" line on the site cards.
 *
 * Built on the customer portal's tokens (theme tokens.css) and .tfs-btn / .tfs-empty-state.
 *
 * @package TFS_Site_Manager
 * @since 2.20.0
 */

.tfs-fe-app .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.tfs-fe-app {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border-default);
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* One minimum height for loading, a short list and the empty state, so the panel never jumps between
   them: the empty state's own height (~280px: 2 x 60px padding, 3em icon, heading, text) plus the
   header/toolbar above it (~70px). */
.tfs-fe-content {
    min-height: 360px;
}

.tfs-fe-loading {
    margin: 0;
    padding: 30px 0;
    text-align: center;
    color: var(--color-text-muted);
}

.tfs-fe-content.tfs-fe-busy {
    opacity: 0.6;
    pointer-events: none;
}

/* Errors and messages — the dashboard's danger / success notice colours */
.tfs-fe-message {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.tfs-fe-message[hidden] {
    display: none;
}

.tfs-fe-message-success {
    background: var(--color-bg-success-subtle);
    color: var(--color-text-success);
}

.tfs-fe-message-error {
    background: var(--color-bg-danger-subtle);
    color: var(--color-text-danger);
}

.tfs-fe-error {
    padding: 14px 16px;
    border-radius: 6px;
    background: var(--color-bg-danger-subtle);
    color: var(--color-text-danger);
}

.tfs-fe-error p {
    margin: 0 0 12px;
}

.tfs-fe-notice {
    padding: 14px 16px;
    border-radius: 6px;
    background: var(--color-bg-surface-muted);
    color: var(--color-text-muted);
}

/* Header + toolbar */
.tfs-fe-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--w4l-brand);
}

/* On the Form entries page the h1 is the heading: the toolbar alone sits at the right. */
.tfs-fe-header-bare {
    justify-content: flex-end;
}

.tfs-fe-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    color: var(--color-text-default);
}

.tfs-fe-count {
    padding: 3px 10px;
    border-radius: 12px;
    background: var(--color-bg-danger-subtle);
    color: var(--color-text-danger);
    font-size: 13px;
    font-weight: 600;
}

.tfs-fe-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.tfs-fe-select {
    padding: 7px 10px;
    border: 1px solid var(--color-border-default);
    border-radius: 4px;
    background: var(--color-bg-surface);
    color: var(--color-text-default);
    font-size: 14px;
}

/* List — a table wider than the card scrolls inside the wrapper instead of squeezing its columns */
.tfs-fe-table-wrap {
    max-width: 100%;
    overflow-x: auto;
}

.tfs-fe-table {
    width: 100%;
    border-collapse: collapse;
}

/* Same header and cell type as the other dashboard tables (tickets.css .tfs-tickets-table, the billing table). */
.tfs-fe-table th {
    background: var(--color-bg-surface-muted);
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 600;
    white-space: nowrap;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border-default);
}

.tfs-fe-table td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--color-border-default);
    vertical-align: top;
    max-width: 280px;
    overflow-wrap: break-word;
    word-break: normal;
    color: var(--color-text-default);
}

/* Form and Received never wrap: a short label or date on one line keeps the rows short. */
.tfs-fe-table td.tfs-fe-col-form,
.tfs-fe-table td.tfs-fe-date {
    white-space: nowrap;
    overflow-wrap: normal;
}

.tfs-fe-table tbody tr:hover {
    background: var(--color-bg-surface-hover);
}

/* Unread: the dot plus the name in bold, like a mail inbox — not the whole row. */
.tfs-fe-unread td .tfs-fe-open {
    font-weight: 600;
}

.tfs-fe-col-status {
    width: 20px;
    padding-right: 0 !important;
}

.tfs-fe-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-top: 6px;
    border-radius: 50%;
    background: var(--w4l-brand);
}

a.tfs-fe-open {
    color: var(--color-text-link);
    text-decoration: none;
}

a.tfs-fe-open:hover {
    color: var(--color-text-link-hover);
    text-decoration: underline;
}

.tfs-fe-date {
    white-space: nowrap;
    color: var(--color-text-muted);
}

.tfs-fe-col-actions {
    width: 100px;
    white-space: nowrap;
}

.tfs-fe-actions {
    display: flex;
    gap: 5px;
}

.tfs-fe-icon-btn {
    background: transparent;
    border: 1px solid var(--color-border-strong);
    padding: 5px 8px;
    border-radius: 3px;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.tfs-fe-icon-btn:hover {
    background: var(--color-bg-surface-hover);
}

/* Pagination */
.tfs-fe-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

.tfs-fe-pagination-info {
    color: var(--color-text-muted);
    font-size: 14px;
}

.tfs-fe-pagination-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.tfs-fe-page-btn {
    padding: 6px 12px;
    border: 1px solid var(--color-border-strong);
    background: var(--color-bg-surface);
    color: var(--color-text-default);
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}

.tfs-fe-page-btn:hover {
    border-color: var(--w4l-brand);
    color: var(--w4l-brand);
}

.tfs-fe-page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: var(--color-border-strong);
    color: var(--color-text-default);
}

.tfs-fe-page-btn.active {
    background: var(--w4l-brand);
    border-color: var(--w4l-brand);
    color: var(--color-text-inverse);
}

/* Notification mail status */
.tfs-fe-mail {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 500;
}

.tfs-fe-mail-sent {
    background: var(--color-bg-success-subtle);
    color: var(--color-text-success);
}

.tfs-fe-mail-failed {
    background: var(--color-bg-danger-subtle);
    color: var(--color-text-danger);
}

.tfs-fe-mail-pending {
    background: var(--color-bg-info-subtle);
    color: var(--color-text-info);
}

.tfs-fe-mail-skipped {
    background: var(--color-bg-surface-muted);
    color: var(--color-text-muted);
}

.tfs-fe-mail-error {
    display: block;
    margin-top: 6px;
    color: var(--color-text-danger);
    font-size: 13px;
}

/* One entry */
.tfs-fe-meta,
.tfs-fe-fields {
    margin: 0 0 24px;
}

.tfs-fe-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 40px;
    padding: 16px;
    background: var(--color-bg-surface-muted);
    border-radius: 4px;
}

.tfs-fe-meta dt,
.tfs-fe-field dt {
    margin: 0 0 4px;
    color: var(--color-text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tfs-fe-meta dd,
.tfs-fe-field dd {
    margin: 0;
    color: var(--color-text-default);
    font-size: 14px;
    overflow-wrap: anywhere;
}

.tfs-fe-field {
    padding: 14px 0;
    border-bottom: 1px solid var(--color-border-default);
}

.tfs-fe-field:last-child {
    border-bottom: none;
}

.tfs-fe-empty {
    color: var(--color-text-subtle);
    font-style: italic;
}

/* Confirm dialog */
.tfs-fe-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: var(--color-bg-overlay);
}

.tfs-fe-modal-box {
    width: 100%;
    max-width: 420px;
    padding: 24px;
    background: var(--color-bg-surface);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.tfs-fe-modal-box h3 {
    margin: 0 0 10px;
    font-size: 18px;
    color: var(--color-text-default);
}

.tfs-fe-modal-box p {
    margin: 0 0 20px;
    color: var(--color-text-muted);
    font-size: 14px;
}

.tfs-fe-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Tab badge and site-card line */
.tfs-fe-badge {
    display: inline-block;
    min-width: 20px;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 10px;
    background: var(--color-bg-brand);
    color: var(--color-text-on-brand);
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
}

.tfs-fe-badge[hidden],
.tfs-fe-card[hidden] {
    display: none;
}

.tfs-fe-card a {
    color: var(--color-text-link);
}

.tfs-fe-card-has-new a {
    font-weight: 600;
    color: var(--color-text-danger);
}

@media (max-width: 768px) {
    .tfs-fe-app {
        padding: 20px;
    }

    .tfs-fe-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
