/* =========================================================================
   BMS HIGH-TECH SAAS FEATURES UI
   Features: Code Playgrounds, PWA Offline Buttons, Smart AI Chat, SPA Progress
   ========================================================================= */

/* 1. INTERACTIVE CODE PLAYGROUND (VS Code style output) */
.bs-playground-wrapper {
    background: #1e1e1e;
    border-radius: 12px;
    overflow: hidden;
    margin: 30px 0;
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid #333;
    display: flex;
    flex-direction: column;
}

.bs-playground-header {
    background: #2d2d2d;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #444;
}

.bs-pg-lang {
    font-size: 11px;
    font-weight: 700;
    color: #6366f1;
    letter-spacing: 1px;
    background: rgba(99, 102, 241, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
}

.bs-pg-actions {
    display: flex;
    gap: 10px;
}

.bs-playground-header button {
    background: #3d3d3d;
    color: #e0e0e0;
    border: 1px solid #4d4d4d;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.bs-playground-header button:hover {
    background: #4d4d4d;
}

.bs-btn-run {
    background: #10b981 !important;
    border-color: #059669 !important;
    color: #fff !important;
    font-weight: 600;
}

.bs-btn-run:hover {
    background: #059669 !important;
}

.bs-playground-split {
    display: flex;
    flex-direction: column;
}

@media(min-width: 768px) {
    .bs-playground-split {
        flex-direction: row;
    }
}

.bs-pg-editor-container {
    flex: 1;
    min-height: 250px;
}

.bs-ace-editor {
    width: 100%;
    height: 100%;
    min-height: 250px;
}

.bs-pg-output-container {
    flex: 1;
    background: #fff;
    border-left: 1px solid #444;
    min-height: 250px;
    max-height: 600px;
    overflow: hidden;
}

.bs-pg-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}

.bs-pg-console {
    background: #000;
    color: #0f0;
    padding: 20px;
    margin: 0;
    height: 100%;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.5;
}

/* Language Selector Dropdown */
.bs-pg-lang-select {
    background: #3d3d3d;
    color: #e0e0e0;
    border: 1px solid #555;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    font-family: inherit;
    min-width: 130px;
}

.bs-pg-lang-select:focus {
    border-color: #6366f1;
}

.bs-pg-lang-select option {
    background: #2d2d2d;
    color: #e0e0e0;
}

/* Output Panel Header */
.bs-pg-output-header {
    background: #1a1a2e;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 6px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
}

.bs-pg-output-header span {
    text-transform: uppercase;
    color: #10b981;
}

.bs-btn-clear-output {
    background: transparent !important;
    border: none !important;
    color: #64748b !important;
    font-size: 11px !important;
    padding: 2px 6px !important;
    cursor: pointer;
    transition: color 0.2s !important;
}

.bs-btn-clear-output:hover {
    color: #ef4444 !important;
}

/* Copy Button */
.bs-btn-copy {
    background: #3d3d3d !important;
    color: #e0e0e0 !important;
    border: 1px solid #4d4d4d !important;
}

.bs-btn-copy:hover {
    background: #4d4d4d !important;
}

/* Disabled run button state */
.bs-btn-run:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Console colors for stdout/stderr */
.bs-pg-console {
    white-space: pre-wrap;
    word-break: break-word;
}

/* 2. FLOATING ACTION BUTTONS (Offline & AI Trigger) */
.bs-fab-btn {
    position: fixed;
    z-index: 9990;
    bottom: 30px;
    right: 30px;
    background: #4f46e5;
    color: #ffffff;
    border: none;
    padding: 14px 24px;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(79, 70, 229, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    outline: none;
}

.bs-fab-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 35px rgba(79, 70, 229, 0.4);
    background: #4338ca;
}

/* Specific positions */
#bs-offline-save-btn {
    right: 30px;
}

.bs-ai-fab {
    right: 210px;
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
}

.bs-ai-sparkle {
    color: #f59e0b;
    font-size: 18px;
}

/* Offline Save Button Animations */
#bs-offline-save-btn.saving {
    background: #f59e0b;
    pointer-events: none;
}

#bs-offline-save-btn.saving svg {
    animation: rotate 1s linear infinite;
}

#bs-offline-save-btn.saved {
    background: #10b981;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* 3. YUG 1.0 CHAT WIDGET */
