/* ==================== NINJABOX DASHBOARD ==================== */

/* Wider section for 2-column layout */
#section-ninjabox.app-section {
    max-width: 1600px;
}

/* ===== 2-COLUMN GRID ===== */
.nb-dashboard {
    display: grid;
    grid-template-columns: 1fr 440px;
    gap: 24px;
    align-items: start;
    min-height: calc(100vh - 120px);
}

/* ===== LEFT: CONTROLS (scrollable) ===== */
.nb-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    scrollbar-width: thin;
    padding-right: 4px;
}

.nb-controls::-webkit-scrollbar {
    width: 4px;
}

.nb-controls::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 2px;
}

/* ===== RIGHT: PREVIEW (sticky) ===== */
.nb-preview-panel {
    position: sticky;
    top: 76px;
    max-height: calc(100vh - 92px);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ===== CARD BASE ===== */
.nb-card {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 12px;
    padding: 16px 20px;
}

.nb-card-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted, #94a3b8);
    margin-bottom: 10px;
}

/* ===== AI FRAME ARCHITECT (collapsible + sticky) ===== */
.nb-card-ai {
    background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 50%, #f5f3ff 100%);
    border: 1.5px solid #e0e7ff;
    border-radius: 16px;
    position: sticky;
    top: 0;
    z-index: 10;
    transition: box-shadow 200ms ease;
}

.nb-card-ai.nb-section--collapsed {
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.08);
}

.nb-ai-section-header {
    gap: 10px;
}

.nb-ai-icon-mini {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    font-size: 13px;
    line-height: 1;
}

.nb-card-ai .nb-ai-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
}

.nb-ai-hint {
    font-size: 11px;
    color: #818cf8;
    margin-left: auto;
    opacity: 1;
    transition: opacity 200ms;
}

.nb-card-ai:not(.nb-section--collapsed) .nb-ai-hint {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
}

.nb-ai-subtitle-expanded {
    font-size: 11px;
    color: var(--text-secondary, #64748b);
    margin-bottom: 12px;
}

.nb-ai-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr 140px;
    gap: 8px;
    margin-bottom: 12px;
}

.nb-ai-inputs label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary, #64748b);
    margin-bottom: 2px;
    display: block;
}

.nb-ai-inputs input,
.nb-ai-inputs select {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--border-light, #e2e8f0);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 200ms;
    box-sizing: border-box;
    background: #fff;
}

.nb-ai-inputs input:focus,
.nb-ai-inputs select:focus {
    border-color: #667eea;
}

.nb-ai-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nb-ai-generate-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition:
        opacity 150ms,
        transform 150ms;
    font-family: inherit;
}

.nb-ai-generate-btn:active {
    transform: scale(0.97);
}

.nb-ai-loading {
    display: none;
    align-items: center;
    gap: 10px;
}

.nb-ai-loading.active {
    display: flex;
}

.nb-ai-spinner,
.nb-spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid var(--border-light, #e2e8f0);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: nbSpin 0.6s linear infinite;
}

@keyframes nbSpin {
    to {
        transform: rotate(360deg);
    }
}

.nb-ai-loading-text {
    font-size: 12px;
    color: var(--text-secondary, #64748b);
}

/* ===== AI REASONING (inline inside AI section) ===== */
.nb-reasoning-inline {
    margin-top: 12px;
    padding: 10px 14px;
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.12);
    border-radius: 10px;
}

.nb-reasoning-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6366f1;
    margin-bottom: 4px;
}

.nb-reasoning-text {
    font-size: 12px;
    color: #475569;
    line-height: 1.4;
}

/* ===== THEME GRID ===== */
.nb-theme-grid {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ===== LAYOUT STRIP ===== */
.nb-layout-strip {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
}

.nb-layout-strip::-webkit-scrollbar {
    height: 3px;
}

.nb-layout-strip::-webkit-scrollbar-thumb {
    background: var(--border-light, #e2e8f0);
    border-radius: 2px;
}

/* ===== PREVIEW TOOLBAR ===== */
.nb-preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 4px 0;
}

/* ===== PREVIEW CONTAINER ===== */
.nb-preview-container {
    background: #e2e8f0;
    border-radius: 16px;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.nb-preview-iframe-mobile {
    width: 375px;
    height: 812px;
    border: none;
    border-radius: 36px;
    box-shadow:
        0 0 0 6px #1e293b,
        0 0 0 8px #0f172a,
        0 16px 48px rgba(0, 0, 0, 0.25);
    background: #fff;
    transform-origin: top center;
    flex-shrink: 0;
}

/* ===== COLLAPSIBLE SECTIONS ===== */
.nb-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
    transition: opacity 150ms;
}

.nb-section-header:hover {
    opacity: 0.7;
}

.nb-section-title {
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #1e293b;
    white-space: nowrap;
    position: relative;
    padding-left: 10px;
}

.nb-section-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 14px;
    background: var(--primary, #2563eb);
    border-radius: 2px;
}

.nb-section-summary {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    overflow: hidden;
    max-width: 0;
    opacity: 0;
    transition:
        max-width 300ms ease,
        opacity 200ms ease;
    white-space: nowrap;
}

.nb-section--collapsed .nb-section-summary {
    max-width: 300px;
    opacity: 1;
}

.nb-section-chevron {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    transition: transform 250ms ease;
    flex-shrink: 0;
    transform: rotate(90deg);
    line-height: 1;
}

.nb-section--collapsed .nb-section-chevron {
    transform: rotate(0deg);
}

.nb-section-body {
    overflow: hidden;
    max-height: 800px;
    opacity: 1;
    transition:
        max-height 300ms ease,
        opacity 150ms ease,
        margin-top 200ms ease;
    margin-top: 12px;
}

.nb-section--collapsed .nb-section-body {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

/* ===== DELETE CONFIRM OVERLAY ANIMATIONS ===== */
@keyframes nbFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes nbScaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== VIEW SWITCHER (Editor / Templates) ===== */
.nb-view-switcher {
    display: flex;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 3px;
    margin-bottom: 12px;
}

.nb-view-btn {
    flex: 1;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all 200ms;
    background: transparent;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.nb-view-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.7);
    color: #334155;
}

.nb-view-btn.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.25);
}

/* ===== TEMPLATE GALLERY ===== */
.nb-tpl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}

.nb-tpl-card {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 14px;
    padding: 16px;
    transition: all 200ms;
}

.nb-tpl-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.12);
    transform: translateY(-2px);
}

.nb-tpl-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nb-tpl-meta {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    margin-bottom: 10px;
}

.nb-tpl-actions {
    display: flex;
    gap: 6px;
}

.nb-tpl-empty {
    text-align: center;
    padding: 48px 24px;
}

.nb-tpl-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    #section-ninjabox.app-section {
        max-width: 1400px;
    }

    .nb-dashboard {
        grid-template-columns: 1fr;
    }

    .nb-controls {
        max-height: none;
        overflow-y: visible;
    }

    .nb-preview-panel {
        position: static;
        max-height: none;
    }

    .nb-preview-container {
        min-height: 600px;
    }
}

@media (max-width: 768px) {
    .nb-ai-inputs {
        grid-template-columns: 1fr;
    }
}
