/* Component: attachment */

.sm-attachment-group { display: grid; gap: 10px; }

.sm-attachment {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--sm-line);
    border-radius: 12px;
    background: #fff;
}

.sm-attachment[hidden] { display: none; }

.sm-attachment--vertical { flex-direction: column; align-items: stretch; }

.sm-attachment--sm { padding: 8px 10px; gap: 10px; }

.sm-attachment--error { border-color: var(--sm-danger); background: var(--sm-danger-soft); }

.sm-attachment--done { border-color: var(--sm-success); }

.sm-attachment__thumb,
.sm-attachment__icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    align-self: center;
    background: var(--sm-soft);
    color: var(--sm-muted);
    flex-shrink: 0;
    overflow: hidden;
}

.sm-attachment--sm .sm-attachment__thumb,
.sm-attachment--sm .sm-attachment__icon { width: 34px; height: 34px; }

.sm-attachment__thumb img { width: 100%; height: 100%; object-fit: cover; }

.sm-attachment__body { flex: 1 1 auto; min-width: 0; }

.sm-attachment__title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--sm-ink);
    line-height: 1.35;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

.sm-attachment--sm .sm-attachment__title { font-size: 13px; }

.sm-attachment__desc { margin: 2px 0 0; font-size: 12px; color: var(--sm-muted); }

.sm-attachment__error { margin: 6px 0 0; font-size: 12px; color: var(--sm-danger); }

.sm-attachment__progress { margin-top: 8px; display: grid; gap: 4px; }

.sm-attachment__progress-meta { font-size: 11px; color: var(--sm-muted); }

.sm-attachment__remove,
.sm-attachment__action {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    align-self: center;
    border: 0;
    background: transparent;
    color: var(--sm-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    text-decoration: none;
    line-height: 1;
}

.sm-attachment__remove:hover { color: var(--sm-danger); background: var(--sm-danger-soft); }

.sm-attachment__action:hover,
.sm-attachment__action:focus { color: var(--sm-accent); background: var(--sm-accent-soft); }

/* Disabled / empty slot (upload icon on the right) */

.sm-attachment--disabled {
    border-style: dashed;
    background: var(--sm-soft);
}

.sm-attachment--disabled .sm-attachment__title,
.sm-attachment--disabled .sm-attachment__desc { color: var(--sm-muted); }

.sm-attachment--disabled .sm-attachment__icon { background: #fff; opacity: .7; }

.sm-attachment--empty { border-style: dashed; background: var(--sm-soft); }

.sm-attachment--empty .sm-attachment__title { color: var(--sm-muted); font-weight: 500; }

/* Form file field (sm_ui_attachment_field) */
.sm-attachment-field { position: relative; display: grid; gap: 8px; }

.sm-attachment-field .sm-attachment--empty { cursor: pointer; }

.sm-attachment-field__input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
}

.sm-attachment-field:focus-within .sm-attachment--empty { border-color: var(--sm-accent); }

.sm-attachment-field__camera-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.sm-attachment-field__camera-actions[hidden] { display: none !important; }

.sm-attachment-field__camera-actions .sm-btn .dashicons {
    width: 16px;
    height: 16px;
    font-size: 16px;
    margin-inline-end: 4px;
    vertical-align: text-bottom;
}

.sm-attachment-field__list,
.sm-attachment-field__existing-list {
    display: grid;
    gap: 8px;
}

.sm-attachment-field__list[hidden],
.sm-attachment-field__existing-list[hidden] { display: none !important; }

.sm-attachment-field__add-more {
    justify-self: start;
}

.sm-attachment-field__add-more[hidden] { display: none !important; }

.sm-attachment-field__add-more .dashicons {
    width: 16px;
    height: 16px;
    font-size: 16px;
    margin-inline-end: 4px;
    vertical-align: text-bottom;
}

/* Take-photo camera modal */
.sm-camera-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: grid;
    place-items: center;
    padding: 16px;
}

.sm-camera-modal[hidden] { display: none !important; }

.sm-camera-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgb(15 23 42 / 55%);
}

.sm-camera-modal__dialog {
    position: relative;
    width: min(100%, 420px);
    background: #fff;
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 20px 50px rgb(0 0 0 / 25%);
}

.sm-camera-modal__title {
    margin: 0 0 12px;
    font-size: 16px;
    font-weight: 700;
}

.sm-camera-modal__video-wrap {
    border-radius: 10px;
    overflow: hidden;
    background: #0f172a;
    aspect-ratio: 4 / 3;
}

.sm-camera-modal__video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sm-camera-modal__error {
    margin: 10px 0 0;
    font-size: 13px;
    color: var(--sm-danger, #b91c1c);
}

.sm-camera-modal__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
