/**
 * Code Block - Académie des Étoiles
 */

.ade-code { margin: var(--ade-space-2xl) 0; }

.ade-code__container {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--ade-shadow-lg);
    position: relative;
}

/* Dark theme (default) */
.ade-code__container--dark {
    background: #1e1e2e;
    border: 1px solid #313244;
}

.ade-code__container--dark .ade-code__header {
    background: #181825;
    border-bottom: 1px solid #313244;
}

.ade-code__container--dark .ade-code__language {
    background: rgba(155, 81, 224, 0.2);
    color: #cba6f7;
}

.ade-code__container--dark .ade-code__title {
    color: #cdd6f4;
}

.ade-code__container--dark .ade-code__copy {
    color: #cdd6f4;
    border-color: #313244;
}

.ade-code__container--dark .ade-code__copy:hover {
    background: #313244;
    border-color: #9b51e0;
}

.ade-code__container--dark .ade-code__code {
    color: #cdd6f4;
}

.ade-code__container--dark .ade-code__line--highlighted {
    background: rgba(155, 81, 224, 0.15);
}

/* Light theme */
.ade-code__container--light {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

.ade-code__container--light .ade-code__header {
    background: #ffffff;
    border-bottom: 1px solid #e9ecef;
}

.ade-code__container--light .ade-code__language {
    background: rgba(155, 81, 224, 0.1);
    color: #7c3aed;
}

.ade-code__container--light .ade-code__title {
    color: #1f2937;
}

.ade-code__container--light .ade-code__copy {
    color: #6b7280;
    border-color: #d1d5db;
}

.ade-code__container--light .ade-code__copy:hover {
    background: #f3f4f6;
    border-color: #9b51e0;
}

.ade-code__container--light .ade-code__code {
    color: #1f2937;
}

.ade-code__container--light .ade-code__line--highlighted {
    background: rgba(155, 81, 224, 0.1);
}

/* Header */
.ade-code__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--ade-space-sm) var(--ade-space-lg);
}

.ade-code__header-left {
    display: flex;
    align-items: center;
    gap: var(--ade-space-md);
}

.ade-code__language {
    display: inline-block;
    padding: var(--ade-space-xs) var(--ade-space-sm);
    border-radius: 6px;
    font-size: var(--ade-font-size-small);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ade-code__title {
    font-size: var(--ade-font-size-small);
    font-weight: 500;
}

.ade-code__copy {
    display: flex;
    align-items: center;
    gap: var(--ade-space-xs);
    padding: var(--ade-space-xs) var(--ade-space-sm);
    background: transparent;
    border: 1px solid;
    border-radius: 6px;
    font-size: var(--ade-font-size-small);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ade-code__copy:focus {
    outline: 2px solid rgba(155, 81, 224, 0.5);
    outline-offset: 2px;
}

.ade-code__copy-icon {
    width: 16px;
    height: 16px;
}

/* Content */
.ade-code__content {
    overflow-x: auto;
    max-width: 100%;
}

.ade-code__pre {
    margin: 0;
    padding: var(--ade-space-lg);
    overflow-x: auto;
}

.ade-code__code {
    display: block;
    font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre;
}

/* Line numbers */
.ade-code__line {
    display: block;
    position: relative;
    padding-left: 60px;
    padding-right: var(--ade-space-sm);
}

.ade-code__line::before {
    content: attr(data-line);
    position: absolute;
    left: 0;
    width: 40px;
    text-align: right;
    opacity: 0.4;
    user-select: none;
    padding-right: var(--ade-space-md);
}

.ade-code__line--highlighted {
    border-left: 3px solid var(--ade-primary);
    padding-left: 57px;
}

/* Copied notification */
.ade-code__copied-notification {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--ade-primary);
    color: var(--ade-white);
    padding: var(--ade-space-md) var(--ade-space-xl);
    border-radius: 8px;
    font-weight: 600;
    box-shadow: var(--ade-shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--ade-space-sm);
    z-index: 10;
    opacity: 0;
    pointer-events: none;
}

.ade-code__copied-notification:not([hidden]) {
    animation: fadeInOut 2s ease-in-out;
}

.ade-code__copied-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    font-weight: bold;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    10%, 90% { opacity: 1; }
}

/* Syntax highlighting - Basic token styles */
.ade-code__container--dark .token.keyword { color: #f38ba8; }
.ade-code__container--dark .token.string { color: #a6e3a1; }
.ade-code__container--dark .token.comment { color: #6c7086; font-style: italic; }
.ade-code__container--dark .token.function { color: #89dceb; }
.ade-code__container--dark .token.number { color: #fab387; }
.ade-code__container--dark .token.operator { color: #94e2d5; }
.ade-code__container--dark .token.property { color: #cba6f7; }
.ade-code__container--dark .token.punctuation { color: #bac2de; }

.ade-code__container--light .token.keyword { color: #d73a49; }
.ade-code__container--light .token.string { color: #22863a; }
.ade-code__container--light .token.comment { color: #6a737d; font-style: italic; }
.ade-code__container--light .token.function { color: #005cc5; }
.ade-code__container--light .token.number { color: #e36209; }
.ade-code__container--light .token.operator { color: #d73a49; }
.ade-code__container--light .token.property { color: #6f42c1; }
.ade-code__container--light .token.punctuation { color: #24292e; }

/* Responsive */
@media screen and (max-width: 768px) {
    .ade-code__header {
        padding: var(--ade-space-xs) var(--ade-space-md);
    }

    .ade-code__pre {
        padding: var(--ade-space-md);
    }

    .ade-code__code {
        font-size: 12px;
    }

    .ade-code__line {
        padding-left: 50px;
    }

    .ade-code__line::before {
        width: 30px;
    }

    .ade-code__line--highlighted {
        padding-left: 47px;
    }

    .ade-code__copy-text {
        display: none;
    }
}
