/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 20px;
    width: 98%;
}

/* Header */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1800px;
    margin: 0 auto;
}

.header-text {
    text-align: left;
}

.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 300;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.cluster-name-display {
    font-size: 0.85rem;
    opacity: 0.85;
    text-align: right;
    color: white;
}

/* User Info Display */
.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;
}

.user-name {
    font-size: 0.9rem;
    opacity: 0.9;
    color: white;
}

.logout-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

.refresh-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(10px);
}

.refresh-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.refresh-btn:active {
    transform: translateY(0);
}

.refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.refresh-icon {
    font-size: 1.2em;
    transition: transform 0.3s ease;
}

.refresh-btn:hover .refresh-icon {
    transform: rotate(180deg);
}

.refresh-btn.loading .refresh-icon {
    animation: spin 1s linear infinite;
}

/* Main deployment view */
.deployment-view {
    display: flex;
    flex-direction: column;
    gap: 30px;
    background: white;
    border-radius: 15px;
    padding: 50px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    min-height: 600px;
}

.deployment-top {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: start;
    gap: 30px;
    position: relative;
}

/* Version comparison container should not break the grid */
.version-comparison-container {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 2px;
    z-index: 5;
    pointer-events: none;
}

.deployment-bottom {
    display: flex;
    justify-content: center;
    width: 100%;
}

/* Instance containers */
.instance {
    flex: 1;
    min-width: 0;
}

.shared-instance {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px solid #dee2e6;
    border-radius: 10px;
    padding: 20px;
    max-width: 800px;
    width: 100%;
}

.shared-instance .instance-header h2 {
    color: #495057;
    font-weight: 600;
}

.instance-header {
    margin-bottom: 25px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: nowrap;
}

.instance-header h2 {
    font-size: 1.8rem;
    font-weight: 500;
    color: #2c3e50;
}

.color-label {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.color-label.green {
    background-color: #27ae60;
    color: white;
}

.color-label.blue {
    background-color: #3498db;
    color: white;
}

/* Applications list */
.applications-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.application-item {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1.5fr;
    gap: 25px;
    align-items: center;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
    min-height: 80px;
}

.application-item:hover {
    background-color: #e9ecef;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.application-item.highlighted {
    background-color: #e9ecef;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 2px solid #007bff;
}

.app-name {
    font-weight: 500;
    color: #2c3e50;
    font-size: 1.1rem;
    min-width: 140px;
}

.version-column {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.version-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.current-version {
    font-size: 0.9rem;
    color: #2c3e50;
    font-weight: 500;
    padding: 12px 18px;
    background-color: #e9ecef;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 20px;
    width: 100%;
}

.version-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.version-select {
    padding: 12px 18px;
    border: 2px solid #ddd;
    border-radius: 6px;
    background-color: white;
    font-size: 0.9rem;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 250px;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.version-select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.version-select:disabled {
    background-color: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
    border-color: #dee2e6;
}

.upgrade-indicator {
    color: #e67e22;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 4px 8px;
    background-color: #fef5e7;
    border-radius: 4px;
    border: 1px solid #f39c12;
}

.asterisk-indicator {
    color: #e74c3c;
    font-weight: bold;
    font-size: 1.2rem;
    margin-left: 5px;
}

.hidden-column {
    display: none;
}

/* Swap section */
.swap-section {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    grid-column: 2;
    grid-row: 1;
    z-index: 10;
}

.swap-btn {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.swap-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

.swap-btn:active {
    transform: translateY(0);
}

.swap-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.swap-btn.swapping {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    cursor: not-allowed;
}

/* Swap Status Styles */
.swap-status {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
    text-decoration: none;
    cursor: pointer;
    border: none;
    text-transform: uppercase;
}

.swap-status:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(243, 156, 18, 0.4);
    text-decoration: none;
    color: white;
}

.swap-status.running {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
}

.swap-status.completed {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    animation: none;
}

.swap-status.failed {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    animation: none;
}

.swap-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

.swap-status.completed .swap-spinner,
.swap-status.failed .swap-spinner {
    animation: none;
}

.swap-text {
    font-weight: 600;
}

/* Sync from Green Button */
.sync-from-green-btn {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: none;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(155, 89, 182, 0.3);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sync-from-green-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(155, 89, 182, 0.4);
}

.sync-from-green-btn:active {
    transform: translateY(0);
}

.sync-from-green-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.sync-from-green-btn.syncing {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    cursor: not-allowed;
    animation: pulse 2s infinite;
}

/* Deploy button */
.deploy-btn {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
}

.deploy-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.4);
}

.deploy-btn:active {
    transform: translateY(0);
}

.deploy-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.deploy-btn.deploying {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    cursor: not-allowed;
    animation: pulse 2s infinite;
}

.deploy-icon {
    font-size: 1.2em;
    transition: transform 0.3s ease;
}

.deploy-btn:hover .deploy-icon {
    transform: scale(1.1);
}

.deploy-btn.deploying .deploy-icon {
    animation: spin 1s linear infinite;
}

/* Deployment Status Styles */
.deployment-status {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
    text-decoration: none;
    cursor: pointer;
    border: none;
}

.deployment-status:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(243, 156, 18, 0.4);
    text-decoration: none;
    color: white;
}

.deployment-status.running {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
}

.deployment-status.completed {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    animation: none;
}

