/**
 * UploadMate Frontend Styles
 * 
 * @package UploadMate
 * @since 1.0.0
 */

/* Main container */
.uploadmate-container {
    margin: 20px 0;
    padding: 0;
    clear: both;
    width: 100%;
    font-family: inherit;
}

.uploadmate-field-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Label styling */
.uploadmate-label {
    font-weight: 600;
    font-size: 16px;
    color: #333;
    margin-bottom: 0;
    display: block;
}

.uploadmate-label .required {
    color: #e74c3c;
    margin-left: 2px;
}

/* Standard file input */
.uploadmate-standard-area .uploadmate-file-input {
    padding: 12px 15px;
    border: 2px solid #6ec1e4;
    border-radius: 8px;
    background: #fafdff;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
}

.uploadmate-standard-area .uploadmate-file-input:hover {
    border-color: #5ba8c7;
    background: #f0f9fc;
}

.uploadmate-standard-area .uploadmate-file-input:focus {
    outline: none;
    border-color: #4a90a4;
    box-shadow: 0 0 0 3px rgba(106, 193, 228, 0.15);
}

/* Drag and drop area */
.uploadmate-drag-drop-area {
    border: 2px dashed #6ec1e4;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    background: #fafdff;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.uploadmate-drag-drop-area:hover,
.uploadmate-drag-drop-area.dragover {
    border-color: #4a90a4;
    background: #f0f9fc;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(106, 193, 228, 0.2);
}

.uploadmate-drag-drop-area.dragover {
    border-style: solid;
    background: #e8f6fa;
}

.uploadmate-drag-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    pointer-events: none;
}

.uploadmate-drag-icon {
    font-size: 48px;
    opacity: 0.7;
    transition: transform 0.3s ease;
}

.uploadmate-drag-drop-area:hover .uploadmate-drag-icon {
    transform: scale(1.05);
}

.uploadmate-drag-text {
    font-size: 16px;
    color: #555;
    line-height: 1.4;
    font-weight: 500;
}

.uploadmate-drag-text span {
    color: #888;
    font-size: 14px;
    font-weight: normal;
}

.uploadmate-browse-btn {
    background: linear-gradient(135deg, #6ec1e4 0%, #5ba8c7 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    pointer-events: auto;
    box-shadow: 0 2px 4px rgba(106, 193, 228, 0.3);
}

.uploadmate-browse-btn:hover {
    background: linear-gradient(135deg, #5ba8c7 0%, #4a90a4 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(106, 193, 228, 0.4);
}

.uploadmate-browse-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(106, 193, 228, 0.3);
}

/* File info text */
.uploadmate-info {
    font-size: 13px;
    color: #21807c;
    line-height: 1.5;
}

.uploadmate-file-limit {
    font-weight: 600;
    display: block;
    margin-bottom: 2px;
}

.uploadmate-allowed-types {
    opacity: 0.9;
    font-size: 12px;
}

/* Preview area */
.uploadmate-preview-area {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.uploadmate-preview-area:empty {
    display: none !important;
}

/* Preview items */
.uploadmate-preview-item,
.uploadmate-ajax-preview-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.2s ease;
}

.uploadmate-preview-item:last-child,
.uploadmate-ajax-preview-item:last-child {
    border-bottom: none;
}

.uploadmate-preview-item:hover,
.uploadmate-ajax-preview-item:hover {
    background-color: rgba(106, 193, 228, 0.05);
    border-radius: 4px;
    margin: 0 -8px;
    padding-left: 20px;
    padding-right: 20px;
}

.uploadmate-preview-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6ec1e4 0%, #5ba8c7 100%);
    color: white;
    border-radius: 6px;
    font-size: 10px;
    font-weight: bold;
    text-align: center;
    line-height: 1;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(106, 193, 228, 0.3);
}

.uploadmate-preview-info {
    flex: 1;
    min-width: 0;
}

.uploadmate-preview-name {
    font-weight: 600;
    color: #333;
    font-size: 14px;
    line-height: 1.3;
    word-break: break-word;
    margin-bottom: 2px;
}

.uploadmate-preview-size {
    color: #666;
    font-size: 12px;
    line-height: 1;
}

.uploadmate-remove-file {
    color: #e74c3c;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    padding: 4px 6px;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
    line-height: 1;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.uploadmate-remove-file:hover {
    background: #fdf2f2;
    color: #c0392b;
    transform: scale(1.1);
}

/* Progress bar for AJAX uploads */
.uploadmate-progress-bar {
    width: 100%;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 6px;
    transition: all 0.3s ease;
}

.uploadmate-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6ec1e4 0%, #5ba8c7 100%);
    border-radius: 2px;
    transition: width 0.3s ease;
    position: relative;
}

.uploadmate-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: progressShimmer 2s infinite;
}