#bs-ai-tutor-overlay {
    position: fixed;
    z-index: 9999;
    bottom: 90px;
    right: 30px;
    width: 350px;
    height: 500px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid #e2e8f0;
}

#bs-ai-tutor-overlay.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.bs-ai-header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.bs-ai-avatar {
    font-size: 24px;
    background: rgba(255, 255, 255, 0.1);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bs-ai-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

.bs-ai-header span {
    font-size: 12px;
    color: #94a3b8;
}

#bs-ai-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s;
}

#bs-ai-close:hover {
    color: #fff;
}

.bs-ai-chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.bs-ai-message {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    max-width: 85%;
    position: relative;
    animation: fadeInMsg 0.3s ease;
}

@keyframes fadeInMsg {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bs-ai-message.ai {
    background: #fff;
    color: #334155;
    align-self: flex-start;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.bs-ai-message.user {
    background: #4f46e5;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.bs-ai-message.error {
    background: #fef2f2;
    color: #ef4444;
    border-color: #fecaca;
}

/* Mermaid Diagram Styling */
.mermaid {
    background: #fff;
    border-radius: 8px;
    padding: 10px;
    margin-top: 10px;
    overflow-x: auto;
    border: 1px solid #f1f5f9;
}

.mermaid svg {
    max-width: 100% !important;
    height: auto !important;
}

/* Loading Dots */
.bs-ai-message.loading {
    display: flex;
    gap: 4px;
    font-size: 18px;
    padding: 10px 16px;
}

.bs-ai-message.loading span {
    animation: blink 1.4s infinite both;
}

.bs-ai-message.loading span:nth-child(2) {
    animation-delay: 0.2s;
}

.bs-ai-message.loading span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes blink {
    0% {
        opacity: 0.2;
    }

    20% {
        opacity: 1;
    }

    100% {
        opacity: 0.2;
    }
}

.bs-ai-input-area {
    padding: 15px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    align-items: center;
}

#bs-ai-input {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#bs-ai-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#bs-ai-send {
    background: #4f46e5;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

#bs-ai-send:hover {
    transform: scale(1.05);
}

/* 4. SPA Loading Progress Indicator */
#bs-spa-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: #6366f1;
    z-index: 999999;
    box-shadow: 0 0 10px #6366f1;
    transition: width 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

/* 5. INLINE CONTEXTUAL DISCUSSIONS */
#bs-inline-trigger {
    position: absolute;
    z-index: 9990;
    background: #1e293b;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#bs-inline-trigger::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px 5px 0;
    border-style: solid;
    border-color: #1e293b transparent transparent transparent;
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(10px);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

#bs-panel-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

#bs-panel-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.bs-side-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: #fff;
    z-index: 9999;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.1);
    transition: right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
}

.bs-side-panel.active {
    right: 0;
}

.bs-panel-header {
    background: #f8fafc;
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bs-panel-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

.bs-panel-header span {
    font-size: 12px;
    color: #64748b;
}

#bs-panel-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #94a3b8;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

#bs-panel-close:hover {
    color: #0f172a;
}

.bs-panel-quote-area {
    padding: 20px;
    background: #fbfbfe;
    border-bottom: 1px solid #e2e8f0;
}

#bs-active-quote {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: #475569;
    font-style: italic;
    border-left: 3px solid #6366f1;
    padding-left: 12px;
}

.bs-panel-threads {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #fff;
}

.bs-loading-notes {
    text-align: center;
    color: #64748b;
    padding: 30px 0;
}

.bs-inline-note-item {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #f1f5f9;
}

.bs-inline-note-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.bs-inline-note-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.bs-inline-note-meta strong {
    font-size: 13px;
    color: #0f172a;
}

.bs-inline-note-meta span {
    font-size: 11px;
    color: #94a3b8;
}

.bs-inline-note-content {
    font-size: 14px;
    color: #334155;
    line-height: 1.5;
}

.bs-panel-input {
    padding: 20px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

#bs-inline-input {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    resize: none;
    margin-bottom: 10px;
    outline: none;
    font-family: inherit;
}

#bs-inline-input:focus {
    border-color: #6366f1;
}

#bs-inline-submit {
    width: 100%;
    background: #4f46e5;
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#bs-inline-submit:hover {
    background: #4338ca;
}

#bs-inline-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}