/* ========================================
   Modern Pytalk Playground Styles
   ======================================== */

:root {
    /* Colors */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;

    /* Neutrals */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-code: #1e1e1e;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border: #334155;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Borders */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);

    /* Fonts */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========================================
   Header
   ======================================== */

.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: var(--spacing-sm) var(--spacing-xl);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.logo-section {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    flex: 1;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 400;
    text-align: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.header-links {
    display: flex;
    gap: var(--spacing-lg);
    align-items: center;
    position: absolute;
    right: var(--spacing-xl);
}

.header-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9375rem;
    transition: color 0.2s ease;
}

.header-link:hover {
    color: var(--primary-light);
}

.header-link.primary-link {
    background: var(--primary);
    color: white;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.header-link.primary-link:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

/* ========================================
   Info Banner
   ======================================== */

.info-banner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    padding: var(--spacing-sm) var(--spacing-xl);
    text-align: center;
}

.info-text {
    font-size: 0.9375rem;
    color: white;
    max-width: 1400px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ========================================
   Main Playground
   ======================================== */

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.playground {
    flex: 1;
    display: grid;
    grid-template-columns: 280px 1fr;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    gap: 0;
    padding: var(--spacing-xl);
}

/* ========================================
   Sidebar
   ======================================== */

.sidebar {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    height: fit-content;
    border: 1px solid var(--border);
}

.sidebar-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

.examples-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xl);
}

.example-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    text-align: left;
    transition: all 0.2s ease;
}

.example-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--primary);
}

.example-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.api-info {
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--border);
}

.api-info h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

.api-categories {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.api-category {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.api-category summary {
    padding: var(--spacing-sm) var(--spacing-md);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    -webkit-user-select: none;
    user-select: none;
}

.api-category summary:hover {
    color: var(--text-primary);
}

.api-list {
    list-style: none;
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.api-list li {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.api-list code {
    font-family: var(--font-mono);
    color: var(--primary-light);
    font-size: 0.8125rem;
}

.quick-ref-btn {
    background: none;
    border: none;
    padding: var(--spacing-xs) 0;
    font-size: 0.8125rem;
    color: var(--primary-light);
    cursor: pointer;
    text-align: left;
    font-family: var(--font-mono);
    transition: all 0.2s ease;
}

.quick-ref-btn:hover {
    color: var(--primary);
    text-decoration: underline;
    padding-left: var(--spacing-xs);
}

.quick-ref-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0 var(--spacing-md) var(--spacing-xs);
    margin: 0;
}

/* ========================================
   Editor Section
   ======================================== */

.editor-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 600px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}

.editor-header {
    background: var(--bg-tertiary);
    padding: var(--spacing-md) var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.editor-tabs {
    display: flex;
    gap: var(--spacing-sm);
}

.tab {
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.tab.active {
    background: var(--bg-secondary);
    color: var(--primary-light);
}

.editor-actions {
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
}

.clear-code-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-code-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    color: white;
}

.clear-code-btn:active:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
}

.clear-code-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.run-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    transition: all 0.2s ease;
}

.run-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.run-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-icon {
    font-size: 0.875rem;
}

/* ========================================
   Code Editor
   ======================================== */

.editor-container {
    flex: 1;
    background: var(--bg-code);
    overflow: hidden;
}

.editor-iframe {
    width: 100%;
    flex: 1;
    min-height: 0;
    border: none;
    background: var(--bg-code);
}

/* ========================================
   Output Section
   ======================================== */

.output-section {
    background: var(--bg-code);
    border-top: 1px solid var(--border);
}

.output-header {
    background: var(--bg-tertiary);
    padding: var(--spacing-sm) var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.output-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.clear-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--primary);
}

.output-content {
    padding: var(--spacing-lg);
    min-height: 150px;
    max-height: 300px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

.output-placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.output-line {
    margin-bottom: var(--spacing-xs);
    line-height: 1.5;
}

.output-info {
    color: var(--text-primary);
}

.output-success {
    color: var(--success);
}

.output-error {
    color: var(--error);
}

.output-warning {
    color: var(--warning);
}

/* ========================================
   Footer
   ======================================== */

.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: var(--spacing-2xl) var(--spacing-xl);
    margin-top: var(--spacing-2xl);
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-xl);
}

.footer-section h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

.footer-section p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    line-height: 1.7;
}

.footer-link {
    display: inline-block;
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 500;
    margin-top: var(--spacing-sm);
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: var(--primary);
}

.footer-note {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-style: italic;
}

.footer-copyright {
    margin-top: var(--spacing-md);
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* ========================================
   Loading Overlay
   ======================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
}

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--spacing-lg);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-spinner p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
}

/* ========================================
   Scrollbar Styling
   ======================================== */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border);
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 1024px) {
    .playground {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }

    .sidebar {
        order: 2;
    }

    .editor-section {
        order: 1;
    }

    .footer-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: var(--spacing-md);
        text-align: center;
    }

    .header-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    .playground {
        padding: var(--spacing-md);
    }
}

/* ========================================
   Animations
   ======================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.output-line {
    animation: fadeIn 0.2s ease;
}

/* ========================================
   Monaco Editor - Suggest Widget Fix (ULTIMATE FIX)
   ======================================== */

/* 補完ウィジェット全体 */
.suggest-widget {
    background: #3c3c3c !important;
    color: #eeeeee !important;
    border: 1px solid #555555 !important;
}

/* すべてのテキスト要素に白色を強制 */
.suggest-widget * {
    color: #eeeeee !important;
    visibility: visible !important;
}

/* リスト行 */
.suggest-widget .monaco-list-row {
    color: #eeeeee !important;
    background: transparent !important;
    visibility: visible !important;
}

/* 選択行（focused）- 最優先 */
.suggest-widget .monaco-list-row.focused {
    background: #264f78 !important;
    color: #ffffff !important;
    visibility: visible !important;
}

.suggest-widget .monaco-list-row.focused * {
    background: transparent !important;
    color: #ffffff !important;
    visibility: visible !important;
}

/* ラベル要素 */
.suggest-widget .monaco-icon-label {
    color: #eeeeee !important;
}

.suggest-widget .monaco-list-row.focused .monaco-icon-label {
    color: #ffffff !important;
}

.suggest-widget .label-name {
    color: #eeeeee !important;
    visibility: visible !important;
}

.suggest-widget .monaco-list-row.focused .label-name {
    color: #ffffff !important;
    visibility: visible !important;
}

/* ハイライト部分 */
.suggest-widget .monaco-highlighted-label {
    color: #eeeeee !important;
}

.suggest-widget .monaco-highlighted-label span {
    color: #4fc1ff !important;
    visibility: visible !important;
}

.suggest-widget .monaco-list-row.focused .monaco-highlighted-label span {
    color: #c7d2fe !important;
}

/* ========================================
   Features Banner
   ======================================== */

.features-banner {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-top: 1px solid var(--border);
    padding: var(--spacing-2xl);
}

.features-content {
    max-width: 1200px;
    margin: 0 auto;
}

.features-content h2 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-2xl);
    text-align: center;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-lg);
}

.feature-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    transition: all 0.3s ease;
}

.feature-card:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-light);
    transform: translateY(-2px);
}

.feature-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-light);
    margin-bottom: var(--spacing-md);
}

.feature-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}