/* Stage and console panel styles */

#output-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    min-width: 500px;
}

/* Stage wrapper */
#stage-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    background-color: var(--bg-secondary);
    min-height: 200px;
    overflow: auto;
}

#stage-wrapper > .panel-header {
    width: 100%;
    max-width: 960px;
}

#stage-wrapper .panel-header {
    margin-bottom: 10px;
    background-color: transparent;
    border-bottom: none;
    padding: 0;
}

#stage-container {
    width: 960px;
    height: 720px;
    flex-shrink: 0;
    background-color: #ffffff;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transform-origin: top center;
}

#stage-container canvas {
    display: block;
}

/* Ask input box (like Scratch's ask and wait) */
#ask-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.9));
    padding: 12px 15px;
    display: none;
    flex-direction: column;
    gap: 8px;
    border-top: 2px solid #4a90d9;
    z-index: 100;
}

#ask-container.visible {
    display: flex;
}

#ask-prompt {
    font-size: 14px;
    color: #333;
    font-weight: 500;
    margin: 0;
}

#ask-input-wrapper {
    display: flex;
    gap: 8px;
}

#ask-input {
    flex: 1;
    padding: 8px 12px;
    font-size: 14px;
    border: 2px solid #4a90d9;
    border-radius: 20px;
    outline: none;
    font-family: inherit;
}

#ask-input:focus {
    border-color: #2e6bb0;
    box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.3);
}

#ask-submit {
    padding: 8px 16px;
    background-color: #4a90d9;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

#ask-submit:hover {
    background-color: #2e6bb0;
}

#ask-submit:active {
    background-color: #1e5a9a;
}

/* Vertical Resizer (between stage and console) */
#vertical-resizer {
    height: 6px;
    background-color: var(--bg-tertiary);
    cursor: ns-resize;
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}

#vertical-resizer:hover {
    background-color: var(--accent-primary);
}

/* Console wrapper */
#console-wrapper {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    min-height: 50px;
    height: 150px;
}

#console-output {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.4;
    background-color: var(--bg-primary);
}

.console-line {
    padding: 2px 0;
    color: var(--text-primary);
    word-wrap: break-word;
}

.console-line:before {
    content: '> ';
    color: var(--accent-primary);
}

.console-error {
    color: var(--accent-danger) !important;
}

.console-error:before {
    content: '✗ ';
    color: var(--accent-danger);
}

.console-warning {
    color: var(--accent-warning) !important;
}

.console-warning:before {
    content: '⚠ ';
    color: var(--accent-warning);
}

/* Loading state */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
}

.loading:after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--accent-primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

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

/* Fullscreen button */
#btn-fullscreen {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s;
    margin-left: auto;
}

#btn-fullscreen:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

#stage-wrapper .panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Fullscreen mode styles */
#stage-container:fullscreen,
#stage-container:-webkit-full-screen,
#stage-container:-moz-full-screen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    border: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    background-color: #000 !important;
    /* Reset any transforms */
    transform: none !important;
    transform-origin: center center !important;
    /* Center content */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
    /* Reset flex/aspect properties from mobile */
    flex: unset !important;
    aspect-ratio: unset !important;
    z-index: 999999 !important;
}

#stage-container:fullscreen canvas,
#stage-container:-webkit-full-screen canvas,
#stage-container:-moz-full-screen canvas {
    /* Position canvases absolutely, centered via JS */
    position: absolute !important;
    transform-origin: center center !important;
}

/* Hide ask container in fullscreen - position it properly */
#stage-container:fullscreen #ask-container,
#stage-container:-webkit-full-screen #ask-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-width: 600px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    #stage-container {
        width: 100%;
        min-width: auto;
        max-width: 640px;
        height: auto;
        min-height: auto;
        max-height: none;
        aspect-ratio: 4 / 3;
    }

    #output-panel {
        min-width: 350px;
    }
}

@media (max-width: 768px) {
    #main-content {
        flex-direction: column;
    }

    #editor-panel {
        width: 100% !important;
        height: 40vh;
        min-height: 200px;
        max-height: 45vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    #output-panel {
        min-width: 0 !important;
        width: 100% !important;
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    #resizer {
        display: none;
    }

    #stage-wrapper {
        padding: 5px;
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    #stage-wrapper .panel-header {
        flex-shrink: 0;
    }

    #stage-container {
        flex: 1;
        width: 100% !important;
        min-width: auto !important;
        max-width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        max-height: 100% !important;
        aspect-ratio: unset !important;
        margin: 0;
        transform-origin: top left !important;
    }

    /* Hide console and vertical resizer on mobile to give more space to stage */
    #console-wrapper,
    #vertical-resizer {
        display: none;
    }
}

@media (max-width: 480px) {
    #editor-panel {
        height: 35vh;
        min-height: 180px;
        max-height: 40vh;
    }

    #stage-wrapper .panel-header {
        font-size: 11px;
        padding: 0 5px;
    }

    #btn-fullscreen {
        padding: 4px 6px;
        font-size: 12px;
    }
}
