/**
 * Change Tracker Visual Styles
 * Styles for dirty cells, conflicts, and save indicators
 */

/* Dirty cell indicator */
.cell-dirty {
    background-color: #fff3cd !important;
    position: relative;
    transition: background-color 0.2s ease;
}

/* Corner triangle indicator for dirty cells */
.cell-dirty::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 8px 8px 0;
    border-color: transparent #ff9800 transparent transparent;
    pointer-events: none;
}

/* Hover state for dirty cells */
.cell-dirty:hover {
    background-color: #ffe7a0 !important;
}

/* Conflict cell indicator */
.cell-conflict {
    background-color: #f8d7da !important;
    border: 2px solid #dc3545 !important;
    position: relative;
}

.cell-conflict::before {
    content: '⚠';
    position: absolute;
    top: 2px;
    left: 2px;
    color: #dc3545;
    font-size: 12px;
    font-weight: bold;
}

/* Saving state indicator */
.cell-saving {
    background-color: #d1ecf1 !important;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(13, 202, 240, 0.4);
    }
    50% {
        opacity: 0.8;
        box-shadow: 0 0 0 4px rgba(13, 202, 240, 0);
    }
    100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(13, 202, 240, 0);
    }
}

/* Successfully saved indicator */
.cell-saved {
    background-color: #d4edda !important;
    animation: fadeToNormal 2s ease-out forwards;
}

@keyframes fadeToNormal {
    0% {
        background-color: #d4edda;
    }
    100% {
        background-color: transparent;
    }
}

/* Change status display */
#change-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    padding: 12px 16px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
}

#change-status:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transform: translateY(-2px);
}

#change-status .badge {
    font-size: 0.875rem;
    padding: 4px 8px;
}

/* Saving indicator overlay */
.saving-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 30px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    font-size: 16px;
    font-weight: 500;
}

/* Save button with change count */
#save-workspace-btn {
    position: relative;
    transition: all 0.3s ease;
}

#save-workspace-btn #change-count {
    background: #dc3545;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-left: 4px;
    font-weight: bold;
}

#save-workspace-btn:disabled #change-count {
    background: #6c757d;
}

/* Grid modifications for better visibility */
.jss td.cell-dirty {
    font-weight: 500;
}

/* Toolbar integration */
.workspace-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

/* Change summary panel */
.change-summary {
    position: fixed;
    top: 70px;
    right: 20px;
    width: 300px;
    max-height: 400px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 15px;
    display: none;
    overflow-y: auto;
}

.change-summary.show {
    display: block;
}

.change-summary h5 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1rem;
    font-weight: 600;
}

.change-summary .change-item {
    padding: 8px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 0.875rem;
}

.change-summary .change-item:hover {
    background: #e9ecef;
}

.change-summary .change-item .cell-ref {
    font-weight: bold;
    color: #0066cc;
}

.change-summary .change-item .old-value {
    color: #dc3545;
    text-decoration: line-through;
}

.change-summary .change-item .new-value {
    color: #28a745;
}

/* Auto-save indicator */
.auto-save-status {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 8px 12px;
    background: #28a745;
    color: white;
    border-radius: 4px;
    font-size: 0.875rem;
    display: none;
    animation: slideIn 0.3s ease;
}

.auto-save-status.show {
    display: block;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Conflict resolution dialog styles */
.conflict-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    max-height: 600px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    z-index: 10000;
    overflow: hidden;
}

.conflict-dialog-header {
    padding: 15px 20px;
    background: #dc3545;
    color: white;
    font-weight: 600;
}

.conflict-dialog-body {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.conflict-item {
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.conflict-item.selected {
    border-color: #0066cc;
    background: #e7f3ff;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #change-status {
        bottom: 10px;
        right: 10px;
        font-size: 0.875rem;
        padding: 8px 12px;
    }

    .change-summary {
        width: 250px;
        right: 10px;
        top: 60px;
    }

    .conflict-dialog {
        width: 90%;
        max-width: 400px;
    }
}