/**
 * DIVI File Upload - Frontend Styles
 *
 * @package Divi_File_Upload
 */

/* File Upload Wrapper */
.divi-file-upload-wrapper {
    margin: 10px 0;
    width: 100%;
}

/* Dropzone */
.divi-file-upload-dropzone {
    position: relative;
    border: 2px dashed #d3d3d3;
    border-radius: 4px;
    background: #fafafa;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.divi-file-upload-dropzone:hover {
    border-color: #2ea3f2;
    background: #f0f9ff;
}

.divi-file-upload-dropzone.dragover {
    border-color: #2ea3f2;
    background: #e3f2fd;
    transform: scale(1.02);
}

/* File Input */
.divi-file-upload-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Placeholder */
.divi-file-upload-placeholder {
    pointer-events: none;
}

.divi-file-upload-icon {
    display: block;
    font-size: 48px;
    color: #2ea3f2;
    margin-bottom: 10px;
}

.divi-file-upload-text {
    display: block;
    font-size: 14px;
    color: #666;
}

/* File List */
.divi-file-upload-list {
    margin-top: 15px;
}

/* File Item */
.divi-file-upload-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin-bottom: 10px;
    transition: all 0.2s ease;
}

.divi-file-upload-item:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.divi-file-upload-item.uploaded {
    border-color: #4caf50;
    background: #f1f8f4;
}

.divi-file-upload-item.error {
    border-color: #f44336;
    background: #ffebee;
}

/* File Item Name */
.divi-file-upload-item-name {
    flex: 1;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 10px;
}

/* File Item Size */
.divi-file-upload-item-size {
    font-size: 12px;
    color: #999;
    margin-right: 10px;
    white-space: nowrap;
}

/* File Item Progress */
.divi-file-upload-item-progress {
    flex: 0 0 100px;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    margin-right: 10px;
    overflow: hidden;
    position: relative;
}

.divi-file-upload-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: #2ea3f2;
    transition: width 0.3s ease;
}

.divi-file-upload-item.uploaded .divi-file-upload-progress-bar {
    background: #4caf50;
}

.divi-file-upload-item.error .divi-file-upload-progress-bar {
    background: #f44336;
}

/* File Item Status */
.divi-file-upload-item-status {
    font-size: 12px;
    color: #999;
    margin-right: 10px;
    white-space: nowrap;
}

.divi-file-upload-item-status.success {
    color: #4caf50;
    font-weight: bold;
}

.divi-file-upload-item-status.error {
    color: #f44336;
    font-weight: bold;
}

/* Remove Button */
.divi-file-upload-item-remove {
    background: transparent;
    border: none;
    color: #999;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.divi-file-upload-item-remove:hover {
    color: #f44336;
}

/* Error Container */
.divi-file-upload-error {
    display: none;
    margin-top: 10px;
    padding: 10px 15px;
    background: #ffebee;
    border: 1px solid #f44336;
    border-radius: 4px;
    color: #c62828;
    font-size: 14px;
}

.divi-file-upload-error.visible {
    display: block;
}

/* DIVI Contact Form Integration */
.et_pb_contact_field[data-type="file_upload"] {
    width: 100%;
}

.et_pb_contact_field[data-type="file_upload"] label {
    display: block;
    margin-bottom: 10px;
}

/* Required Mark */
.et_pb_contact_field[data-type="file_upload"] .required {
    color: #f44336;
}

/* Responsive */
@media (max-width: 768px) {
    .divi-file-upload-dropzone {
        padding: 20px 15px;
    }

    .divi-file-upload-icon {
        font-size: 36px;
    }

    .divi-file-upload-text {
        font-size: 13px;
    }

    .divi-file-upload-item {
        flex-wrap: wrap;
        padding: 10px;
    }

    .divi-file-upload-item-name {
        flex: 1 1 100%;
        margin-bottom: 5px;
    }

    .divi-file-upload-item-progress {
        flex: 1 1 auto;
    }
}

@media (max-width: 480px) {
    .divi-file-upload-item-size,
    .divi-file-upload-item-status {
        display: none;
    }

    .divi-file-upload-item-progress {
        flex: 1 1 auto;
        margin-right: 5px;
    }
}

/* Animation */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.divi-file-upload-item {
    animation: slideIn 0.3s ease;
}

/* Visual Builder Compatibility */
.et-fb .divi-file-upload-wrapper {
    pointer-events: auto;
}

/* Admin View in CFDB7 */
.divi-uploaded-files {
    margin: 10px 0;
}

.divi-uploaded-file-item {
    padding: 5px 0;
}

.divi-file-download {
    color: #2ea3f2;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.divi-file-download:hover {
    text-decoration: underline;
}

.divi-file-size {
    color: #999;
    font-size: 12px;
    margin-left: 5px;
}

/* Loading State */
.divi-file-upload-item.loading .divi-file-upload-item-progress {
    position: relative;
    overflow: visible;
}

.divi-file-upload-item.loading .divi-file-upload-progress-bar {
    animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
    0% {
        left: -100%;
        width: 100%;
    }
    50% {
        left: 100%;
        width: 100%;
    }
    100% {
        left: 100%;
        width: 0;
    }
}

/* Accessibility */
.divi-file-upload-input:focus + .divi-file-upload-placeholder {
    outline: 2px solid #2ea3f2;
    outline-offset: 2px;
}

.divi-file-upload-item-remove:focus {
    outline: 2px solid #2ea3f2;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .divi-file-upload-dropzone,
    .divi-file-upload-item-remove,
    .divi-file-upload-item-progress {
        display: none;
    }

    .divi-file-upload-item {
        border: none;
        padding: 5px 0;
    }
}
