/**
 * Sandbox Styles - SlideMind
 *
 * Styles dédiés au sandbox et au debug panel.
 *
 * @package SlideMind
 * @since 2.0.0
 */

/* Session Indicator */
.sm-session-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--sm-gray-500);
    margin-bottom: 16px;
    padding: 8px 12px;
    background: var(--sm-gray-50);
    border-radius: var(--sm-radius);
}

.sm-session-indicator .sm-session-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sm-success);
    flex-shrink: 0;
}

.sm-session-indicator.disconnected .sm-session-dot {
    background: var(--sm-gray-400);
}

/* Restored Notice */
.sm-restored-notice {
    padding: 12px 16px;
    background: var(--sm-primary-light);
    border-radius: var(--sm-radius);
    font-size: 13px;
    color: var(--sm-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: sm-fade-in 0.3s ease;
}

.sm-restored-notice .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

@keyframes sm-fade-in {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Export Button */
.sm-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 13px;
    background: var(--sm-gray-100);
    border: 1px solid var(--sm-gray-300);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--sm-gray-700);
}

.sm-export-btn:hover {
    background: var(--sm-gray-200);
    border-color: var(--sm-gray-400);
}

.sm-export-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Debug Panel Sections */
.sm-debug-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--sm-gray-200);
}

.sm-debug-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.sm-debug-section h4 {
    font-size: 12px;
    font-weight: 600;
    color: var(--sm-gray-500);
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Debug Table */
.sm-debug-table {
    width: 100%;
    font-size: 13px;
    border-collapse: collapse;
}

.sm-debug-table td {
    padding: 8px 0;
    border-bottom: 1px solid var(--sm-gray-100);
    vertical-align: top;
}

.sm-debug-table tr:last-child td {
    border-bottom: none;
}

.sm-debug-table td:first-child {
    color: var(--sm-gray-500);
    width: 45%;
    padding-right: 12px;
}

.sm-debug-table td:last-child {
    color: var(--sm-gray-800);
    font-weight: 500;
}

.sm-debug-table code {
    background: var(--sm-gray-100);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Monaco', 'Consolas', monospace;
    word-break: break-all;
}

/* Mini Tabs for prompt view */
.sm-tabs-mini {
    display: flex;
    gap: 0;
    margin-bottom: 12px;
}

.sm-tab-mini {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 500;
    color: var(--sm-gray-500);
    background: var(--sm-gray-100);
    border: 1px solid var(--sm-gray-200);
    border-right: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sm-tab-mini:first-child {
    border-radius: 6px 0 0 6px;
}

.sm-tab-mini:last-child {
    border-right: 1px solid var(--sm-gray-200);
    border-radius: 0 6px 6px 0;
}

.sm-tab-mini:hover {
    background: var(--sm-gray-200);
}

.sm-tab-mini.active {
    background: var(--sm-primary);
    color: #fff;
    border-color: var(--sm-primary);
}

.sm-tab-mini.active + .sm-tab-mini {
    border-left-color: var(--sm-primary);
}

.sm-tab-content-mini {
    display: none;
}

.sm-tab-content-mini.active {
    display: block;
}

/* Prompt Preview */
.sm-prompt-preview {
    background: var(--sm-gray-50);
    border: 1px solid var(--sm-gray-200);
    border-radius: 6px;
    padding: 14px;
    font-size: 12px;
    font-family: 'Monaco', 'Consolas', monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 200px;
    overflow-y: auto;
    margin: 0;
    line-height: 1.6;
    color: var(--sm-gray-700);
}

.sm-prompt-preview::-webkit-scrollbar {
    width: 6px;
}

.sm-prompt-preview::-webkit-scrollbar-track {
    background: var(--sm-gray-100);
    border-radius: 3px;
}

.sm-prompt-preview::-webkit-scrollbar-thumb {
    background: var(--sm-gray-300);
    border-radius: 3px;
}

.sm-prompt-rendered {
    background: var(--sm-success-light);
    border-color: var(--sm-success);
}

/* Variables Display */
.sm-variables-used,
.sm-variables-missing {
    margin-top: 12px;
    padding: 12px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.8;
}

.sm-variables-used {
    background: var(--sm-primary-light);
    color: var(--sm-gray-700);
}

.sm-variables-missing {
    background: var(--sm-warning-light);
    color: var(--sm-gray-700);
}

.sm-variables-used code,
.sm-variables-missing code {
    background: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 11px;
}

.sm-variables-used code {
    color: var(--sm-primary);
}

.sm-variables-missing code {
    color: var(--sm-warning);
}

/* Max tokens input */
#sm-sandbox-max-tokens {
    width: 100%;
    margin-top: 8px;
}

/* Card header with multiple buttons */
.sm-card-header .sm-header-buttons {
    display: flex;
    gap: 8px;
}

/* Prompt debug section */
.sm-prompt-debug {
    background: var(--sm-gray-50);
    margin: 0 -24px -24px;
    padding: 20px 24px 24px;
    border-top: 1px solid var(--sm-gray-200);
    border-radius: 0 0 var(--sm-radius) var(--sm-radius);
}

/* Prompt card above conversation */
.sm-sandbox-prompt-card {
    margin-bottom: 0;
}

.sm-sandbox-prompt-pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    background: #f3f4f6;
    padding: 14px;
    border-radius: 6px;
    font-size: 12px;
    font-family: 'Monaco', 'Consolas', monospace;
    max-height: 180px;
    overflow-y: auto;
    margin: 0;
    line-height: 1.6;
    color: var(--sm-gray-700);
    border: 1px solid var(--sm-gray-200);
}