.deployment-status.failed {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    animation: none;
}

.deployment-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

.deployment-status.completed .deployment-spinner,
.deployment-status.failed .deployment-spinner {
    animation: none;
}

.deployment-text {
    font-weight: 600;
}

.external-link-icon {
    font-size: 0.9em;
    opacity: 0.8;
    margin-left: 4px;
}

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
}

.version-loading {
    display: flex;
    align-items: center;
    padding: 12px 18px;
    background-color: #f8f9fa;
    border: 2px solid #007bff;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #2c3e50;
    font-weight: 500;
    min-height: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.version-loading .loading-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #007bff;
    border-top-color: transparent;
    margin-right: 8px;
}

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

/* Status messages */
.status-messages {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.status-message {
    padding: 12px 20px;
    border-radius: 6px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s ease;
}

.status-message.success {
    background-color: #27ae60;
    color: white;
}

.status-message.error {
    background-color: #e74c3c;
    color: white;
}

/* Error popup at bottom */
.error-popup {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
    max-width: 500px;
    width: 90%;
    padding: 16px 24px;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(231, 76, 60, 0.4);
    font-weight: 500;
    text-align: center;
    animation: slideUp 0.3s ease-out;
    border: 2px solid #c0392b;
}

.error-popup::before {
    content: "⚠️";
    margin-right: 8px;
    font-size: 1.2em;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.status-message.info {
    background-color: #3498db;
    color: white;
}

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

/* Responsive design */
@media (max-width: 1200px) {
    .container {
        max-width: 95%;
        padding: 15px;
    }
    
    .deployment-view {
        gap: 30px;
        padding: 30px;
    }
    
    .deployment-top {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .swap-section {
        order: -1;
        padding: 20px 0;
    }
    
    .application-item {
        gap: 15px;
        padding: 15px;
    }
}

@media (max-width: 768px) {
    .deployment-view {
        gap: 20px;
        padding: 20px;
    }
    
    .deployment-top {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .swap-section {
        order: -1;
        padding: 15px 0;
    }
    
    .application-item {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 15px;
    }
    
    .version-column {
        flex-direction: row;
        align-items: center;
        gap: 15px;
    }
    
    .version-label {
        min-width: 100px;
    }
    
    .version-select {
        min-width: 100%;
    }
    
    .app-name {
        min-width: auto;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .container {
        padding: 10px;
    }
}


@media (max-width: 480px) {
    .deployment-view {
        padding: 20px;
    }
    
    .instance-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .instance-header h2 {
        font-size: 1.5rem;
    }
    
    .deploy-btn {
        font-size: 0.9rem;
        padding: 10px 20px;
    }
    
    .swap-btn {
        padding: 12px 24px;
        font-size: 1rem;
    }
}

/* Version Comparison Indicators */

.version-comparison-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: repeating-linear-gradient(
        to bottom,
        #ccc 0px,
        #ccc 4px,
        transparent 4px,
        transparent 8px
    );
    transform: translateX(-50%);
    opacity: 0.3;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.version-comparison-indicator {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    opacity: 0.3;
    transition: opacity 0.3s ease;
    z-index: 2;
    background: white;
    border: 2px solid;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Version comparison scenarios */
.version-comparison-indicator.match {
    color: #27ae60;
    border-color: #27ae60;
}

.version-comparison-indicator.mismatch {
    color: #f39c12;
    border-color: #f39c12;
}

.version-comparison-indicator.blue-target-matches-green {
    color: #3498db;
    border-color: #3498db;
}

.version-comparison-indicator.blue-target-will-mismatch {
    color: #3498db;
    border-color: #3498db;
}

/* Hover effects for version comparison */
.application-item:hover ~ .version-comparison-line,
.application-item.highlighted ~ .version-comparison-line {
    opacity: 0.8;
}

.application-item:hover ~ .version-comparison-indicator,
.application-item.highlighted ~ .version-comparison-indicator {
    opacity: 1;
}

/* Version comparison line and indicator hover states */
.version-comparison-line.highlighted {
    opacity: 0.8;
}

.version-comparison-indicator.highlighted {
    opacity: 1;
}

/* Loading Spinner Overlay */
.loading-spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-spinner-content {
    background: white;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    min-width: 400px;
}

.loading-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 10px;
}

.loading-status-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.loading-status-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    transition: all 0.3s ease;
}

.loading-status-item.loading {
    color: #666;
}

.loading-status-item.loaded {
    color: #27ae60;
}

.loading-status-item.error {
    color: #e74c3c;
}

.loading-spinner-small {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-radius: 50%;
    border-top-color: #007bff;
    animation: spin 1s linear infinite;
}

.loading-status-text {
    flex: 1;
    font-size: 1rem;
    font-weight: 500;
}

.loading-checkmark {
    font-size: 1.2rem;
    font-weight: bold;
    color: #27ae60;
    display: none;
}

.loading-checkmark.error {
    color: #e74c3c;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

.loading-text {
    color: #333;
    font-size: 16px;
    font-weight: 500;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Version Display */
.version-display {
    position: fixed;
    bottom: 10px;
    right: 10px;
    font-size: 0.75rem;
    color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Last Refresh Display */
.last-refresh-display {
    position: fixed;
    bottom: 10px;
    left: 10px;
    font-size: 0.75rem;
    color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}
