/* Completely isolated code block styles to prevent UI interference */
.message-code-block {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    margin: 12px 0;
    overflow: hidden;
    max-width: 100%;
    position: relative;
}

/* Code block loading animation */
.message-code-loading {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    margin: 12px 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    overflow: hidden;
}

.message-code-loading-text {
    color: var(--accent-color);
    font-size: 14px;
    margin-top: 16px;
    font-weight: 500;
}

/* Wave animation container */
.message-code-wave-container {
    width: 60px;
    height: 30px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

/* Individual wave bars */
.message-code-wave-bar {
    background-color: var(--accent-color);
    width: 8px;
    height: 100%;
    border-radius: 3px;
    animation: wave 1.2s ease-in-out infinite;
}

/* Stagger the animations */
.message-code-wave-bar:nth-child(2) {
    animation-delay: 0.1s;
}

.message-code-wave-bar:nth-child(3) {
    animation-delay: 0.2s;
}

.message-code-wave-bar:nth-child(4) {
    animation-delay: 0.3s;
}

.message-code-wave-bar:nth-child(5) {
    animation-delay: 0.4s;
}

/* Wave animation */
@keyframes wave {
    0%, 100% {
        height: 15px;
        opacity: 0.3;
    }
    50% {
        height: 30px;
        opacity: 1;
    }
}

.message-code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: rgba(0, 180, 216, 0.1);
    border-bottom: 1px solid var(--glass-border);
}

/* Code header actions container */
.message-code-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.message-code-language {
    font-size: 12px;
    color: var(--accent-color);
    font-weight: 600;
    text-transform: uppercase;
}

.message-copy-code {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    padding: 4px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.message-copy-code:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Preview button styles */
.message-preview-code {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    padding: 4px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.message-preview-code:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Preview modal styles */
.code-preview-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.code-preview-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.code-preview-content {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    width: 90%;
    max-width: 900px;
    height: 80%;
    max-height: 600px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.code-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(0, 180, 216, 0.1);
    border-bottom: 1px solid var(--glass-border);
}

.code-preview-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent-color);
}

.code-preview-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s ease;
}

.code-preview-close:hover {
    color: var(--accent-color);
}

.code-preview-iframe {
    flex: 1;
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

.message-code-pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    background: rgba(0, 0, 0, 0.2);
}

.message-code {
    color: var(--text-primary);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    display: block;
}

/* Inline code styling */
.message-inline-code {
    background: var(--glass-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
    color: var(--accent-color);
    display: inline;
}

/* Preview button styling */
.message-preview-code {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    padding: 4px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.message-preview-code:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Modal styles */
.code-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.code-preview-modal.active {
    opacity: 1;
    visibility: visible;
}

.code-preview-content {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    width: 80%;
    height: 80%;
    max-width: 1200px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.code-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(0, 180, 216, 0.1);
}

.code-preview-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent-color);
}

.code-preview-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.code-preview-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.code-preview-iframe {
    flex: 1;
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

/* Scrollbar for code blocks */
.message-code-pre::-webkit-scrollbar {
    height: 6px;
}

.message-code-pre::-webkit-scrollbar-track {
    background: transparent;
}

.message-code-pre::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 3px;
}
