/* Custom styles for Uppy integration */

/* ==========================================================================
   Drop Zone Styling - Modern, Clean Visual Affordances
   ========================================================================== */

.uppy-upload-container {
    margin-bottom: 1rem;
    font-family: inherit;
}

/* Drop Zone Base Styling */
.uppy-drop-zone {
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    background-color: #f9fafb;
    padding: 2rem;
    text-align: center;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    margin-bottom: 1rem;
}

/* Drop Zone Hover State */
.uppy-drop-zone:hover {
    border-color: #9ca3af;
    background-color: #f3f4f6;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Drop Zone Active State (when dragging files over) */
.uppy-drop-zone.uppy-drop-active {
    border-color: #3b82f6;
    background-color: #eff6ff;
    border-style: solid;
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.15);
}

/* Drop Zone Content */
.uppy-drop-zone-content {
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Drop Zone Icon */
.uppy-drop-zone-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: opacity 0.2s ease-in-out;
}

.uppy-drop-zone:hover .uppy-drop-zone-icon,
.uppy-drop-zone.uppy-drop-active .uppy-drop-zone-icon {
    opacity: 0.8;
}

/* Drop Zone Text */
.uppy-drop-zone-text {
    font-size: 1rem;
    color: #6b7280;
    margin-bottom: 8px;
    font-weight: 500;
    transition: color 0.2s ease-in-out;
}

.uppy-drop-zone:hover .uppy-drop-zone-text {
    color: #4b5563;
}

.uppy-drop-zone.uppy-drop-active .uppy-drop-zone-text {
    color: #3b82f6;
    font-weight: 600;
}

/* Browse Button */
.uppy-browse-button {
    color: #3b82f6;
    text-decoration: underline;
    background: none;
    border: none;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    padding: 2px 4px;
    border-radius: 2px;
    transition: all 0.2s ease-in-out;
}

.uppy-browse-button:hover {
    color: #2563eb;
    background-color: rgba(59, 130, 246, 0.1);
    text-decoration: none;
}

/* File Input Container */
.uppy-file-input-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
}

.uppy-file-input-container input[type="file"] {
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* Allowed Types Information */
.uppy-allowed-types {
    font-size: 0.875rem;
    color: #6b7280;
    margin-top: 8px;
    font-style: italic;
    line-height: 1.4;
}

/* ==========================================================================
   Container States
   ========================================================================== */

/* Required Field State */
.uppy-upload-container.uppy-required .uppy-drop-zone {
    border-color: #f59e0b;
}

.uppy-upload-container.uppy-required .uppy-drop-zone:hover {
    border-color: #d97706;
}

/* Error State */
.uppy-upload-container.uppy-has-error .uppy-drop-zone {
    border-color: #ef4444;
    background-color: #fef2f2;
}

.uppy-upload-container.uppy-has-error .uppy-drop-zone:hover {
    border-color: #dc2626;
    background-color: #fef2f2;
}

/* Validation Message */
.uppy-validation-message {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: none;
    line-height: 1.4;
}

.uppy-upload-container.uppy-has-error .uppy-validation-message {
    display: block;
}

/* ==========================================================================
   Accessibility and Focus States
   ========================================================================== */

/* Focus States for Accessibility */
.uppy-drop-zone:focus-within {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-color: #3b82f6;
}

.uppy-browse-button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 2px;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 640px) {
    .uppy-drop-zone {
        padding: 1.5rem 1rem;
        min-height: 100px;
    }
    
    .uppy-drop-zone-icon {
        width: 40px;
        height: 40px;
        margin-bottom: 8px;
    }
    
    .uppy-drop-zone-text {
        font-size: 0.875rem;
    }
    
    .uppy-allowed-types {
        font-size: 0.8125rem;
    }
}

@media (max-width: 480px) {
    .uppy-drop-zone {
        padding: 1rem;
        min-height: 80px;
    }
    
    .uppy-drop-zone-text {
        font-size: 0.8125rem;
    }
}

/* ==========================================================================
   File List Styling - Unordered List with Clear Status Indicators
   ========================================================================== */

/* File List Base Styling */
.uppy-file-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0 0 0;
    border-radius: 6px;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    max-height: 300px;
    overflow-y: auto;
}

.uppy-file-list:empty {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: none !important;
    min-height: 0 !important;
}

/* Additional rule to hide file list when it has no file items */
.uppy-file-list:not(:has(.uppy-file-item)) {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: none !important;
    min-height: 0 !important;
}

/* Individual File Item */
.uppy-file-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    background-color: #ffffff;
    transition: all 0.2s ease-in-out;
    position: relative;
    min-height: 60px;
}

.uppy-file-item:last-child {
    border-bottom: none;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}

