/* =========================================================
   live-examples Page Specific Styles
   ========================================================= */

:root {
    --iron-text: #1c1b1f;
    --iron-text-dim: #49454e;
    --iron-text-mute: #79747e;
    --iron-border: rgba(0, 0, 0, 0.12);
    --primary-blue: #4f46e5;
    --primary-blue-hover: #4338ca;
    --button-gray: #d1d5db;
    --button-gray-hover: #9ca3af;
    --bg-light: #f5f5f5;
}

* { box-sizing: border-box; }

body.examples-page {
    margin: 0;
    min-height: 100vh;
    font-family: 'Roboto', 'Inter', 'Segoe UI', Arial, sans-serif;
    color: var(--iron-text);
    background: #ffffff;
    overflow-x: hidden;
}

/* ============== LAYOUT ============== */
.examples-shell {
    display: grid;
    grid-template-columns: 1fr;
    height: 100vh;
}

.examples-main {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.examples-content {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 20px;
    padding: 20px;
    flex: 1;
    overflow: hidden;
}

/* ============== EDITOR PANEL ============== */
.editor-panel {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid var(--iron-border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100vh;
    margin: auto;
}

/* ============== BUTTONS ============== */
.ghost-button,
.primary-button,
.action-button {
    vertical-align: middle;
    justify-content: center;
    align-items: center;
    height: 30px;
    margin: 0;
    display: inline-flex;
    box-shadow: none;
    border-radius: 6px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 400;
    font-family: 'Roboto', Arial, sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 6px;
}

/* Run Button - Blue */
.ghost-button {
    background: var(--primary-blue);
    border: 2px solid var(--primary-blue);
    color: #ffffff;
}

.ghost-button:hover:not(:disabled) {
    background: var(--primary-blue-hover);
    border-color: var(--primary-blue-hover);
}

.ghost-button:active:not(:disabled) {
    transform: scale(0.98);
}

.ghost-button:disabled {
    opacity: 1;
    cursor: not-allowed;
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    color: #ffffff;
}

.ghost-button:disabled svg {
    opacity: 1;
}

/* Download & Copy Buttons - White */
.primary-button,
.action-button {
    background: #ffffff;
    border: 2px solid var(--button-gray);
    color: var(--iron-text);
}

.primary-button:hover:not(:disabled),
.action-button:hover:not(:disabled) {
    background: var(--bg-light);
    border-color: var(--button-gray-hover);
    color: var(--iron-text);
}

.primary-button:active:not(:disabled),
.action-button:active:not(:disabled) {
    transform: scale(0.98);
}

.primary-button:disabled,
.action-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--bg-light);
    color: var(--iron-text-mute);
}

.action-button .e-icons {
    font-size: 14px;
}

.action-button .btn-text,
.ghost-button .btn-text {
    font-size: 13px;
    font-weight: 400;
}

/* ============== PANEL HEADER ============== */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: #ffffff;
    border-bottom: 1px solid var(--iron-border);
    font-weight: 600;
    font-size: 14px;
    color: var(--iron-text);
    gap: 12px;
    font-family: 'Roboto', Arial, sans-serif;
}

.sample-name {
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #111827;
    flex: auto;
    justify-content: flex-start;
    align-items: center;
    min-width: 0;
    margin: 0;
    padding: 0;
    font-family: 'Roboto', Arial, sans-serif;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    display: flex;
    overflow: hidden;
}

.sample-name .chip-label {
    color: #4b5563;
    align-items: center;
    margin-left: 6px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    display: inline-flex;
}

.panel-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    max-width: 100%;
}

.panel-actions .download-btn {
    max-width: 200px;
    padding: 0 14px;
    border: 2px solid var(--button-gray);
    margin-left: 6px;
    opacity: 1;
    pointer-events: auto;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: visible;
}

.panel-actions.has-output .download-btn {
    opacity: 1;
    pointer-events: auto;
    background: #ffffff;
    color: var(--iron-text);
    border-color: var(--button-gray);
}

.panel-actions.has-output .download-btn:hover {
    background: var(--bg-light);
    border-color: var(--button-gray-hover);
}

/* ============== EDITOR SURFACE ============== */
.editor-surface {
    flex: 1;
    background: #ffffff;
    overflow: auto;
    position: relative;
}

#editor {
    width: 100% !important;
    height: 100% !important;
    background: #ffffff !important;
}

/* ============== LOADING SPINNER ============== */
#loading.loading-spinner {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.85);
    z-index: 5;
    pointer-events: none;
}

#loading.loading-spinner::after {
    content: "";
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid rgba(0, 0, 0, 0.12);
    border-top-color: #2196f3;
    animation: live-examples-spin 0.8s linear infinite;
}

@keyframes live-examples-spin {
    to { transform: rotate(360deg); }
}

/* ============== RESPONSIVE ============== */
/* Tablet & Mobile - Hide button text, show only icons */
@media (max-width: 768px) {
    .examples-content {
        padding: 0;
        gap: 0;
    }

    .editor-panel {
        border-radius: 0;
        border: none;
    }

    .panel-header {
        padding: 10px 12px;
        font-size: 12px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .sample-name {
        font-size: 12px;
    }

    .panel-actions {
        gap: 6px;
    }

    /* Hide button text on mobile - show only icons */
    .ghost-button .btn-text,
    .action-button .btn-text {
        display: none;
    }

    /* Make buttons icon-only on mobile */
    .ghost-button,
    .action-button {
        padding: 0 8px;
        min-width: 30px;
    }

    .ghost-button svg,
    .action-button svg,
    .action-button .e-icons {
        font-size: 14px;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .panel-header {
        padding: 8px 10px;
    }

    .ghost-button,
    .action-button {
        padding: 0 6px;
        min-width: 28px;
        height: 28px;
    }

    .ghost-button svg,
    .action-button svg,
    .action-button .e-icons {
        font-size: 12px;
    }
}

.editor-surface {
    position: relative;
}

.error-panel {
    display: none;
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 2000;
    background: #fff1f2;
    border: 1px solid #f43f5e;
    border-radius: 10px;
    color: #881337;
    box-shadow: 0 12px 30px rgba(0,0,0,.18);
    overflow: hidden;
}

    .error-panel.show {
        display: block;
    }

.error-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: rgba(244,63,94,.08);
    border-bottom: 1px solid rgba(244,63,94,.2);
}

.error-panel-title {
    font-size: 13px;
    font-weight: 700;
}

.error-close-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: #881337;
    font-size: 22px;
    cursor: pointer;
}

.error-panel-body {
    padding: 12px;
    max-height: 180px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}