/* OS-Specific File Upload Component Styles */

/* Container */
.os-files-container {
    margin-top: 1rem;
    display: block;
    visibility: visible;
}

.os-file-entry {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr auto;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background-color: var(--white, #ffffff);
    border-radius: 8px;
    border: 1px solid var(--gray, #e0e0e0);
    align-items: end;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
    visibility: visible;
    opacity: 1;
    min-width: 0;
}

.os-file-entry > div {
    min-width: 0;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.os-file-entry:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Dark mode os-file-entry hover */
[data-theme="dark"] .os-file-entry:hover,
.dark-theme .os-file-entry:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

/* Form groups within OS file entries */
.os-file-entry .form-group {
    margin-bottom: 0;
}

.os-file-entry label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color, #333333);
    font-size: 0.9rem;
    line-height: 1.4;
    visibility: visible;
    opacity: 1;
    transition: color 0.3s ease;
}

/* Custom dropdown within OS entries */
.os-file-entry .custom-dropdown {
    width: 100%;
    position: relative;
    display: block;
    visibility: visible;
    opacity: 1;
}

.os-file-entry .custom-dropdown select {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 0.75rem;
    border: 1px solid var(--gray, #ccc);
    border-radius: 4px;
    background-color: var(--white, #ffffff);
    color: var(--text-color, #333333);
    font-size: 0.9rem;
    font-weight: 400;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 12px;
    line-height: 1.5;
    min-height: 42px;
    display: block;
    visibility: visible;
    opacity: 1;
}

.os-file-entry .custom-dropdown select:hover {
    border-color: #999;
    background-color: #fafafa;
}

.os-file-entry .custom-dropdown select:focus {
    outline: none;
    outline-offset: 0;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
    background-color: #ffffff;
}

.os-file-entry .custom-dropdown select option {
    padding: 0.5rem;
    color: #333333;
    background-color: #ffffff;
}

.os-file-entry .custom-dropdown select option:disabled {
    color: #999;
}

/* Auto-detection badge */
.auto-detect-badge {
    display: inline-block;
    position: absolute;
    top: -8px;
    right: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 12px;
    z-index: 10;
    pointer-events: none;
    animation: badge-appear 0.3s ease-out;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.auto-detect-badge-os {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auto-detect-badge-device {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

@keyframes badge-appear {
    from {
        opacity: 0;
        transform: translateY(-5px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Auto-detected select styling */
.os-file-entry .custom-dropdown select[data-auto-detected="true"] {
    border-color: #667eea;
    background-color: rgba(102, 126, 234, 0.08);
}

.os-file-entry .custom-dropdown select[data-auto-detected="true"]:hover {
    background-color: rgba(102, 126, 234, 0.12);
}

.os-file-entry .custom-dropdown select[data-auto-detected="true"]:focus {
    background-color: #ffffff;
}

/* Custom file input within OS entries */
.os-file-entry .custom-file-input {
    position: relative;
    width: 100%;
    display: block;
}

.os-file-entry .custom-file-input input[type="file"] {
    position: absolute;
    left: 0;
    top: 0;
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    z-index: -1;
    display: block;
}

.os-file-entry .custom-file-upload-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background-color: #ffffff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
    font-size: 0.9rem;
    color: #333333;
    width: 100%;
    box-sizing: border-box;
}

.os-file-entry .custom-file-upload-btn:hover {
    border-color: #667eea;
    background-color: #667eea;
    color: #fff;
}

.os-file-entry .custom-file-upload-btn .file-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.os-file-entry .custom-file-upload-btn .file-button-text {
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Hide upload button when file is selected */
.os-file-entry .custom-file-input:has(input[type="file"]:valid) .custom-file-upload-btn,
.os-file-entry .custom-file-input.has-file .custom-file-upload-btn {
    display: none;
}

/* Hide drag-drop zone when file is selected */
.os-file-entry .custom-file-input:has(input[type="file"]:valid) .drag-drop-zone,
.os-file-entry .custom-file-input.has-file .drag-drop-zone {
    display: none;
}

/* Remove button */
.remove-os-file {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: #f44336;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.5rem;
    font-weight: bold;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.remove-os-file:hover {
    background-color: #d32f2f;
    transform: scale(1.05);
}

.remove-os-file:active {
    transform: scale(0.95);
}

/* Add OS file button */
.add-os-file-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background-color: var(--primary-color, #667eea);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-top: 0.5rem;
}

.add-os-file-btn:hover {
    background-color: var(--primary-color-dark, #5a6fd6);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.add-os-file-btn:active {
    transform: translateY(0);
}

/* File hint */
.file-hint {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #666666;
    font-style: italic;
}

/* Drag and drop zone */
.drag-drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    border: 2px dashed #ddd;
    border-radius: 8px;
    background-color: #ffffff;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
    text-align: center;
}

.drag-drop-zone:hover {
    border-color: #667eea;
    background-color: rgba(102, 126, 234, 0.05);
}

.drag-drop-zone.drag-over {
    border-color: #667eea;
    background-color: rgba(102, 126, 234, 0.1);
    transform: scale(1.02);
}

.drag-drop-zone .drag-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.drag-drop-zone .drag-text {
    font-size: 0.95rem;
    color: #666666;
    margin-bottom: 0.5rem;
}

.os-file-entry .drag-hint {
    font-size: 0.85rem;
    color: #999999;
}

/* Dark theme support - Complete */
@media (prefers-color-scheme: dark) {
    .os-file-entry {
        background-color: #1e1e1e;
        border-color: #333;
    }

    .os-file-entry label {
        color: #e0e0e0;
    }

    .os-file-entry .custom-dropdown select {
        background-color: #2d2d2d;
        color: #e0e0e0;
        border-color: #444;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e0e0e0' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    }

    .os-file-entry .custom-file-upload-btn {
        background-color: #2d2d2d;
        border-color: #444;
        color: #e0e0e0;
    }

    .drag-drop-zone {
        background-color: #2d2d2d;
        border-color: #444;
    }

    .drag-drop-zone .drag-text {
        color: #cccccc;
    }

    .file-info-display {
        background-color: #2d2d2d;
    }

    .file-info-display .file-name {
        color: #e0e0e0;
    }

    .file-info-display .file-size {
        color: #999999;
    }

    .validation-error-message {
        background-color: rgba(244, 67, 54, 0.1);
        border-color: rgba(244, 67, 54, 0.3);
        color: #ef9a9a;
    }

    .form-inline-error {
        background-color: rgba(244, 67, 54, 0.1);
        border-color: rgba(244, 67, 54, 0.3);
        color: #ef9a9a;
    }
}

/* Explicit light theme class support - ensure proper theme switching */
[data-theme="light"] .os-file-entry,
.light-theme .os-file-entry {
    background-color: #ffffff !important;
    border-color: #e0e0e0 !important;
}

[data-theme="light"] .os-file-entry label,
.light-theme .os-file-entry label {
    color: #333333 !important;
}

[data-theme="light"] .os-file-entry .custom-dropdown,
.light-theme .os-file-entry .custom-dropdown {
    color: #333333;
}

[data-theme="light"] .os-file-entry .custom-dropdown select,
.light-theme .os-file-entry .custom-dropdown select {
    background-color: #ffffff !important;
    color: #333333 !important;
    border-color: #ccc !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E") !important;
}

[data-theme="light"] .os-file-entry .custom-dropdown select option,
.light-theme .os-file-entry .custom-dropdown select option {
    background-color: #ffffff;
    color: #333333;
}

[data-theme="light"] .os-file-entry .custom-file-upload-btn,
.light-theme .os-file-entry .custom-file-upload-btn {
    background-color: #ffffff !important;
    border-color: #ccc !important;
    color: #333333 !important;
}

[data-theme="light"] .os-file-entry .drag-drop-zone,
.light-theme .os-file-entry .drag-drop-zone {
    background-color: #ffffff !important;
    border-color: #ccc !important;
}

[data-theme="light"] .os-file-entry .drag-drop-zone .drag-text,
.light-theme .os-file-entry .drag-drop-zone .drag-text {
    color: #333333 !important;
}

[data-theme="light"] .os-file-entry .drag-drop-zone .drag-hint,
.light-theme .os-file-entry .drag-drop-zone .drag-hint {
    color: #666666 !important;
}

[data-theme="light"] .os-file-entry .file-info-display,
.light-theme .os-file-entry .file-info-display {
    background-color: #f5f5f5 !important;
}

[data-theme="light"] .os-file-entry .file-info-display .file-name,
.light-theme .os-file-entry .file-info-display .file-name {
    color: #333333 !important;
}

[data-theme="light"] .os-file-entry .file-info-display .file-size,
.light-theme .os-file-entry .file-info-display .file-size {
    color: #666666 !important;
}

[data-theme="light"] .os-file-entry .validation-error-message,
.light-theme .os-file-entry .validation-error-message {
    background-color: rgba(244, 67, 54, 0.1) !important;
    border-color: rgba(244, 67, 54, 0.3) !important;
    color: #c62828 !important;
}

[data-theme="light"] .os-file-entry .form-inline-error,
.light-theme .os-file-entry .form-inline-error {
    background-color: rgba(244, 67, 54, 0.1) !important;
    border-color: rgba(244, 67, 54, 0.3) !important;
    color: #c62828 !important;
}

/* Explicit dark theme class support */
[data-theme="dark"] .os-file-entry,
.dark-theme .os-file-entry,
body.dark-mode .os-file-entry {
    background-color: #1e1e1e !important;
    border-color: #333 !important;
}

[data-theme="dark"] .os-file-entry label,
.dark-theme .os-file-entry label,
body.dark-mode .os-file-entry label {
    color: #e0e0e0 !important;
}

[data-theme="dark"] .os-file-entry .custom-dropdown,
.dark-theme .os-file-entry .custom-dropdown,
body.dark-mode .os-file-entry .custom-dropdown {
    color: #e0e0e0;
}

[data-theme="dark"] .os-file-entry .custom-dropdown select,
.dark-theme .os-file-entry .custom-dropdown select,
body.dark-mode .os-file-entry .custom-dropdown select {
    background-color: #2d2d2d !important;
    color: #e0e0e0 !important;
    border-color: #444 !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e0e0e0' d='M6 9L1 4h10z'/%3E%3C/svg%3E") !important;
}

[data-theme="dark"] .os-file-entry .custom-dropdown select option,
.dark-theme .os-file-entry .custom-dropdown select option,
body.dark-mode .os-file-entry .custom-dropdown select option {
    background-color: #2d2d2d;
    color: #e0e0e0;
}

[data-theme="dark"] .os-file-entry .custom-file-upload-btn,
.dark-theme .os-file-entry .custom-file-upload-btn,
body.dark-mode .os-file-entry .custom-file-upload-btn {
    background-color: #2d2d2d !important;
    border-color: #444 !important;
    color: #e0e0e0 !important;
}

[data-theme="dark"] .os-file-entry .drag-drop-zone,
.dark-theme .os-file-entry .drag-drop-zone,
body.dark-mode .os-file-entry .drag-drop-zone {
    background-color: #2d2d2d !important;
    border-color: #444 !important;
}

[data-theme="dark"] .os-file-entry .drag-drop-zone .drag-text,
.dark-theme .os-file-entry .drag-drop-zone .drag-text,
body.dark-mode .os-file-entry .drag-drop-zone .drag-text {
    color: #cccccc !important;
}

[data-theme="dark"] .os-file-entry .drag-drop-zone .drag-hint,
.dark-theme .os-file-entry .drag-drop-zone .drag-hint,
body.dark-mode .os-file-entry .drag-drop-zone .drag-hint {
    color: #999999 !important;
}

[data-theme="dark"] .os-file-entry .file-info-display,
.dark-theme .os-file-entry .file-info-display,
body.dark-mode .os-file-entry .file-info-display {
    background-color: #2d2d2d !important;
}

[data-theme="dark"] .os-file-entry .file-info-display .file-name,
.dark-theme .os-file-entry .file-info-display .file-name,
body.dark-mode .os-file-entry .file-info-display .file-name {
    color: #e0e0e0 !important;
}

[data-theme="dark"] .os-file-entry .file-info-display .file-size,
.dark-theme .os-file-entry .file-info-display .file-size,
body.dark-mode .os-file-entry .file-info-display .file-size {
    color: #999999 !important;
}

[data-theme="dark"] .os-file-entry .validation-error-message,
.dark-theme .os-file-entry .validation-error-message,
body.dark-mode .os-file-entry .validation-error-message {
    background-color: rgba(244, 67, 54, 0.1) !important;
    border-color: rgba(244, 67, 54, 0.3) !important;
    color: #ef9a9a !important;
}

[data-theme="dark"] .os-file-entry .form-inline-error,
.dark-theme .os-file-entry .form-inline-error,
body.dark-mode .os-file-entry .form-inline-error {
    background-color: rgba(244, 67, 54, 0.1) !important;
    border-color: rgba(244, 67, 54, 0.3) !important;
    color: #ef9a9a !important;
}

/* File info display */
.validation-error-message {
    display: block;
    margin-top: 0.5rem;
    margin-bottom: 0;
    padding: 0.75rem 1rem;
    background-color: #fee;
    border: 1px solid #fcc;
    border-left: 4px solid #f44336;
    border-radius: 4px;
    color: #c62828;
    font-size: 0.85rem;
    line-height: 1.5;
    animation: slideDown 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
        max-height: 0;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 200px;
    }
}

/* Form inline error */
.form-inline-error {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    background-color: #fee;
    border: 1px solid #fcc;
    border-left: 4px solid #f44336;
    border-radius: 8px;
    color: #c62828;
    font-size: 0.9rem;
    animation: slideDown 0.3s ease;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.form-inline-error svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.form-inline-error span {
    flex: 1;
}

.form-inline-error .error-dismiss {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: #c62828;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.form-inline-error .error-dismiss:hover {
    background-color: rgba(244, 67, 54, 0.1);
}

/* File info display */
.file-info-display {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background-color: #f8f9fa;
    border-radius: 4px;
    margin-top: 0.5rem;
    width: 100%;
    box-sizing: border-box;
    animation: fadeIn 0.3s ease;
    transition: background-color 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.file-info-display .file-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.file-info-display .file-details {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.file-info-display .file-name {
    font-weight: 600;
    color: #333333;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.file-info-display .file-size {
    font-size: 0.8rem;
    color: #666666;
    display: block;
    margin-top: 0.25rem;
}

.file-info-display .remove-file-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background-color: #f44336;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.file-info-display .remove-file-btn:hover {
    background-color: #d32f2f;
    transform: scale(1.1);
}

/* Progress bar */
.upload-progress-container {
    margin-top: 0.5rem;
}

.upload-progress-bar {
    width: 100%;
    height: 6px;
    background-color: var(--border-color, #e0e0e0);
    border-radius: 3px;
    overflow: hidden;
}

.upload-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color, #667eea), var(--primary-color-dark, #5a6fd6));
    transition: width 0.3s ease;
    border-radius: 3px;
}

.upload-progress-text {
    font-size: 0.75rem;
    color: var(--text-muted, #666);
    margin-top: 0.25rem;
    text-align: right;
}

/* Validation states */
.os-file-entry.valid {
    border-color: #4caf50;
    background-color: rgba(76, 175, 80, 0.05);
}

.os-file-entry.invalid {
    border-color: #f44336;
    background-color: rgba(244, 67, 54, 0.05);
}

.error-message-inline {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: #f44336;
}

/* Responsive design */
@media (max-width: 1024px) {
    .os-file-entry {
        grid-template-columns: 1fr 1fr;
    }

    .os-file-entry > div:nth-child(3) {
        grid-column: 1 / -1;
    }

    .os-file-entry > div:nth-child(4) {
        grid-column: 2;
        justify-self: end;
    }
}

@media (max-width: 768px) {
    .os-file-entry {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .os-file-entry > div:nth-child(3) {
        grid-column: 1;
    }

    .os-file-entry > div:nth-child(4) {
        grid-column: 1;
        justify-self: stretch;
        width: 100%;
    }

    .remove-os-file {
        width: 100%;
        height: 40px;
    }
}

/* Accessibility */
.os-file-entry:focus-within {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* Loading state */
.os-file-entry.loading {
    pointer-events: none;
    opacity: 0.7;
}

.os-file-entry.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid rgba(102, 126, 234, 0.3);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
