/* Estilos para o frontend - Tema Escuro Moderno */
.academify-python-block {
    border-radius: 8px;
    background: linear-gradient(145deg, #2d3142, #4a4e69);
    padding: 0;
    margin: 24px 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Cabeçalho do bloco */
.academify-python-header {
    background: #383c51;
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.language-python{
    font-size: 0.875rem!important;
}

.academify-prism-editor {
    background: transparent !important;
}

/* Prism syntax highlighting customization */
.academify-prism-editor .token.keyword {
    color: #1b9cdd !important;
}

.academify-prism-editor .token.string {
    color: #a3be8c !important;
}

.academify-prism-editor .token.comment {
    color: #6272a4 !important;
    font-style: italic;
}

.academify-prism-editor .token.number {
    color: #bd93f9 !important;
}

.academify-prism-editor .token.function {
    color: #50fa7b !important;
}

.academify-prism-editor .token.operator {
    color: #ff79c6 !important;
}

.academify-prism-editor .token.builtin {
    color: #8be9fd !important;
}

/* Prism Line Numbers Styling - Alinhamento perfeito */
.academify-prism-editor.line-numbers {
    position: relative;
    padding-left: 3.8em;
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
    counter-reset: linenumber;
}

.academify-prism-editor.line-numbers > code {
    position: relative;
    white-space: pre;
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
}

.academify-prism-editor.line-numbers .line-numbers-rows {
    position: absolute;
    pointer-events: none;
    top: 0;
    font-size: 100%;
    left: -3.8em;
    width: 3em;
    letter-spacing: -1px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    font-family: inherit;
    line-height: inherit;
}

.academify-prism-editor.line-numbers .line-numbers-rows > span {
    pointer-events: none;
    display: block;
    counter-increment: linenumber;
    color: rgba(255, 255, 255, 0.4);
    text-align: right;
    padding-right: 0.8em;
    font-size: inherit;
    line-height: inherit;
    margin: 0;
    box-sizing: border-box;
}

.academify-prism-editor.line-numbers .line-numbers-rows > span:before {
    content: counter(linenumber);
    display: block;
    padding-right: 0.8em;
    text-align: right;
}

/* Forçar altura automática para todos os elementos Prism */
.academify-prism-editor,
.academify-prism-editor *,
.academify-prism-editor code,
.academify-prism-editor pre {
    overflow: visible !important;
    max-height: none !important;
    height: auto !important;
}

/* Garantir que não haja scroll no container */
.academify-code-container pre {
    overflow: visible !important;
    max-height: none !important;
}

.academify-python-title {
    font-weight: 600;
    font-size: 14px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.academify-python-header-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.academify-python-edit-btn,
.academify-python-copy-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.academify-python-edit-btn:hover,
.academify-python-copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.academify-python-edit-btn {
    background: rgba(27, 156, 221, 0.2);
    border-color: rgba(27, 156, 221, 0.4);
}

.academify-python-edit-btn:hover {
    background: rgba(27, 156, 221, 0.3);
}

.academify-python-editor {
    display: flex;
    flex-direction: column;
    background: #2d3142;
}

/* Container do Prism Editor */
.academify-code-container {
    position: relative;
    background: #282a36;
    overflow: visible;
    height: auto;
    overflow-x: auto;
}

.academify-prism-editor {
    position: relative;
    min-height: auto;
    max-height: none;
    overflow: visible;
    font-family: 'Fira Code', 'Monaco', 'Consolas', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    background: #2d3142;
    color: #f8f8f2;
    border: none;
    outline: none;
    padding: 20px;
    white-space: pre;
    overflow-wrap: break-word;
    height: auto;
}

.academify-prism-editor code {
    background: transparent !important;
    color: inherit !important;
    padding: 0 !important;
    font-family: inherit !important;
    font-size: inherit !important;
    line-height: inherit !important;
    display: block !important;
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
}

/* Placeholder para o editor Prism */
.academify-prism-editor.empty::before {
    content: attr(data-placeholder);
    color: rgba(255, 255, 255, 0.4);
    position: absolute;
    top: 20px;
    left: 20px;
    pointer-events: none;
    font-style: italic;
}

/* Container do ACE Editor */
.academify-ace-editor-container {
    position: relative;
    min-height: 100px;
    background: #2d3142;
    overflow: hidden;
}

.academify-ace-editor {
    width: 100% !important;
    height: auto !important;
    min-height: 100px !important;
    max-height: 60vh !important;
    font-family: 'Fira Code', 'Monaco', 'Consolas', 'Courier New', monospace !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
}

/* ACE Editor specific styles */
.academify-python-editor .ace_gutter {
    background: #282a36 !important;
} 

.academify-python-editor .ace_scroller {
    background: #282a36 !important;
}

.ace-monokai .ace_entity.ace_name.ace_tag, 
.ace-monokai .ace_keyword, 
.ace-monokai .ace_meta.ace_tag, 
.ace-monokai .ace_storage {
    color: #1b9cdd !important;
}

.academify-python-editor .ace-monokai .ace_gutter-active-line,
.academify-python-editor .ace-monokai .ace_marker-layer .ace_active-line {
    background: transparent !important;
}

/* Fallback textarea */
.academify-python-code {
    font-family: 'Fira Code', 'Monaco', 'Consolas', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    border: none;
    border-radius: 0;
    padding: 20px;
    background: #2d3142;
    color: #f8f8f2;
    resize: vertical;
    min-height: 100px;
    max-height: 60vh;
    width: 100%;
    box-sizing: border-box;
    overflow-y: auto;
}

.academify-python-code:focus {
    outline: none;
    box-shadow: none;
}

/* Botão de execução */
.academify-python-controls {
    background: #2d3142;
    padding: 15px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.academify-python-run {
    background: #229ddb;
    border: none;
    color: white;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 40px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(34,157,219,.3);
    display: flex;
    align-items: center;
    gap: 8px;
}

.academify-python-run::before {
    content: "▶";
    font-size: 12px;
}

.academify-python-run:hover:not(:disabled) {
    background: #1b9cdd;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(34,157,219,.3);
}

.academify-python-run:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.academify-python-run.loading::before {
    content: "⟳";
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Status e informações */
.academify-python-status {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    gap: 8px;
}

.academify-python-status.ready::before {
    content: "";
    width: 8px;
    height: 8px;
    background: #43aa8b;
    border-radius: 50%;
    display: inline-block;
    position: relative;
    animation: ripple 2s infinite;
}

@keyframes ripple {
    0% {
        box-shadow: 0 0 0 0 rgba(67, 170, 139, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(67, 170, 139, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(67, 170, 139, 0);
    }
}

.academify-python-status.loading::before {
    content: "";
    width: 8px;
    height: 8px;
    background: #f77f00;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Área de saída */
.academify-python-output {
    background: #1e1e1e;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    max-height: 400px;
    overflow-y: auto;
}

.academify-python-output:empty {
    display: none;
}

.academify-python-output-header {
    background: #2d3142;
    color: #1b9cdd;
    padding: 8px 20px;
    font-size: 12px;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.academify-python-output pre {
    background: #1e1e1e !important;
    color: #f8f8f2 !important;
    padding: 20px !important;
    font-family: 'Fira Code', 'Monaco', 'Consolas', 'Courier New', monospace !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
    margin: 0 !important;
    white-space: pre-wrap !important;
    word-break: break-word !important;
    border: none !important;
}

/* Estados de saída */
.academify-python-output.success .academify-python-output-header {
    background: #1b9cdd;
    color: white;
}

.academify-python-output.error .academify-python-output-header {
    background: #dd1b3d;
    color: white;
}

.academify-python-output.error pre {
    color: #ff6b6b !important;
}

.academify-python-output.loading {
    position: relative;
}

.academify-python-output.loading::before {
    content: "Executando código...";
    display: block;
    color: #f77f00;
    font-style: italic;
    padding: 15px 20px;
    font-size: 13px;
    background: #2d3142;
}

/* Scrollbar personalizada */
.academify-python-output::-webkit-scrollbar {
    width: 8px;
}

.academify-python-output::-webkit-scrollbar-track {
    background: #1e1e1e;
}

.academify-python-output::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.academify-python-output::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Responsividade */
@media (max-width: 768px) {
    .academify-python-block {
        margin: 20px 0;
    }
    
    .academify-python-header {
        padding: 10px 15px;
    }
    
    .academify-python-title {
        font-size: 13px;
    }
    
    .academify-python-code,
    .academify-prism-editor {
        min-height: 80px !important;
        max-height: 50vh !important;
        font-size: 13px !important;
        padding: 15px !important;
    }
    
    .academify-python-controls {
        padding: 12px 15px;
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .academify-python-run {
        width: 100%;
        justify-content: center;
    }
    
    .academify-python-output pre {
        padding: 15px !important;
        font-size: 12px !important;
    }
}

/* Acessibilidade */
@media (prefers-reduced-motion: reduce) {
    .academify-python-run {
        transition: none;
    }
    
    .academify-python-run:hover:not(:disabled) {
        transform: none;
    }
    
    @keyframes spin {
        from { transform: none; }
        to { transform: none; }
    }
    
    @keyframes pulse {
        0%, 100% { opacity: 1; }
        50% { opacity: 1; }
    }
}

/* Estados especiais */
.academify-python-block.readonly .academify-python-run {
    display: none;
}

.academify-python-block.compact {
    margin: 16px 0;
}

.academify-python-block.compact .academify-python-header {
    padding: 8px 15px;
}

.academify-python-block.compact .academify-python-controls {
    padding: 10px 15px;
}

/* Animações de entrada */
.academify-python-block {
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hover do bloco completo */
.academify-python-block:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    transform: translateY(-2px);
    transition: all 0.3s ease;
}

@media (prefers-reduced-motion: reduce) {
    .academify-python-block {
        animation: none;
    }
    
    .academify-python-block:hover {
        transform: none;
    }
}