/* File: shared/css/ticket-attachments.css
 *
 * The attachment list, styled once for all three portals.
 *
 * It draws entirely from the ECVALLA design tokens in ecvalla-theme.css — no colour,
 * radius or shadow is written literally here — so the same markup takes on the user
 * portal's, the department desk's and administration's identity without a per-portal
 * copy, and light and dark are handled by the tokens rather than by a second rule set.
 */

.ec-attachment-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ec-attachment {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--sys-border);
    border-radius: 8px;
    background: var(--sys-surface-raised);
    font-size: 13px;
    min-width: 0;
}

.ec-attachment:hover {
    background: var(--sys-surface-hover);
}

.ec-attachment-icon {
    flex: 0 0 auto;
    color: var(--sys-text-muted);
    font-size: 15px;
}

.ec-attachment-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--sys-text-primary);
}

.ec-attachment-meta {
    flex: 0 0 auto;
    color: var(--sys-text-muted);
    font-size: 11.5px;
    /* Sizes and dates are numbers in a list; tabular figures stop them jittering. */
    font-variant-numeric: tabular-nums;
}

.ec-attachment-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 4px;
}

.ec-attachment-btn {
    border: 0;
    background: transparent;
    color: var(--sys-text-secondary);
    cursor: pointer;
    padding: 5px 7px;
    border-radius: 6px;
    font-size: 12.5px;
    line-height: 1;
}

.ec-attachment-btn:hover:not(:disabled) {
    background: var(--sys-surface-selected);
    color: var(--sys-text-primary);
}

.ec-attachment-btn.is-danger:hover:not(:disabled) {
    color: var(--sys-action-destructive);
}

.ec-attachment-btn:disabled {
    opacity: 0.55;
    cursor: default;
}

.ec-attachment-btn:focus-visible {
    outline: 2px solid var(--sys-focus-ring);
    outline-offset: 1px;
}

/* --- Upload states -------------------------------------------------------------
 *
 * Four states, told apart at a glance rather than by reading: in progress (a filling
 * bar), waiting on the server (the bar full and indeterminate), done, failed. The
 * failed row keeps the file name, because "which one failed" is the first question.
 */

.ec-upload-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.ec-upload {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border: 1px solid var(--sys-border);
    border-radius: 8px;
    background: var(--sys-surface-secondary);
    font-size: 12.5px;
}

.ec-upload-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ec-upload-state {
    flex: 0 0 auto;
    color: var(--sys-text-muted);
    font-variant-numeric: tabular-nums;
}

.ec-upload.is-failed {
    border-color: var(--sys-state-error);
}

.ec-upload.is-failed .ec-upload-state {
    color: var(--sys-state-error);
}

.ec-upload.is-done .ec-upload-state {
    color: var(--sys-state-success);
}

.ec-upload-bar {
    flex: 0 0 96px;
    height: 4px;
    border-radius: 2px;
    background: var(--sys-skeleton-base);
    overflow: hidden;
}

.ec-upload-bar > span {
    display: block;
    height: 100%;
    width: 0;
    background: var(--sys-action-primary);
    transition: width 0.18s ease-out;
}

/* Handed to the server and waiting on Microsoft: there is no percentage to show any
 * more, so the bar says "still working" instead of pretending to advance. */
.ec-upload.is-processing .ec-upload-bar > span {
    width: 100%;
    animation: ec-upload-pulse 1.1s ease-in-out infinite;
}

@keyframes ec-upload-pulse {
    0%, 100% { opacity: 0.45; }
    50%      { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .ec-upload-bar > span { transition: none; animation: none; }
}

.ec-attachment-empty {
    color: var(--sys-text-muted);
    font-size: 12.5px;
    margin: 6px 0 0;
}

/* Arabic reverses the reading order; the actions belong at the reading end either way,
 * which flex handles as long as nothing is pinned to a physical side. */
[dir="rtl"] .ec-attachment-name,
[dir="rtl"] .ec-upload-name {
    text-align: right;
}
