/**
 * File Exchange Modal Styles
 */

/* Overlay - поверх всего */
.file-exchange-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

/* Modal */
.file-exchange-modal {
    background: var(--bg-primary, #fff);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.file-exchange-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.file-exchange-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.file-exchange-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.file-exchange-permission-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.file-exchange-permission-badge.permission-owner {
    background: #e8f5e9;
    color: #2e7d32;
}

.file-exchange-permission-badge.permission-edit {
    background: #e3f2fd;
    color: #1565c0;
}

.file-exchange-permission-badge.permission-read {
    background: #fff3e0;
    color: #e65100;
}

.file-exchange-permission-badge.permission-list {
    background: #f5f5f5;
    color: #616161;
}

.file-exchange-close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary, #666);
    transition: background 0.2s;
}

.file-exchange-close:hover {
    background: var(--hover-bg, #f5f5f5);
}

/* Toolbar */
.file-exchange-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-secondary, #fafafa);
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.file-exchange-actions {
    display: flex;
    gap: 8px;
}

.fe-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    background: var(--primary-color, #1976d2);
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    transition:
        background 0.2s,
        opacity 0.2s;
}

.fe-btn:hover:not(:disabled) {
    background: var(--primary-dark, #1565c0);
}

.fe-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.fe-btn i {
    font-size: 18px;
}

.file-exchange-provider {
    font-size: 13px;
    color: var(--text-secondary, #666);
}

.provider-name {
    font-weight: 500;
    color: var(--text-primary, #333);
}

/* Content */
.file-exchange-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
}

/* Vertical sections */
.file-exchange-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Label above box */
.file-exchange-label {
    display: flex;
    align-items: center;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary, #666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Rounded box container */
.file-exchange-box {
    border-radius: 8px;
    min-height: 100px;
    max-height: 180px;
    overflow-y: auto;
    padding: 8px;
}

/* Master box - light green */
.file-exchange-section:first-child .file-exchange-box {
    background: #e8f5e9;
    border: 1px solid #c8e6c9;
}

[data-theme='dark'] .file-exchange-section:first-child .file-exchange-box {
    background: rgba(76, 175, 80, 0.15);
    border-color: rgba(76, 175, 80, 0.3);
}

/* Work box - light blue */
.file-exchange-section:last-child .file-exchange-box {
    background: #e3f2fd;
    border: 1px solid #bbdefb;
}

[data-theme='dark'] .file-exchange-section:last-child .file-exchange-box {
    background: rgba(33, 150, 243, 0.15);
    border-color: rgba(33, 150, 243, 0.3);
}

/* Add file button in label */
.fe-add-file-btn {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: 8px;
    padding: 2px 8px;
    border: 1px solid var(--primary-color, #1976d2);
    border-radius: 4px;
    background: transparent;
    color: var(--primary-color, #1976d2);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: none;
}

.fe-add-file-btn:hover {
    background: var(--primary-color, #1976d2);
    color: #fff;
}

.fe-add-file-btn i {
    font-size: 14px;
}

/* Files list */
.fe-files-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.fe-file-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 0;
}

.fe-file-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* File action buttons */
.fe-file-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.2s;
}

.fe-file-item:hover .fe-file-actions {
    opacity: 1;
}

/* Status badge below file row */
.fe-file-item > .fe-file-status {
    padding-left: 0;
}

.fe-file-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-secondary, #666);
    cursor: pointer;
    border-radius: 4px;
    transition:
        background 0.2s,
        color 0.2s;
}

.fe-file-action:hover {
    background: var(--hover-bg, #e0e0e0);
    color: var(--text-primary, #333);
}

.fe-file-action i {
    font-size: 16px;
}

.fe-file-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.fe-file-icon i {
    font-size: 20px;
    color: var(--primary-color, #1976d2);
}

.fe-file-name {
    flex: 1;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary, #333);
}

.fe-file-status {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.fe-file-status i {
    font-size: 18px;
}

/* Spinner for uploading */
.fe-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color, #e0e0e0);
    border-top-color: var(--primary-color, #1976d2);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.fe-file-uploading {
    opacity: 0.7;
}

.fe-file-error {
    background: #ffebee;
}

[data-theme='dark'] .fe-file-error {
    background: rgba(244, 67, 54, 0.15);
}

/* Loading */
.file-exchange-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    color: var(--text-secondary, #666);
}

.file-exchange-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color, #e0e0e0);
    border-top-color: var(--primary-color, #1976d2);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Empty */
.file-exchange-empty,
.file-exchange-connect,
.file-exchange-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    padding: 40px;
    text-align: center;
    color: var(--text-secondary, #666);
}

.file-exchange-empty i,
.file-exchange-connect i,
.file-exchange-error i {
    font-size: 48px;
    opacity: 0.5;
}

.file-exchange-error i {
    color: #d32f2f;
}

.connect-buttons {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.fe-btn-connect {
    background: #fff;
    color: var(--text-primary, #333);
    border: 1px solid var(--border-color, #e0e0e0);
}

.fe-btn-connect:hover {
    background: var(--hover-bg, #f5f5f5);
}

/* File List */
.file-exchange-list {
    padding: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    transition: background 0.2s;
}

.file-item:hover {
    background: var(--hover-bg, #f5f5f5);
}

.file-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary, #f0f0f0);
    border-radius: 8px;
}

.file-icon i {
    font-size: 24px;
    color: var(--primary-color, #1976d2);
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-secondary, #666);
    margin-top: 2px;
}

.file-actions {
    display: flex;
    gap: 4px;
}

.fe-btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    border-radius: 50%;
    color: var(--text-secondary, #666);
    cursor: pointer;
    transition:
        background 0.2s,
        color 0.2s;
    text-decoration: none;
}

.fe-btn-icon:hover {
    background: var(--hover-bg, #e0e0e0);
    color: var(--text-primary, #333);
}

.fe-btn-delete:hover {
    color: #d32f2f;
}

/* Briefcase icon in step row */
.step-briefcase-cell {
    width: 48px;
    text-align: center;
    vertical-align: middle;
}

.briefcase-icon {
    cursor: pointer;
    transition:
        transform 0.2s,
        opacity 0.2s;
}

.briefcase-icon:hover:not(.briefcase-disabled) {
    transform: scale(1.1);
}

.briefcase-icon.briefcase-disabled {
    cursor: not-allowed;
}

.briefcase-icon.briefcase-owner,
.briefcase-icon.briefcase-edit {
    filter: hue-rotate(90deg) saturate(1.2);
}

/* Dark theme support */
[data-theme='dark'] .file-exchange-modal {
    background: var(--bg-primary, #1e1e1e);
}

[data-theme='dark'] .file-exchange-toolbar {
    background: var(--bg-secondary, #2d2d2d);
}

[data-theme='dark'] .fe-btn-connect {
    background: var(--bg-secondary, #2d2d2d);
    border-color: var(--border-color, #444);
}

/* Confirm dialog */
.fe-confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

.fe-confirm-dialog {
    background: var(--bg-primary, #fff);
    border-radius: 8px;
    padding: 20px;
    min-width: 280px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.fe-confirm-message {
    font-size: 14px;
    margin-bottom: 16px;
    color: var(--text-primary, #333);
}

.fe-confirm-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.fe-confirm-btn {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}

.fe-confirm-cancel {
    background: var(--bg-secondary, #f5f5f5);
    color: var(--text-primary, #333);
}

.fe-confirm-cancel:hover {
    background: var(--hover-bg, #e0e0e0);
}

.fe-confirm-ok {
    background: #d32f2f;
    color: #fff;
}

.fe-confirm-ok:hover {
    background: #b71c1c;
}

[data-theme='dark'] .fe-confirm-dialog {
    background: var(--bg-primary, #1e1e1e);
}

/* Editing status */
.fe-file-editing {
    background: rgba(25, 118, 210, 0.08);
    border-radius: 4px;
}

[data-theme='dark'] .fe-file-editing {
    background: rgba(25, 118, 210, 0.15);
}

.fe-file-editing .fe-file-actions {
    opacity: 1;
}

.fe-editing-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    background: #e3f2fd;
    color: #1565c0;
    animation: pulse-editing 2s ease-in-out infinite;
}

[data-theme='dark'] .fe-editing-badge {
    background: rgba(25, 118, 210, 0.3);
    color: #64b5f6;
}

@keyframes pulse-editing {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.fe-upload-success {
    background: #e8f5e9;
    color: #2e7d32;
    animation: none;
}

[data-theme='dark'] .fe-upload-success {
    background: rgba(76, 175, 80, 0.3);
    color: #81c784;
}

/* Fallback dialog */
.fe-fallback-dialog {
    max-width: 360px;
}

.fe-fallback-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

.fe-fallback-icon i {
    font-size: 48px;
    color: #1976d2;
}

.fe-fallback-dialog .fe-confirm-message {
    text-align: center;
    line-height: 1.6;
}

.fe-fallback-dialog .fe-confirm-buttons {
    justify-content: center;
}

.fe-fallback-dialog .fe-confirm-ok {
    background: var(--primary-color, #1976d2);
}

.fe-fallback-dialog .fe-confirm-ok:hover {
    background: var(--primary-dark, #1565c0);
}

/* Tracking status - отслеживание изменений файла после загрузки */

/* When tracking - only show Stop tracking button always, others on hover */
.fe-file-tracking [title='Stop tracking'] {
    opacity: 1;
}

/* Folder button - linked state */
.fe-folder-btn.fe-folder-linked {
    color: var(--primary-color, #1976d2);
}

.fe-folder-btn.fe-folder-linked i {
    color: var(--primary-color, #1976d2);
}

.fe-tracking-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    background: #e8f5e9;
    color: #2e7d32;
    white-space: nowrap;
}

[data-theme='dark'] .fe-tracking-badge {
    background: rgba(76, 175, 80, 0.2);
    color: #81c784;
}

/* Changes detected badge - оранжевый для привлечения внимания */
.fe-tracking-badge.fe-changes-detected {
    background: #fff3e0;
    color: #e65100;
}

[data-theme='dark'] .fe-tracking-badge.fe-changes-detected {
    background: rgba(255, 152, 0, 0.2);
    color: #ffb74d;
}

/* Upload button highlight when changes detected */
.fe-file-changed .fe-upload-btn {
    color: #e65100 !important;
}

[data-theme='dark'] .fe-file-changed .fe-upload-btn {
    color: #ffb74d !important;
}

/* Version badge - показывает номер версии при обновлении */
.fe-version-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    background: #e3f2fd;
    color: #1565c0;
    white-space: nowrap;
}

[data-theme='dark'] .fe-version-badge {
    background: rgba(33, 150, 243, 0.2);
    color: #64b5f6;
}

/* Info footer - подсказка про настройки браузера */
.fe-info-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 11px;
    color: #757575;
    border-top: 1px solid #e0e0e0;
}

.fe-info-footer i {
    font-size: 14px;
}

[data-theme='dark'] .fe-info-footer {
    color: #9e9e9e;
    border-top-color: #424242;
}