.uppy-file-item:first-child {
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

.uppy-file-item:hover {
    background-color: #f9fafb;
}

/* File Information Section */
.uppy-file-info {
    flex: 1;
    min-width: 0; /* Allows text truncation */
    margin-right: 1rem;
}

.uppy-file-name {
    display: block;
    font-weight: 500;
    color: #1f2937;
    font-size: 0.875rem;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.uppy-file-size {
    display: block;
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 2px;
    font-weight: normal;
}

/* File Status Section */
.uppy-file-status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 120px;
    margin-right: 0.75rem;
}

.uppy-file-status-text {
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 4px;
    text-align: right;
    white-space: nowrap;
}

/* Progress Container */
.uppy-file-progress-container {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 100px;
}

.uppy-file-progress {
    flex: 1;
    height: 6px;
    background-color: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.uppy-file-progress-bar {
    height: 100%;
    background-color: #3b82f6;
    border-radius: 3px;
    transition: width 0.3s ease-in-out;
    width: 0%;
}

.uppy-file-progress-percentage {
    font-size: 0.6875rem;
    color: #6b7280;
    font-weight: 500;
    min-width: 32px;
    text-align: right;
}

/* Remove Button */
.uppy-file-remove {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    font-size: 1.125rem;
    font-weight: bold;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.2s ease-in-out;
    line-height: 1;
    min-width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.uppy-file-remove:hover {
    background-color: #fee2e2;
    color: #dc2626;
    transform: scale(1.1);
}

.uppy-file-remove:focus {
    outline: 2px solid #ef4444;
    outline-offset: 1px;
}

/* ==========================================================================
   File Status Indicators
   ========================================================================== */

/* Ready State (Default) */
.uppy-file-item {
    border-left: 4px solid #e5e7eb;
}

.uppy-file-item .uppy-file-status-text {
    color: #6b7280;
}

/* Uploading State */
.uppy-file-item.uppy-file-uploading {
    border-left-color: #3b82f6;
    background-color: #eff6ff;
}

.uppy-file-item.uppy-file-uploading .uppy-file-status-text {
    color: #3b82f6;
}

.uppy-file-item.uppy-file-uploading .uppy-file-progress-bar {
    background-color: #3b82f6;
    animation: pulse-progress 1.5s ease-in-out infinite;
}

.uppy-file-item.uppy-file-uploading .uppy-file-progress-percentage {
    color: #3b82f6;
    font-weight: 600;
}

/* Completed State */
.uppy-file-item.uppy-file-completed {
    border-left-color: #10b981;
    background-color: #f0fdf4;
}

.uppy-file-item.uppy-file-completed .uppy-file-status-text {
    color: #10b981;
}

.uppy-file-item.uppy-file-completed .uppy-file-progress-bar {
    background-color: #10b981;
}

.uppy-file-item.uppy-file-completed .uppy-file-progress-percentage {
    color: #10b981;
    font-weight: 600;
}

.uppy-file-item.uppy-file-completed .uppy-file-remove {
    color: #10b981;
}

.uppy-file-item.uppy-file-completed .uppy-file-remove:hover {
    background-color: #dcfce7;
    color: #059669;
}

/* Failed State */
.uppy-file-item.uppy-file-failed {
    border-left-color: #ef4444;
    background-color: #fef2f2;
}

.uppy-file-item.uppy-file-failed .uppy-file-status-text {
    color: #ef4444;
    font-size: 0.6875rem; /* Smaller text for error messages */
    line-height: 1.2;
    max-width: 120px;
    word-wrap: break-word;
}

.uppy-file-item.uppy-file-failed .uppy-file-progress-bar {
    background-color: #ef4444;
}

.uppy-file-item.uppy-file-failed .uppy-file-progress-percentage {
    color: #ef4444;
    font-weight: 600;
}

.uppy-file-item.uppy-file-failed .uppy-file-remove {
    color: #ef4444;
}

.uppy-file-item.uppy-file-failed .uppy-file-remove:hover {
    background-color: #fee2e2;
    color: #dc2626;
}

/* ==========================================================================
   File List Animations
   ========================================================================== */

/* Progress bar pulse animation for uploading files */
@keyframes pulse-progress {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
    100% {
        opacity: 1;
    }
}

/* File item slide-in animation when added */
.uppy-file-item {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Responsive File List Design
   ========================================================================== */

@media (max-width: 640px) {
    .uppy-file-item {
        padding: 0.5rem 0.75rem;
        flex-wrap: wrap;
        min-height: auto;
    }
    
    .uppy-file-info {
        flex: 1 1 100%;
        margin-right: 0;
        margin-bottom: 0.5rem;
    }
    
    .uppy-file-status {
        flex: 1 1 auto;
        align-items: flex-start;
        margin-right: 0.5rem;
        min-width: 100px;
    }
    
    .uppy-file-progress-container {
        min-width: 80px;
    }
    
    .uppy-file-remove {
        align-self: flex-start;
        margin-top: 2px;
    }
}

@media (max-width: 480px) {
    .uppy-file-list {
        margin-top: 0.75rem;
    }
    
    .uppy-file-item {
        padding: 0.5rem;
    }
    
    .uppy-file-name {
        font-size: 0.8125rem;
    }
    
    .uppy-file-size {
        font-size: 0.6875rem;
    }
    
    .uppy-file-status-text {
        font-size: 0.6875rem;
    }
    
    .uppy-file-progress {
        height: 5px;
    }
    
    .uppy-file-progress-percentage {
        font-size: 0.625rem;
        min-width: 28px;
    }
}

/* ==========================================================================
   Form Integration Styles - Match Existing PublicPages Design
   ========================================================================== */

/* Align Uppy container with existing form field styling */
.uppy-upload-container {
    font-family: Arial, Helvetica, Sans-Serif; /* Match body font */
    font-size: 12px; /* Match existing form elements */
    line-height: 18px; /* Match existing line height */
    margin-bottom: 1em; /* Match .RadUpload margin */
}

/* Integrate drop zone sizing with existing form inputs */
.uppy-drop-zone {
    /* Use similar width to existing .textbox elements, but allow for wider content */
    max-width: 500px; /* Match textarea width */
    font-size: 12px; /* Match form element font size */
}

/* Match existing label styling for file information */
.uppy-file-name {
    font-family: Arial, Helvetica, Sans-Serif;
    font-size: 12px;
    line-height: 18px;
}

/* Match existing validation message styling */
.uppy-validation-message {
    color: Red; /* Match .invalid color */
    font-size: 12px; /* Match body font size */
    line-height: 18px; /* Match body line height */
    margin-top: 0.5rem;
}

/* Ensure browse button matches existing link styling */
.uppy-browse-button {
    color: black; /* Match existing link color */
    font-family: Arial, Helvetica, Sans-Serif;
    font-size: 12px;
}

.uppy-browse-button:hover {
    color: #2563eb; /* Keep modern hover color for better UX */
}

/* Integrate with existing form layout patterns */
.uppy-upload-container label {
    font-weight: bold; /* Match existing label styling */
    margin-top: 0.5em; /* Match existing label margin */
    line-height: 20px; /* Match existing label line height */
    display: block; /* Match .label, .longlabel styling */
    font-size: 12px; /* Match body font size */
}

/* Match file size text with existing description styling */
.uppy-file-size {
    font-family: Arial, Helvetica, Sans-Serif;
    font-size: 12px;
    color: #6b7280; /* Maintain subtle color for file size */
}

/* Match existing button styling for remove buttons */
.uppy-file-remove {
    font-family: Arial, Helvetica, Sans-Serif;
    font-size: 12px;
}

/* Ensure progress text matches form styling */
.uppy-file-status-text,
.uppy-file-progress-percentage {
    font-family: Arial, Helvetica, Sans-Serif;
    font-size: 12px;
}

/* Match existing allowed types info with description styling */
.uppy-allowed-types {
    font-family: Arial, Helvetica, Sans-Serif;
    font-size: 12px;
    line-height: 18px;
    color: #6b7280; /* Maintain subtle color */
    margin-top: 8px;
    font-style: italic; /* Match .booleanItemLabel italic style */
}

/* Integration with existing invalid states */
.uppy-upload-container.uppy-has-error {
    /* Add consistent spacing with other invalid form elements */
    margin-bottom: 16px; /* Match textarea margin-bottom */
}

.uppy-upload-container.uppy-has-error .uppy-validation-message {
    /* Match existing .invalid.fileUpload positioning */
    white-space: nowrap;
    margin-left: 3px;
    line-height: 20px; /* Match invalid element line height */
}

/* Ensure compatibility with existing checkbox/radio patterns */
.uppy-upload-container + .multilineFieldLabel,
.uppy-upload-container + .booleanItemLabel {
    margin-top: 8px; /* Match existing spacing patterns */
}

/* Match existing form field spacing when placed after other elements */
label + .uppy-upload-container,
.label + .uppy-upload-container,
.longlabel + .uppy-upload-container {
    margin-top: 0.5em; /* Match existing label-to-field spacing */
}

/* Integration with jQuery UI theme colors (subtle adaptation) */
.uppy-file-item.uppy-file-uploading {
    /* Use colors that harmonize with jQuery UI blue theme */
    border-left-color: #007fff; /* Match ui-state-active background */
}

.uppy-file-item.uppy-file-uploading .uppy-file-progress-bar {
    background-color: #007fff; /* Match ui-state-active background */
}

.uppy-file-item.uppy-file-uploading .uppy-file-status-text,
.uppy-file-item.uppy-file-uploading .uppy-file-progress-percentage {
    color: #007fff; /* Match ui-state-active background */
}

/* Ensure error states match existing validation styling */
.uppy-file-item.uppy-file-failed .uppy-file-status-text {
    color: Red; /* Match existing .invalid color */
}

/* Responsive adjustments to maintain form consistency */
@media (max-width: 640px) {
    .uppy-upload-container {
        /* Maintain mobile form consistency */
        font-size: 12px;
    }
    
    .uppy-drop-zone {
        /* Scale down for mobile but maintain proportions */
        max-width: 100%;
    }
}

/* Ensure proper spacing in form context */
.uppy-upload-container:last-child {
    margin-bottom: 0; /* Remove extra margin when last element */
}

/* Match standard button height for remove buttons */
.uppy-file-remove {
    height: 20px; /* Approximate existing button height */
    min-height: 20px;
}

/* Ensure file list integrates well with form sections */
.uppy-file-list {
    /* Match spacing patterns from existing form sections */
    margin-top: 8px;
}
