/**
 * Attachment Widget Styles
 */

/* Dropzone customization */
.attachment-dropzone {
    min-height: 120px;
    border: 2px dashed var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    background: var(--bs-light);
    transition: all 0.2s ease;
    cursor: pointer;
}

.attachment-dropzone:hover {
    border-color: var(--bs-primary);
    background: rgba(var(--bs-primary-rgb), 0.05);
}

.attachment-dropzone.dz-drag-hover {
    border-color: var(--bs-primary);
    background: rgba(var(--bs-primary-rgb), 0.1);
}

.attachment-dropzone.dz-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.attachment-dropzone .dz-message {
    margin: 0;
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
}

.attachment-dropzone .dz-preview {
    margin: 10px;
}

/* Hide default dropzone previews - we use our own list */
.attachment-dropzone .dz-preview {
    display: none;
}

/* Attachment list */
.attachment-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    margin-bottom: 5px;
    background: var(--bs-white);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    transition: all 0.2s ease;
}

.attachment-item:hover {
    border-color: var(--bs-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Ghost state during drag */
.attachment-ghost {
    opacity: 0.4;
    background: var(--bs-light);
}

.attachment-chosen {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Drag handle */
.attachment-drag-handle {
    cursor: grab;
    color: var(--text-muted);
    padding: 5px;
}

.attachment-drag-handle:hover {
    color: var(--color-primary-500);
}

.attachment-drag-handle:active {
    cursor: grabbing;
}

/* Preview */
.attachment-preview {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bs-light);
    border-radius: var(--bs-border-radius);
    overflow: hidden;
    flex-shrink: 0;
}

.attachment-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Info */
.attachment-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.attachment-name {
    display: flex;
    align-items: center;
    gap: 5px;
}

.attachment-caption {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-caption-input {
    max-width: 200px;
}

.attachment-edit-btn {
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s;
}

.attachment-item:hover .attachment-edit-btn {
    opacity: 1;
}

.attachment-edit-btn:hover {
    color: var(--color-primary-500);
}

.attachment-meta {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Visibility toggle - ensure text is readable when selected */
.attachment-visibility-control .btn-check:checked + .btn .text-muted {
    color: rgba(255, 255, 255, 0.75) !important;
}

/* Actions */
.attachment-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.attachment-visibility-btn,
.attachment-delete-btn {
    opacity: 0.6;
    transition: opacity 0.2s;
}

.attachment-visibility-btn:hover,
.attachment-delete-btn:hover {
    opacity: 1;
}

/* Counter */
.attachment-counter {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Allowed extensions hint */
.attachment-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Empty state */
.attachment-empty {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

/* Card header actions */
.attachment-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Dark mode support */
[data-bs-theme="dark"] .attachment-dropzone {
    background: var(--bs-dark);
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .attachment-dropzone:hover {
    background: rgba(var(--bs-primary-rgb), 0.1);
}

[data-bs-theme="dark"] .attachment-item {
    background: var(--bs-dark);
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .attachment-preview {
    background: rgba(255, 255, 255, 0.05);
}

/* Public widget styles */
.attachments-widget {
    margin: 20px 0;
}

.attachments-widget .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.attachments-widget .attachment-count {
    font-weight: normal;
    color: var(--text-secondary);
}

.attachment-download-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--bs-border-color);
}

.attachment-download-item:last-child {
    border-bottom: none;
}

.attachment-download-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bs-light);
    border-radius: var(--bs-border-radius);
    margin-right: 12px;
    flex-shrink: 0;
}

.attachment-download-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--bs-border-radius);
}

.attachment-download-info {
    flex: 1;
    min-width: 0;
}

.attachment-download-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.attachment-download-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.attachment-download-btn {
    flex-shrink: 0;
    margin-left: 12px;
}

/* Grid layout for images */
.attachments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    padding: 10px;
}

.attachment-grid-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--bs-border-radius);
    overflow: hidden;
    background: var(--bs-light);
}

.attachment-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.attachment-grid-item:hover img {
    transform: scale(1.05);
}

.attachment-grid-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: white;
    font-size: 0.75rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.attachment-grid-item:hover .attachment-grid-overlay {
    opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .attachment-item {
        flex-wrap: wrap;
    }

    .attachment-info {
        flex-basis: calc(100% - 100px);
    }

    .attachment-actions {
        flex-basis: 100%;
        justify-content: flex-end;
        margin-top: 5px;
    }
}

/* Sidebar layout styles */
.attachments-widget-sidebar {
    margin: 0;
}

.attachments-widget-sidebar .card-body {
    padding: 0 !important;
}

.attachment-sidebar-item {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    padding: 10px 12px;
    border-bottom: 1px solid var(--bs-border-color);
    gap: 12px;
}

.attachment-sidebar-item:last-child {
    border-bottom: none;
}

.attachment-sidebar-icon {
    width: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: var(--bs-light);
    border-radius: var(--bs-border-radius);
    flex-shrink: 0;
    overflow: hidden;
}

.attachment-sidebar-icon i {
    font-size: 1.25rem;
    line-height: 1;
}

.attachment-sidebar-icon img {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px;
    min-height: 40px;
    max-width: 40px;
    max-height: 40px;
    object-fit: cover;
    display: block;
}

.attachment-sidebar-info {
    flex: 1 1 auto !important;
    min-width: 0;
    overflow: hidden;
}

.attachment-sidebar-name {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.attachment-sidebar-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.3;
}

.attachment-sidebar-btn {
    flex-shrink: 0 !important;
    margin-left: auto;
}

/* Sidebar dark mode */
[data-bs-theme="dark"] .attachment-sidebar-icon {
    background: rgba(255, 255, 255, 0.05);
}
