/**
 * File attribute widget — self-contained, theme-portable styling.
 *
 * Everything is scoped under .file-upload so it renders consistently on any
 * storefront theme, with no external dependency beyond the Font Awesome
 * bundle every theme already loads. JS (file-attribute.js) drives the
 * dropzone/preview toggling and the upload itself.
 */

/*
 * Hardened against full-reset host themes (e.g. DriveGo's unprefixed Tailwind
 * v4 build, preflight included): box-sizing and the load-bearing layout
 * properties below are forced with `!important` so this widget renders the
 * same regardless of whatever base/reset rules the host page ships.
 */
.file-upload,
.file-upload * {
    box-sizing: border-box;
}

.file-upload {
    position: relative;
}

.file-upload input[type="file"] {
    position: absolute !important;
    display: block !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap;
    border: 0;
}

/*
 * .file-upload__dropzone/.file-upload__preview both set an explicit
 * `display: flex` below, which — being an author rule — otherwise beats the
 * browser's default `[hidden] { display: none }` (origin wins over
 * specificity in the cascade). Restate it here so JS toggling the `hidden`
 * attribute actually hides them.
 */
.file-upload__dropzone[hidden],
.file-upload__preview[hidden] {
    display: none !important;
}

.file-upload__dropzone {
    /* Specificity-proof: some host themes' own layout rules (grid/flex
       children, `a`/`label` resets) can otherwise collapse this stack. */
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center;
    gap: 6px;
    width: auto;
    text-align: center;
    padding: 28px 20px;
    margin: 0;
    margin-bottom: 14px !important;
    border: 1px dashed #d9e0ea;
    border-radius: 11px;
    background-color: #fff;
    cursor: pointer;
    font-weight: normal;
    line-height: normal;
    transition: border-color .15s ease, background-color .15s ease;
}

.file-upload__dropzone:hover,
.file-upload__dropzone.is-dragover {
    border-color: #888888;
    background-color: rgba(37, 99, 235, .05);
}

.file-upload input[type="file"]:focus + .file-upload__dropzone {
    outline: none;
    border-color: #888888;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

.file-upload__icon {
    width: 26px !important;
    height: 26px !important;
    color: #888888;
}

.file-upload__cta {
    font-size: 14px;
    color: #0f172a;
}

.file-upload__cta strong {
    color: #888888;
    text-decoration: underline;
}

.file-upload__hint {
    font-size: 12px;
    color: #9aa6b6;
}

.file-upload__preview {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 12px;
    width: auto;
    padding: 12px 14px;
    border: 1px solid #d9e0ea;
    border-radius: 11px;
    background-color: #fff;
    margin-bottom: 14px;
}

.file-upload__preview.file-upload--success {
    border-color: #888888;
    background-color: rgba(37, 99, 235, .05);
}

.file-upload__preview.file-upload--error {
    border-color: #e2574c;
    background-color: rgba(226, 87, 76, .06);
}

.file-upload__file-icon {
    font-size: 20px;
    color: #888888;
    flex-shrink: 0;
}

.file-upload__preview.file-upload--error .file-upload__file-icon {
    color: #e2574c;
}

.file-upload__thumb {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #d9e0ea;
}

.file-upload__file-details {
    flex: 1;
    min-width: 0;
    display: flex !important;
    flex-direction: column !important;
}

.file-upload__file-name {
    font-size: 14px;
    font-weight: bold;
    color: #0f172a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

a.file-upload__file-name:hover {
    color: #888888;
    text-decoration: underline;
}

.file-upload__file-status {
    font-size: 12px;
    color: #9aa6b6;
}

.file-upload__preview.file-upload--error .file-upload__file-status {
    color: #e2574c;
}

.file-upload__remove {
    /* Reset hard: host themes that give every plain <button> a default
       filled/full-width look (a common Tailwind-base-layer pattern) would
       otherwise turn this into a giant colored pill. */
    all: unset;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: auto !important;
    height: auto !important;
    box-sizing: border-box;
    border: none;
    border-radius: 6px;
    background: none !important;
    color: #9aa6b6;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 4px 8px;
}

.file-upload__remove:hover {
    color: #e2574c;
}
