/* ==========================================================================
   ATTACHMENTS STYLES
   Styles for attachment gallery, list view, upload, and media elements
   ========================================================================== */

/* --------------------------------------------------------------------------
   Media Group & Single
   -------------------------------------------------------------------------- */
.media-single {
    width: 100%;
}

.media-image {
    display: block;
    max-width: 100%;
    margin: auto;
}

.image-center,
.video-center {
    display: block;
    margin: 0 auto;
    max-width: 100%;
}

.media-video {
    margin-left: auto;
    margin-right: auto;
    object-fit: contain;
    width: 100%;
    height: 100%;
}

.media-group {
    display: flex;
    flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Attachments Container
   -------------------------------------------------------------------------- */
.attachments {
    margin-top: 20px;
    margin-bottom: 20px;
}

.attachments-zone {
    position: relative;
}

/* --------------------------------------------------------------------------
   File Card Base
   -------------------------------------------------------------------------- */
.file {
    color: #172b4d;
    height: 125px;
    max-height: 100%;
    width: 156px;
    max-width: 100%;
    cursor: pointer;
    position: relative;
    margin: 4px 4px;
    box-shadow: rgba(9, 30, 66, 0.2) 0 1px 1px, rgba(9, 30, 66, 0.24) 0 0 1px 0;
    border-radius: 3px;
    background: rgb(244, 245, 247);
}

.file:hover {
    color: rgb(207, 220, 242);
}

.file-wrapper {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    justify-content: space-between;
    flex-direction: column;
    padding: 16px;
    border-radius: 3px;
    word-break: break-word;
}

.file-title {
    font-size: 12px;
    white-space: initial;
}

.file-title:hover {
    color: rgb(0, 82, 204);
}

.file-bottom {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.file-bytes {
    overflow: hidden;
    text-overflow: ellipsis;
}

.file:hover .file-wrapper {
    background-color: rgba(9, 30, 66, 0.7);
}

.file:hover .file-title {
    color: white;
}

.file:hover .file-bytes {
    color: rgb(207, 220, 242);
}

/* --------------------------------------------------------------------------
   Image Attachment
   -------------------------------------------------------------------------- */
.file.image {
    background-repeat: no-repeat;
    background-position: center;
}

.image-full {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    color: white;
}

.file:hover .image-full {
    background-color: rgba(9, 30, 66, 0.7);
    visibility: visible;
}

.image-wrapper {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    justify-content: space-between;
    flex-direction: column;
    padding: 16px;
    border-radius: 3px;
    overflow: hidden;
    visibility: hidden;
}

.file:hover .image-full .image-wrapper {
    visibility: visible;
}

.image-title {
    transition: transform 0.2s ease 0s, opacity 0.5s ease 0s;
    transform: translateY(-35px);
    font-size: 12px;
}

.file:hover .image-full .image-wrapper .image-title {
    transform: translateY(0px);
}

.image-bottom {
    transition: transform 0.2s ease 0s, opacity 0.5s ease 0s;
    transform: translateY(35px);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.file:hover .image-full .image-wrapper .image-bottom {
    transform: translateY(0px);
}

.image-bytes {
    color: rgb(207, 220, 242);
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   Video Attachment
   -------------------------------------------------------------------------- */
.video-full {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    color: #FFF;
}

div.video-full:hover {
    background-color: rgba(9, 30, 66, 0.7);
    visibility: visible;
    cursor: pointer;
}

.video-wrapper {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    justify-content: space-between;
    flex-direction: column;
    padding: 16px;
    border-radius: 3px;
    visibility: hidden;
}

div.video-full:hover .video-wrapper {
    visibility: visible;
}

.video-title {
    transition: transform 0.2s ease 0s, opacity 0.5s ease 0s;
    font-size: 12px;
    overflow-wrap: break-word;
    overflow-y: auto;
}

.video-bottom {
    transition: transform .2s ease 0s, opacity .5s ease 0s;
    display: flex;
    justify-content: space-between;
}

/* --------------------------------------------------------------------------
   Download & Delete Buttons
   -------------------------------------------------------------------------- */
.icon-downland {
    color: white;
}

.icon-downland:hover {
    color: #0052cc;
}

.gallery-download-button {
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.gallery-download-button:hover {
    color: #0052cc;
}

.delete-attachment-button {
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.delete-attachment-button svg {
    fill: #FFFFFF;
    transition: fill 0.2s ease-in-out;
}

.delete-attachment-button:hover svg {
    fill: #0052cc;
}

/* --------------------------------------------------------------------------
   Inline File Attachment
   -------------------------------------------------------------------------- */
.file-inline {
    height: 20px;
    width: fit-content;
    max-width: 32ch;
    display: flex;
    flex-direction: row;
    border: 1px solid var(--border-color);
    align-items: center;
    gap: 4px;
    padding: 4px;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(9, 30, 66, 0.25), 0 0 1px 1px rgba(9, 30, 66, 0.13);
    cursor: pointer;

    & > * {
        color: var(--link-color);
    }

    & button {
        border-radius: 4px;
        padding: 2px 4px !important;
    }
}

/* --------------------------------------------------------------------------
   Attachment View Toggle & Action Buttons
   -------------------------------------------------------------------------- */
#toggle-attachments-view-button {
    color: rgb(23, 43, 77);
    background: transparent;
    border: none;
    cursor: pointer;
}

#download-all-button {
    cursor: pointer;
    background: var(--ds-background-neutral-subtle);
    border: 1px solid var(--ds-border);
    padding: 4px 8px;
    border-radius: 4px;
    color: var(--ds-text-subtle);

    &:hover {
        background-color: var(--ds-background-neutral-subtle-hovered);
    }
}

.attachment-action-buttons {
    margin-top: 8px;
    gap: 8px;
    display: flex;
    align-items: flex-start;
}

/* --------------------------------------------------------------------------
   Attachment List View
   -------------------------------------------------------------------------- */
.attachment-list-view {
    display: flex;
    flex-direction: column;
    gap: 8px;

    &:has(.delete-attachment-button) .list-info.header {
        padding-inline-end: 80px;
    }
}

.attachment-list-view .list-header,
.attachment-list-view .attachment-list-item {
    display: grid;
    grid-template-columns: 2.5rem 1fr 180px 100px 120px;
    align-items: center;
    gap: 12px;
}

.attachment-list-view .list-header {
    font-weight: 600;
    padding: 6px 8px;
}

.attachment-list-view .attachment-list-item {
    padding: 6px 8px;
}

.attachment-list-view .attachment-list-item .list-info {
    display: contents;
}

.attachment-list-view .list-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-start;
}

.attachment-list-view .list-actions > * {
    flex: 0 0 auto;
}

.attachment-list-view .list-thumbnail,
.attachment-list-view .list-thumbnail-placeholder,
.attachment-list-view video {
    width: 2.5rem;
    height: 2.5rem;
    object-fit: cover;
}

.attachment-list-item {
    display: flex;
    align-items: center;
    padding: 8px;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(9, 30, 66, 0.2);
    background: rgba(22, 26, 29, 0.14);
    gap: 12px;
    cursor: pointer;
}

.attachment-list-item:hover {
    background: #cbd2da;
}

.list-thumbnail,
.list-thumbnail-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    background: #dfe1e6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #456;
}

.list-info {
    flex-grow: 1;
    overflow: hidden;
    display: grid;
    grid-template-columns: 4fr 2fr 1fr;
    gap: 8px;

    &.header {
        color: #44546F;
        font-weight: 600;
        padding-inline-start: 60px;
        padding-inline-end: 44px;
    }
}

.list-filename {
    white-space: nowrap;
    max-width: 64ch;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-filesize {
    font-size: 12px;
    color: #44546F;
}

/* --------------------------------------------------------------------------
   Upload Form & Input
   -------------------------------------------------------------------------- */
.upload-attachment-form {
    margin-top: 15px;
    margin-bottom: 15px;
}

.upload-attachment-form-content {
    display: flex;
}

.upload-attachment-form-content label {
    padding-top: 5px;
    margin-right: 4px;
}

.inputfile {
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    position: absolute;
    z-index: -1;
}

.inputfile + label {
    font-style: normal;
    font-weight: normal;
    font-size: 14px;
    height: 2.28571em;
    line-height: 2.28571em;
    background: rgba(9, 30, 66, 0.04);
    border-radius: 3px;
    border-width: 0;
    color: rgb(80, 95, 121) !important;
    outline: none;
    padding: 8px;
}

.inputfile:focus + label,
.inputfile + label:hover {
    background: rgba(9, 30, 66, 0.08);
    cursor: pointer;
}

.inputfile:focus + label {
    outline: hidden !important;
    border: 2px solid rgb(76, 154, 255);
}

.inputfile + label * {
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   Upload Container & Overlay
   -------------------------------------------------------------------------- */
.upload-attachment-container {
    box-sizing: border-box;
    border-radius: 3px;
}

.upload-attachment-container-child {
    display: flex;
    justify-content: center;
    align-items: center;
}

.upload-attachment-container-child:hover {
    cursor: pointer;
}

.upload-attachment-info-container {
    margin-left: 15px;
    margin-top: 14px;
}

.upload-attachment-icon {
    width: 140px;
}

.upload-attachment-button-container {
    margin-top: 8px;
}

.upload-attachment-info-child {
    color: rgb(108, 121, 143);
    margin-top: 0;
    font-size: 12px;
}

.upload-attachment-info-child.small {
    color: rgb(108, 121, 143);
    font-size: 12px;
}

.upload-overlay {
    display: none;
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    z-index: 100;
    background: rgba(205, 217, 244, 0.36);
    box-sizing: border-box;
    border: 2px dashed rgb(207, 212, 219);
    border-radius: 3px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.upload-overlay.visible {
    display: flex;
    border: 2px dashed rgb(22, 94, 204);
    border-radius: 3px;
}

.upload-attachment-container-drop-info {
    display: flex;
    flex-direction: column;
    font-size: 16px;
    color: #172B4D;
    margin-top: -4px;
}

.upload-attachment-container-bg {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 15px;
    border-radius: 8px;
    background-color: white;
    border: 1px solid #e4e4e6;
    position: fixed;
    bottom: 80px;
}

.upload-disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
}

/* --------------------------------------------------------------------------
   Upload Progress
   -------------------------------------------------------------------------- */
.upload-info-list-progress-summary {
    margin-top: 5px;
    padding: 10px;
    min-width: 320px;
}

.upload-info-list-progress-item {
    margin-top: 5px;
    border: 2px dashed rgb(207, 212, 219);
    border-radius: 3px;
    padding: 10px;
}

.upload-info-list-progress-item.active {
    border-color: rgb(45, 116, 223);
}

.upload-info-list-progress-item.done {
    border-color: rgb(17, 208, 119);
}

.upload-info-list-progress-item.error {
    border-color: rgb(227, 75, 68);
}

.upload-info-list-progress-item-info {
    display: flex;
    justify-content: space-between;
}

/* --------------------------------------------------------------------------
   Upload Animation
   -------------------------------------------------------------------------- */
.slide-bottom {
    -webkit-animation: slide-bottom 0.4s both;
    animation: slide-bottom 0.4s both;
}

@-webkit-keyframes slide-bottom {
    0% {
        -webkit-transform: translateY(40px);
        transform: translateY(40px);
        opacity: 0;
    }
    100% {
        -webkit-transform: translateX(0px);
        transform: translateX(0px);
        opacity: 1;
    }
}

@keyframes slide-bottom {
    0% {
        -webkit-transform: translateY(40px);
        transform: translateY(40px);
        opacity: 0;
    }
    100% {
        -webkit-transform: translateX(0px);
        transform: translateX(0px);
        opacity: 1;
    }
}

/* --------------------------------------------------------------------------
   Progress Bar (for upload)
   -------------------------------------------------------------------------- */
.aui-progress-indicator {
    background: rgba(9, 30, 66, 0.13);
    border-radius: 3px;
    height: 6px;
    overflow: hidden;
    position: relative;
    width: 100%;
}

.aui-progress-indicator-value {
    display: block;
    height: 6px;
    position: absolute;
    animation: none;
    left: 0;
    background: #42526E;
    border-radius: 3px;
    transition: width 0.05s;
}

/* --------------------------------------------------------------------------
   PDF Container (attachment variant)
   -------------------------------------------------------------------------- */
.pdf-container {
    cursor: pointer;
    display: inline-block;
    margin-right: 10px;
    position: relative;
}

.pdf-file-name {
    display: block;
    text-align: center;
    width: 156px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pdf-file-name-tooltip::after {
    content: attr(data-title);
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px;
    background-color: #000;
    color: #fff;
    white-space: nowrap;
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.pdf-container:hover .pdf-file-name-tooltip::after {
    opacity: 1;
}

/* --------------------------------------------------------------------------
   Image Wrap (description images)
   -------------------------------------------------------------------------- */
.image-wrap img[name="image-attachment"] {
    cursor: pointer;
}
