/* AI Block Vibe Custom Styles */

/* Layout Defaults */
#entry-container {
    width: 75%; /* 3/4 of screen - Entry gets 75%, chat gets 25% */
    min-width: 1000px; /* Prevents overlap: 294px object panel + 250px menu + 400px assembly + 56px margins */
    max-width: calc(100% - 400px);
}

#ai-chat-container {
    flex: 1;
    min-width: 300px;
}

/* Resizer Styles */
.resizer {
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.resizer:hover {
    background: linear-gradient(to right, #4f86ec, #9966ff);
}

.resizer.resizing {
    background: linear-gradient(to right, #4f86ec, #9966ff);
    opacity: 0.8;
}

/* Prevent text selection while resizing */
body.resizing {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    cursor: col-resize !important;
}

body.resizing * {
    cursor: col-resize !important;
}

/* Chat Styles */
#chat-messages {
    scrollbar-width: thin;
    scrollbar-color: #e5e7eb #f9fafb;
}

#chat-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
    background: #f9fafb;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: #e5e7eb;
    border-radius: 3px;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
    background: #d1d5db;
}

/* Message Styles */
.user-message {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

.ai-message {
    margin-bottom: 1rem;
}

.message-content {
    max-width: 85%;
}

/* Code Block Styles */
.code-block {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 0.5rem;
    margin: 0.5rem 0;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}

.code-block::-webkit-scrollbar {
    height: 6px;
}

.code-block::-webkit-scrollbar-track {
    background: #334155;
}

.code-block::-webkit-scrollbar-thumb {
    background: #64748b;
    border-radius: 3px;
}

/* Entry Workspace Placeholder Animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

#entry-workspace .text-gray-400 {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Modal Backdrop Animation */
#api-key-modal {
    animation: fadeIn 0.2s ease-out;
}

#api-key-modal.hidden {
    animation: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#api-key-modal > div {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Button Hover Effects */
button {
    transition: all 0.2s ease;
}

button:active {
    transform: scale(0.98);
}

/* Input Focus Effects */
input:focus, textarea:focus {
    box-shadow: 0 0 0 3px rgba(79, 134, 236, 0.1);
}

/* Status Indicator Animation */
@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

#api-status span.w-2 {
    animation: blink 2s infinite;
}

#api-status span.w-2.bg-green-500 {
    animation: none;
}

/* Loading Spinner */
.spinner {
    border: 2px solid #f3f4f6;
    border-top: 2px solid #4f86ec;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Markdown Content Styles */
.markdown-content h1 {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 1rem 0 0.5rem 0;
}

.markdown-content h2 {
    font-size: 1.25rem;
    font-weight: bold;
    margin: 1rem 0 0.5rem 0;
}

.markdown-content h3 {
    font-size: 1.125rem;
    font-weight: bold;
    margin: 1rem 0 0.5rem 0;
}

.markdown-content p {
    margin: 0.5rem 0;
}

.markdown-content ul {
    list-style-type: disc;
    margin-left: 1.5rem;
    margin: 0.5rem 0 0.5rem 1.5rem;
}

.markdown-content ol {
    list-style-type: decimal;
    margin-left: 1.5rem;
    margin: 0.5rem 0 0.5rem 1.5rem;
}

.markdown-content li {
    margin: 0.25rem 0;
}

.markdown-content code {
    background: #f3f4f6;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}

.markdown-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 0.5rem;
    margin: 0.5rem 0;
    overflow-x: auto;
}

.markdown-content pre code {
    background: transparent;
    padding: 0;
}

.markdown-content blockquote {
    border-left: 3px solid #4f86ec;
    padding-left: 1rem;
    margin: 0.5rem 0;
    color: #6b7280;
}

.markdown-content a {
    color: #4f86ec;
    text-decoration: underline;
}

.markdown-content a:hover {
    color: #2563eb;
}

/* Sprite Selector Modal Styles */
#sprite-selector-modal {
    animation: fadeIn 0.2s ease-out;
}

#sprite-selector-modal > div {
    animation: slideIn 0.3s ease-out;
}

.sprite-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border: 2px solid transparent;
    border-radius: 0.5rem;
    background: #f9fafb;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sprite-item:hover {
    border-color: #4f86ec;
    background: #eff6ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 134, 236, 0.1);
}

.sprite-item:active {
    transform: translateY(0);
}

.sprite-item img {
    width: 60px;
    height: 60px;
    border-radius: 0.25rem;
    margin-bottom: 0.5rem;
}

.sprite-item span {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    text-align: center;
}

#sprite-gallery {
    max-height: 400px;
}

#sprite-gallery::-webkit-scrollbar {
    width: 6px;
}

#sprite-gallery::-webkit-scrollbar-track {
    background: #f9fafb;
}

#sprite-gallery::-webkit-scrollbar-thumb {
    background: #e5e7eb;
    border-radius: 3px;
}

#sprite-gallery::-webkit-scrollbar-thumb:hover {
    background: #d1d5db;
}

/* EntryJS Workspace Layout Fixes */
/* Force EntryJS to use full container width */
#entry-workspace .entryWorkspace {
    width: 100% !important;
}

/* Ensure block menu has reasonable width */
#entry-workspace .blockMenu {
    min-width: 250px !important;
}

/* Fix playground workspace flex layout */
#entry-workspace .entryPlaygroundWorkspace {
    flex: 1 !important;
    min-width: 0 !important;
}

/* Ensure block coding area has proper dimensions */
#entry-workspace .entryBlocklyWorkspace,
#entry-workspace .blocklyMainBackground {
    width: 100% !important;
}

/* Fix block assembly area width */
#entry-workspace .entryBlocklyDiv {
    flex: 1 !important;
    min-width: 400px !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    #entry-container {
        width: 100%;
        max-width: 100%;
        min-width: 100%;
    }

    #ai-chat-container {
        display: none;
    }

    .resizer {
        display: none;
    }

    #sprite-selector-modal > div {
        width: 90vw;
        margin: 0 1rem;
    }

    #sprite-gallery {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Chat Font Sizes - 1.2x increase for elementary students */
.chat-message-text {
    font-size: 19px !important;
    line-height: 1.5;
}

.chat-input-text {
    font-size: 19px !important;
    line-height: 1.5;
}

/* EntryJS Toolbar Header Height - Match with AI Chat Header (38px) */
/* AI chat header height adjusted to match EntryJS .entrySceneWorkspace height */