.sm-sandbox-prompt-pre::-webkit-scrollbar {
    width: 6px;
}

.sm-sandbox-prompt-pre::-webkit-scrollbar-track {
    background: var(--sm-gray-100);
    border-radius: 3px;
}

.sm-sandbox-prompt-pre::-webkit-scrollbar-thumb {
    background: var(--sm-gray-300);
    border-radius: 3px;
}

/* Prompt info bar (model + temp + tokens badges) */
.sm-sandbox-prompt-info {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.sm-prompt-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: var(--sm-gray-100);
    border: 1px solid var(--sm-gray-200);
    border-radius: 12px;
    font-size: 11px;
    color: var(--sm-gray-600);
}

.sm-prompt-badge .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

/* Output variables repeater in sandbox sidebar */
.sm-sandbox-output-var-row {
    margin-bottom: 8px;
}

.sm-sandbox-output-var-fields {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.sm-sandbox-output-var-name {
    width: 120px;
    flex-shrink: 0;
}

.sm-sandbox-output-var-type-wrap {
    width: 100px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sm-sandbox-output-var-values {
    width: 100%;
    flex-basis: 100%;
    margin-top: 4px;
}

.sm-sandbox-output-var-desc {
    flex: 1;
    min-width: 0;
}

.sm-sandbox-output-var-remove {
    padding: 4px !important;
    width: 28px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sm-sandbox-output-var-remove .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.sm-sandbox-output-var-type-hint {
    font-size: 10px;
    color: #2271b1;
    font-style: italic;
    line-height: 1.2;
}

/* Insert variable button */
.sm-insert-variable-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.sm-insert-variable-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Config action buttons (edit slide + apply changes) */
.sm-sandbox-config-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.sm-sandbox-config-actions .sm-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Variable expand button */
.sm-sandbox-var-expand {
    width: 32px;
    height: 32px;
    padding: 0 !important;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sm-sandbox-var-expand .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Variable expand modal */
#sm-var-expand-modal .sm-modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#sm-var-expand-textarea {
    min-height: 200px;
    resize: vertical;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.6;
}

/* Conversation auto-grow */
.sm-sandbox-conversation-card {
    display: flex;
    flex-direction: column;
    min-height: 150px;
}

.sm-sandbox-messages {
    max-height: 60vh;
    overflow-y: auto;
    padding: 16px;
    background: #f9fafb;
    border-radius: 8px;
    margin-bottom: 16px;
}

.sm-sandbox-messages::-webkit-scrollbar {
    width: 6px;
}

.sm-sandbox-messages::-webkit-scrollbar-track {
    background: var(--sm-gray-100);
    border-radius: 3px;
}

.sm-sandbox-messages::-webkit-scrollbar-thumb {
    background: var(--sm-gray-300);
    border-radius: 3px;
}

/* ── Comparison Modal (Pro) ───────────────────────── */

/* Override modal max-width for comparison */
.sm-comparison-modal {
    max-width: 95vw !important;
    width: 95vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.sm-comparison-modal .sm-modal-body {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.sm-comparison-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Pro badge — moved to admin-global.css */

/* Config bar */
.sm-comparison-config-bar {
    background: var(--sm-gray-50);
    border: 1px solid var(--sm-gray-200);
    border-radius: var(--sm-radius);
    padding: 16px;
    margin-bottom: 20px;
}

.sm-comparison-config-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.sm-comparison-config-detail {
    font-size: 13px;
    color: var(--sm-gray-600);
    flex-basis: 100%;
    margin-bottom: 4px;
}

.sm-comparison-prompt-preview {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 12px;
    color: var(--sm-gray-500);
}

.sm-comparison-message-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sm-comparison-message-wrap .sm-form-label {
    margin-bottom: 0;
    font-size: 12px;
}

/* Panels container */
.sm-comparison-panels {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

/* Individual panel */
.sm-comparison-panel {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--sm-gray-200);
    border-radius: var(--sm-radius);
    background: #fff;
    display: flex;
    flex-direction: column;
}

.sm-comparison-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--sm-gray-200);
    background: var(--sm-gray-50);
    border-radius: var(--sm-radius) var(--sm-radius) 0 0;
}

.sm-comparison-panel-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--sm-gray-500);
    text-transform: uppercase;
    white-space: nowrap;
}

.sm-comparison-panel-header .sm-form-select {
    flex: 1;
    min-width: 0;
    font-size: 13px;
}

.sm-comparison-panel-body {
    padding: 16px;
    flex: 1;
    max-height: 400px;
    overflow-y: auto;
    min-height: 120px;
}

.sm-comparison-panel-body::-webkit-scrollbar {
    width: 6px;
}

.sm-comparison-panel-body::-webkit-scrollbar-track {
    background: var(--sm-gray-100);
    border-radius: 3px;
}

.sm-comparison-panel-body::-webkit-scrollbar-thumb {
    background: var(--sm-gray-300);
    border-radius: 3px;
}

.sm-comparison-panel-placeholder {
    text-align: center;
    padding: 40px 20px;
    color: var(--sm-gray-400);
    font-size: 13px;
}

.sm-comparison-panel-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
}