@keyframes progressShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.uploadmate-progress-success .uploadmate-progress-fill {
    background: linear-gradient(90deg, #27ae60 0%, #2ecc71 100%);
}

.uploadmate-progress-error .uploadmate-progress-fill {
    background: linear-gradient(90deg, #e74c3c 0%, #c0392b 100%);
}

/* Upload status indicators */
.uploadmate-upload-success {
    background: rgba(39, 174, 96, 0.05);
    border-left: 3px solid #27ae60;
    margin-left: -18px;
    padding-left: 30px;
}

.uploadmate-upload-error {
    background: rgba(231, 76, 60, 0.05);
    border-left: 3px solid #e74c3c;
    margin-left: -18px;
    padding-left: 30px;
}

/* Message styles */
.uploadmate-error-message {
    color: #e74c3c;
    background: #fdf2f2;
    border: 1px solid #e74c3c;
    padding: 12px 15px;
    border-radius: 6px;
    margin: 10px 0;
    font-size: 14px;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 8px;
}

.uploadmate-error-message::before {
    content: '⚠️';
    font-size: 16px;
    flex-shrink: 0;
}

.uploadmate-success-message {
    color: #27ae60;
    background: #f2fdf4;
    border: 1px solid #27ae60;
    padding: 12px 15px;
    border-radius: 6px;
    margin: 10px 0;
    font-size: 14px;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 8px;
}

.uploadmate-success-message::before {
    content: '✅';
    font-size: 16px;
    flex-shrink: 0;
}

/* Cart and checkout integration */
.woocommerce-cart-form__cart-item .uploadmate-files-list,
.woocommerce-checkout-review-order-table .uploadmate-files-list {
    max-width: 250px;
}

.uploadmate-files-list {
    margin: 8px 0;
}

.uploadmate-file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
    padding: 6px 8px;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.3;
    border-left: 3px solid #6ec1e4;
}

.uploadmate-file-icon {
    font-size: 14px;
    min-width: 16px;
    flex-shrink: 0;
}

.uploadmate-file-name,
.uploadmate-file-link {
    flex: 1;
    color: #333;
    text-decoration: none;
    font-weight: 500;
    min-width: 0;
    word-break: break-word;
}

.uploadmate-file-link:hover {
    color: #0073aa;
    text-decoration: underline;
}

.uploadmate-file-size {
    color: #666;
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Mini cart widget styles */
.widget_shopping_cart .uploadmate-files-list {
    font-size: 11px;
    margin: 4px 0;
}

.widget_shopping_cart .uploadmate-file-item {
    display: block !important;
    gap: 6px;
    margin: 2px 0;
    padding: 4px 6px;
    font-size: 11px;
}

.widget_shopping_cart .uploadmate-file-icon {
    font-size: 12px;
    min-width: 14px;
}

/* Responsive design */
@media (max-width: 768px) {
    .uploadmate-drag-drop-area {
        padding: 30px 15px;
    }
    
    .uploadmate-drag-icon {
        font-size: 36px;
    }
    
    .uploadmate-drag-text {
        font-size: 14px;
    }
    
    .uploadmate-browse-btn {
        padding: 10px 20px;
        font-size: 13px;
    }
    
    .uploadmate-preview-item,
    .uploadmate-ajax-preview-item {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .uploadmate-preview-info {
        min-width: 120px;
    }
    
    .uploadmate-file-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .uploadmate-file-name,
    .uploadmate-file-link {
        word-break: break-all;
    }
}

@media (max-width: 480px) {
    .uploadmate-container {
        margin: 15px 0;
    }
    
    .uploadmate-drag-drop-area {
        padding: 20px 10px;
    }
    
    .uploadmate-drag-icon {
        font-size: 28px;
    }
    
    .uploadmate-preview-item,
    .uploadmate-ajax-preview-item {
        padding: 8px 0;
    }
    
    .uploadmate-preview-icon {
        width: 32px;
        height: 32px;
        font-size: 9px;
    }
    
    .uploadmate-preview-name {
        font-size: 13px;
    }
    
    .uploadmate-preview-size {
        font-size: 11px;
    }
}

/* Ensure cart form layout is maintained */
.cart .quantity {
    display: inline-block !important;
    width: auto !important;
    margin-right: 15px !important;
    margin-bottom: 0 !important;
    vertical-align: top !important;
}

.cart .single_add_to_cart_button {
    display: inline-block !important;
    width: auto !important;
    vertical-align: top !important;
}

.cart {
    display: inline-table !important;
    width:100% !important;
}

.cart .cart-actions,
.cart > div:last-child {
    /* display: inline-block !important; */
    width: auto !important;
}
dl.variation{
    flex-direction: column!important;
    display: flex!important;
}

@media (max-width: 768px) {
    .cart .quantity {
        display: block !important;
        width: 100% !important;
        margin-bottom: 15px !important;
        margin-right: 0 !important;
    }
    
    .cart .single_add_to_cart_button {
        display: block !important;
        width: 100% !important;
    }
}

/* Animation utilities */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-10px); }
}

.uploadmate-preview-area {
    animation: fadeIn 0.3s ease;
}

.uploadmate-error-message,
.uploadmate-success-message {
    animation: fadeIn 0.3s ease;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .uploadmate-drag-drop-area {
        border-color: #000;
        background: #fff;
    }
    
    .uploadmate-browse-btn {
        background: #000;
        color: #fff;
        border: 2px solid #000;
    }
    
    .uploadmate-preview-icon {
        background: #000;
        color: #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .uploadmate-drag-drop-area,
    .uploadmate-browse-btn,
    .uploadmate-remove-file,
    .uploadmate-progress-fill,
    .uploadmate-preview-item,
    .uploadmate-ajax-preview-item {
        transition: none;
    }
    
    .uploadmate-progress-fill::after {
        animation: none;
    }
    
    .uploadmate-preview-area,
    .uploadmate-error-message,
    .uploadmate-success-message {
        animation: none;
    }
}

/* Focus styles for accessibility */
.uploadmate-browse-btn:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.uploadmate-remove-file:focus {
    outline: 2px solid #e74c3c;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .uploadmate-container {
        display: none;
    }
}