.sm-comparison-response {
    font-size: 13px;
    line-height: 1.6;
    color: var(--sm-gray-800);
}

.sm-comparison-error {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
    background: #fee2e2;
    border-radius: 6px;
    color: #991b1b;
    font-size: 13px;
}

.sm-comparison-error .dashicons {
    flex-shrink: 0;
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Panel metrics */
.sm-comparison-panel-metrics {
    display: flex;
    gap: 12px;
    padding: 10px 16px;
    border-top: 1px solid var(--sm-gray-200);
    background: var(--sm-gray-50);
    border-radius: 0 0 var(--sm-radius) var(--sm-radius);
    flex-wrap: wrap;
}

.sm-comparison-metric {
    font-size: 12px;
    color: var(--sm-gray-500);
    display: flex;
    align-items: center;
    gap: 4px;
}

.sm-comparison-metric strong {
    color: var(--sm-gray-800);
}

/* Winner badge */
.sm-comparison-winner {
    display: inline-block;
    background: var(--sm-success);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
    vertical-align: middle;
}

/* Add model panel */
.sm-comparison-add-panel {
    border-style: dashed;
    border-color: var(--sm-gray-300);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.sm-comparison-add-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--sm-gray-400);
    cursor: pointer;
    padding: 20px;
    font-size: 13px;
    transition: color 0.2s ease;
}

.sm-comparison-add-btn:hover {
    color: var(--sm-primary);
}

.sm-comparison-add-btn .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
}

/* Summary table */
.sm-comparison-summary {
    margin-bottom: 20px;
}

.sm-comparison-summary h4 {
    font-size: 12px;
    font-weight: 600;
    color: var(--sm-gray-500);
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sm-comparison-summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.sm-comparison-summary-table th,
.sm-comparison-summary-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--sm-gray-100);
}

.sm-comparison-summary-table th {
    font-weight: 600;
    color: var(--sm-gray-700);
    background: var(--sm-gray-50);
}

.sm-comparison-summary-table td:first-child {
    color: var(--sm-gray-500);
    font-weight: 500;
}

/* Footer buttons */
.sm-comparison-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--sm-gray-200);
}

/* Spin animation for loading */
.sm-spin {
    animation: sm-spin 1s linear infinite;
}

@keyframes sm-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Slot remove button */
.sm-comparison-slot-remove {
    flex-shrink: 0;
}

/* ── Comparison Responsive ───────────────────────── */

@media (max-width: 1200px) {
    .sm-comparison-panels {
        flex-wrap: wrap;
    }

    .sm-comparison-panel {
        flex-basis: calc(50% - 8px);
    }

    .sm-comparison-add-panel {
        flex-basis: calc(50% - 8px);
        min-height: 150px;
    }
}

@media (max-width: 768px) {
    .sm-comparison-modal {
        max-width: 100vw !important;
        width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    .sm-comparison-panels {
        flex-direction: column;
    }

    .sm-comparison-panel,
    .sm-comparison-add-panel {
        flex-basis: 100%;
    }

    .sm-comparison-panel-body {
        max-height: 250px;
    }
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .sm-sandbox-layout {
        grid-template-columns: 1fr !important;
    }

    .sm-sandbox-sidebar {
        order: -1;
    }

    .sm-sandbox-output-var-fields {
        flex-wrap: wrap;
    }

    .sm-sandbox-output-var-name,
    .sm-sandbox-output-var-type-wrap {
        width: calc(50% - 3px);
    }

    .sm-sandbox-output-var-desc {
        width: 100%;
        flex-basis: 100%;
    }
}

/* ── Sandbox message bubbles ────────────────────────────────────────────── */

.sm-sandbox-message {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.sm-sandbox-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sm-sandbox-message-user .sm-sandbox-message-avatar {
    background: var(--sm-primary);
    color: #fff;
}

.sm-sandbox-message-assistant .sm-sandbox-message-avatar {
    background: var(--sm-success);
    color: #fff;
}

.sm-sandbox-message-content {
    background: #fff;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 80%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    line-height: 1.5;
}

.sm-sandbox-message-user .sm-sandbox-message-content {
    background: var(--sm-primary-light);
}

.sm-sandbox-typing {
    display: flex;
    gap: 4px;
    padding: 8px;
}

.sm-sandbox-typing span {
    width: 8px;
    height: 8px;
    background: var(--sm-gray-400);
    border-radius: 50%;
    animation: sm-typing 1.4s ease-in-out infinite;
}

.sm-sandbox-typing span:nth-child(2) { animation-delay: 0.2s; }
.sm-sandbox-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes sm-typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}
