/* ==================== */

/* Sandbox Tool Improvement */

/* ==================== */

/* Workspace View (inside Studio) */
.studio-sandbox-view {
    display: none;
    flex-direction: column;
    height: 100%;
}

.studio-sandbox-view.active {
    display: flex;
}

.sandbox-workspace-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    flex-shrink: 0;
}

.sandbox-workspace-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-primary);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.sandbox-workspace-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Chat panel — full width since preview is in a new tab */
.sandbox-chat-layout {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    padding: 0 20px;
}

.sandbox-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Reuse Studio message styles */
.sandbox-msg {
    max-width: 85%;
    line-height: 1.55;
    word-wrap: break-word;
    animation: messageSlide 0.3s ease-out;
}

.sandbox-msg-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: messageSlide 0.3s ease-out;
}

.sandbox-msg-row .sandbox-msg {
    animation: none;
    max-width: calc(100% - 42px);
}

.sandbox-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.sandbox-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(224, 231, 255, 0.8) 0%, rgba(199, 210, 254, 0.6) 100%);
    padding: 10px 14px;
    border-radius: 14px 14px 4px 14px;
    font-size: 14px;
    color: var(--color-text-primary);
}

.sandbox-msg-assistant {
    align-self: flex-start;
    background: linear-gradient(180deg, #fff 0%, #f8f9fa 100%);
    padding: 12px 16px;
    border-radius: 4px 14px 14px 14px;
    font-size: 14px;
    color: var(--color-text-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.sandbox-msg-assistant p {
    margin: 6px 0;
}

.sandbox-msg-assistant strong {
    font-weight: 600;
}

.sandbox-msg-assistant pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 14px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 12px;
    margin: 8px 0;
}

.sandbox-msg-assistant code {
    font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
    font-size: 12px;
}

/* Input area */
.sandbox-chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 0 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.sandbox-chat-input {
    flex: 1;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
    background: #fff;
    line-height: 1.4;
}

.sandbox-chat-input:focus {
    border-color: var(--color-accent, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.sandbox-chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--color-accent, #6366f1);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s, transform 0.15s;
}

.sandbox-chat-send-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.sandbox-chat-send-btn:not(:disabled):hover {
    transform: scale(1.05);
}

/* Typing indicator */
.sandbox-typing .typing-dots span {
    animation: typingBounce 1.2s infinite;
    display: inline-block;
    font-size: 20px;
    line-height: 1;
    color: var(--color-text-secondary);
}

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

/* Warning card */
.sandbox-warning-card {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b;
    border-radius: 10px;
    padding: 10px 14px;
    margin: 8px 0;
    font-size: 13px;
    line-height: 1.5;
    color: #92400e;
}

.sandbox-warning-icon {
    font-size: 15px;
    margin-right: 4px;
}

/* Patch blocks (collapsible in chat) */
.sandbox-patch-block {
    margin: 8px 0;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    overflow: hidden;
}

.sandbox-patch-label {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    background: rgba(0, 0, 0, 0.02);
    cursor: pointer;
    user-select: none;
}

.sandbox-patch-label::marker {
    color: var(--color-text-tertiary, #9ca3af);
}

.sandbox-patch-code {
    margin: 0;
    padding: 12px;
    background: #1e1e2e;
    color: #cdd6f4;
    font-size: 11px;
    border-radius: 0;
    overflow-x: auto;
}

.sandbox-patch-code code {
    font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
    font-size: 11px;
}

/* Recommended option highlight */
.studio-ab-option-btn.recommended {
    border-color: var(--color-accent, #6366f1);
    background: rgba(99, 102, 241, 0.05);
    font-weight: 500;
}

/* Buttons */
.sandbox-back-btn {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s;
}

.sandbox-back-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.sandbox-preview-btn,
.sandbox-submit-btn {
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.12);
    transition: all 0.15s;
}

.sandbox-preview-btn {
    background: #fff;
    color: var(--color-text-primary);
}

.sandbox-preview-btn:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.04);
}

.sandbox-preview-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.sandbox-submit-btn {
    background: var(--color-accent, #6366f1);
    color: white;
    border-color: transparent;
}

.sandbox-submit-btn:hover {
    opacity: 0.9;
}

/* ==================== */

/* Preview Tab Toolbar */

/* ==================== */

.sandbox-preview-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    background: linear-gradient(135deg, #312e81 0%, #4338ca 100%);
    color: white;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sandbox-toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sandbox-toolbar-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.sandbox-toolbar-title {
    font-weight: 500;
    opacity: 0.9;
}

.sandbox-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sandbox-toolbar-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.sandbox-toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.sandbox-toolbar-close {
    background: rgba(255, 255, 255, 0.2);
}

/* Push page content down when preview toolbar is visible */
.sandbox-preview-mode {
    padding-top: 44px;
}

/* ==================== */

/* Responsive */

/* ==================== */

@media (width <= 768px) {
    .sandbox-chat-layout {
        padding: 0 12px;
    }

    .sandbox-workspace-header {
        padding: 10px 12px;
        gap: 8px;
    }

    .sandbox-workspace-title {
        font-size: 13px;
    }

    .sandbox-preview-toolbar {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* ==================== */

/* Choice Modal (AI vs Legacy) */

/* ==================== */

.sandbox-choice-modal {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sandbox-choice-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
}

.sandbox-choice-content {
    position: relative;
    background: #fff;
    border-radius: 16px;
    padding: 28px 32px;
    max-width: 560px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    animation: sandboxModalIn 0.25s ease-out;
}

@keyframes sandboxModalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.sandbox-choice-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0 0 20px;
    text-align: center;
}

.sandbox-choice-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.sandbox-choice-card {
    background: #fff;
    border: 1.5px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 20px 16px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.sandbox-choice-card:hover {
    border-color: var(--color-accent, #6366f1);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
    transform: translateY(-2px);
}

.sandbox-choice-card h4 {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    color: var(--color-text-primary);
}

.sandbox-choice-card p {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin: 0;
    line-height: 1.4;
}

.sandbox-choice-icon {
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.sandbox-choice-ai .sandbox-choice-icon {
    color: var(--color-accent, #6366f1);
}

.sandbox-choice-badge {
    font-size: 10px;
    font-weight: 600;
    color: var(--color-accent, #6366f1);
    background: rgba(99, 102, 241, 0.08);
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.3px;
}

.sandbox-choice-cancel {
    display: block;
    margin: 0 auto;
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 13px;
    cursor: pointer;
    padding: 6px 16px;
}

.sandbox-choice-cancel:hover {
    color: var(--color-text-primary);
}

@media (width <= 480px) {
    .sandbox-choice-options {
        grid-template-columns: 1fr;
    }
}

/* ==================== */

/* Review Pipeline — Sandbox Items */

/* ==================== */

.sandbox-review-badge {
    display: inline-block;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    margin-right: 4px;
    vertical-align: middle;
    letter-spacing: 0.3px;
}

.sandbox-risk-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: auto;
}

.sandbox-risk-badge.risk-green {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}

.sandbox-risk-badge.risk-yellow {
    background: rgba(234, 179, 8, 0.1);
    color: #ca8a04;
}

.sandbox-risk-badge.risk-red {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.sandbox-review-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-bottom: 12px;
}

.sandbox-review-flags {
    color: #ca8a04;
    font-weight: 500;
}

.sandbox-review-patches {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.sandbox-review-patch {
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 6px;
    overflow: hidden;
}

.sandbox-review-patch-header {
    padding: 6px 10px;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.02);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sandbox-patch-type-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

.sandbox-patch-css {
    background: #dbeafe;
    color: #1d4ed8;
}

.sandbox-patch-html {
    background: #fce7f3;
    color: #be185d;
}

.sandbox-patch-js {
    background: #fef3c7;
    color: #92400e;
}

.sandbox-review-patch-code {
    margin: 0;
    padding: 10px 12px;
    background: #1e1e2e;
    color: #cdd6f4;
    font-size: 11px;
    overflow-x: auto;
    border-radius: 0;
}

.sandbox-review-patch-code code {
    font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
}

.sandbox-review-flags-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.sandbox-review-flag {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.4;
}

.sandbox-review-flag.flag-warning {
    background: rgba(234, 179, 8, 0.08);
    color: #92400e;
}

.sandbox-review-flag.flag-critical {
    background: rgba(239, 68, 68, 0.08);
    color: #991b1b;
}

.sandbox-flag-severity {
    font-size: 14px;
    flex-shrink: 0;
}

.sandbox-review-empty {
    font-size: 12px;
    color: var(--color-text-tertiary, #9ca3af);
    font-style: italic;
}

/* Security Review Modal */

.sandbox-security-content {
    max-width: 520px;
}

.sandbox-security-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.sandbox-rec-badge {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary, #6b7280);
    background: var(--color-bg-secondary, #f3f4f6);
    padding: 3px 10px;
    border-radius: 6px;
}

.sandbox-security-text {
    font-size: 14px;
    color: var(--color-text-primary, #1f2937);
    line-height: 1.5;
    margin-bottom: 16px;
}

.sandbox-review-findings {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    max-height: 240px;
    overflow-y: auto;
}

.sandbox-finding {
    padding: 10px 14px;
    border-radius: 8px;
    border-left: 3px solid;
}

.finding-critical {
    background: rgba(239, 68, 68, 0.06);
    border-left-color: var(--color-error, #ef4444);
}

.finding-warning {
    background: rgba(245, 158, 11, 0.06);
    border-left-color: var(--color-warning, #f59e0b);
}

.finding-info {
    background: rgba(59, 130, 246, 0.06);
    border-left-color: var(--color-primary, #6366f1);
}

.sandbox-finding-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.sandbox-finding-icon {
    font-size: 14px;
}

.sandbox-finding-category {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-secondary, #6b7280);
}

.sandbox-finding-desc {
    font-size: 13px;
    color: var(--color-text-primary, #1f2937);
    line-height: 1.4;
    margin: 0;
}

.sandbox-finding-mitigation {
    font-size: 12px;
    color: var(--color-text-secondary, #6b7280);
    margin: 4px 0 0;
    font-style: italic;
}

.sandbox-security-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.sandbox-security-actions .sandbox-choice-card {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    min-width: auto;
}

.sandbox-security-actions .sandbox-choice-cancel {
    padding: 10px 20px;
}

/* Edge function patch block accent */

.sandbox-patch-edge-fn > .sandbox-patch-label {
    color: var(--color-error, #ef4444);
}

.sandbox-ef-badge {
    background: var(--color-error, #ef4444) !important;
    color: #fff !important;
}

.sandbox-ai-review-summary {
    font-size: 12px;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: var(--color-bg-secondary, #f3f4f6);
    border-radius: 6px;
    color: var(--color-text-primary, #1f2937);
    line-height: 1.4;
}

.sandbox-ai-review-label {
    font-weight: 600;
    color: var(--color-primary, #6366f1);
}

.sandbox-patch-type-badge.sandbox-patch-edge_function {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-error, #ef4444);
}

.sandbox-activity-panel {
    position: fixed;
    bottom: 0;
    right: 16px;
    width: 420px;
    max-width: calc(100vw - 32px);
    z-index: 10001;
    background: var(--color-card-bg, #fff);
    border: 1px solid var(--color-border, #e5e7eb);
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
    font-family: Inter, sans-serif;
    font-size: 12px;
}

.sandbox-activity-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
    user-select: none;
}

.sandbox-activity-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--color-text-primary, #1f2937);
    flex: 1;
}

.sandbox-activity-count {
    background: var(--color-primary, #6366f1);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.sandbox-activity-count.has-violations {
    background: var(--color-error, #ef4444);
}

.sandbox-activity-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: var(--color-text-secondary, #6b7280);
    padding: 2px 4px;
}

.sandbox-activity-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.sandbox-activity-body.expanded {
    max-height: 320px;
    overflow-y: auto;
}

.sandbox-activity-entries {
    padding: 4px 0;
}

.sandbox-activity-entry {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-bottom: 1px solid var(--color-border-light, #f3f4f6);
    font-size: 11px;
    line-height: 1.4;
}

.sandbox-activity-entry:hover {
    background: var(--color-hover, #f9fafb);
}

.sandbox-entry-blocked {
    background: rgba(239, 68, 68, 0.06);
}

.sandbox-entry-blocked:hover {
    background: rgba(239, 68, 68, 0.1);
}

.sandbox-entry-icon {
    font-size: 13px;
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}

.sandbox-entry-type {
    color: var(--color-text-tertiary, #9ca3af);
    width: 68px;
    flex-shrink: 0;
    text-transform: uppercase;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.sandbox-entry-method {
    color: var(--color-primary, #6366f1);
    font-weight: 600;
    width: 52px;
    flex-shrink: 0;
}

.sandbox-entry-url {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text-primary, #1f2937);
}

.sandbox-entry-result {
    color: var(--color-text-secondary, #6b7280);
    flex-shrink: 0;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sandbox-entry-blocked .sandbox-entry-result {
    color: var(--color-error, #ef4444);
    font-weight: 600;
}

.sandbox-entry-time {
    color: var(--color-text-tertiary, #9ca3af);
    font-size: 10px;
    flex-shrink: 0;
    width: 60px;
    text-align: right;
}

/* Violations section */

.sandbox-activity-violations {
    border-top: 1px solid var(--color-border, #e5e7eb);
}

.sandbox-violations-header {
    padding: 8px 14px;
    font-weight: 600;
    font-size: 12px;
    color: var(--color-error, #ef4444);
    background: rgba(239, 68, 68, 0.04);
}

.sandbox-violation {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 14px;
    border-bottom: 1px solid var(--color-border-light, #f3f4f6);
    font-size: 11px;
}

.violation-critical {
    background: rgba(239, 68, 68, 0.06);
}

.violation-warning {
    background: rgba(245, 158, 11, 0.06);
}

.sandbox-violation-code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 10px;
    font-weight: 600;
    color: var(--color-error, #ef4444);
    flex-shrink: 0;
    background: rgba(239, 68, 68, 0.08);
    padding: 1px 6px;
    border-radius: 3px;
}

.violation-warning .sandbox-violation-code {
    color: var(--color-warning, #f59e0b);
    background: rgba(245, 158, 11, 0.1);
}

.sandbox-violation-msg {
    color: var(--color-text-primary, #1f2937);
    line-height: 1.4;
}

@media (width <= 480px) {
    .sandbox-activity-panel {
        right: 0;
        width: 100%;
        border-radius: 10px 10px 0 0;
    }

    .sandbox-entry-time {
        display: none;
    }
}

/* ==================== */

/* Version History Panel (Phase 4A) */

/* ==================== */

.sandbox-history-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 320px;
    max-width: 90%;
    background: var(--color-card-bg, #fff);
    border-left: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s ease;
}

.sandbox-history-panel.open {
    transform: translateX(0);
}

.sandbox-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

.sandbox-history-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
}

.sandbox-history-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
}

.sandbox-history-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

.sandbox-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.sandbox-history-loading,
.sandbox-history-empty {
    font-size: 13px;
    color: var(--color-text-tertiary, #9ca3af);
    text-align: center;
    padding: 24px 16px;
    margin: 0;
}

.sandbox-history-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    transition: background 0.15s;
}

.sandbox-history-item:hover {
    background: rgba(0, 0, 0, 0.03);
}

.sandbox-history-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.sandbox-history-version {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-primary, #6366f1);
}

.sandbox-history-status {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    letter-spacing: 0.3px;
}

.sandbox-status-draft {
    background: rgba(107, 114, 128, 0.1);
    color: #6b7280;
}

.sandbox-status-submitted {
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
}

.sandbox-status-in_review {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.sandbox-status-approved {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}

.sandbox-status-rejected {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.sandbox-status-deployed {
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
}

.sandbox-history-preview {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin: 0 0 4px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.sandbox-history-date {
    font-size: 11px;
    color: var(--color-text-tertiary, #9ca3af);
}

@media (width <= 480px) {
    .sandbox-history-panel {
        width: 100%;
        max-width: 100%;
    }
}

/* ==================== */

/* Collaborative Comments (Phase 4B) */

/* ==================== */

.sandbox-comments-section {
    margin: 12px 0 8px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 8px;
    overflow: hidden;
}

.sandbox-comments-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.sandbox-comments-thread {
    max-height: 200px;
    overflow-y: auto;
    padding: 4px 0;
}

.sandbox-comment {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.sandbox-comment:last-child {
    border-bottom: none;
}

.sandbox-comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.sandbox-comment-author {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.sandbox-comment-time {
    font-size: 10px;
    color: var(--color-text-tertiary, #9ca3af);
}

.sandbox-comment-text {
    font-size: 13px;
    color: var(--color-text-primary);
    margin: 0;
    line-height: 1.4;
}

.sandbox-comment-input-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(0, 0, 0, 0.01);
}

.sandbox-comment-input {
    flex: 1;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    font-family: inherit;
    outline: none;
    background: #fff;
}

.sandbox-comment-input:focus {
    border-color: var(--color-accent, #6366f1);
}

.sandbox-comment-send {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: var(--color-accent, #6366f1);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s;
}

.sandbox-comment-send:hover {
    opacity: 0.85;
}

/* ==================== */

/* Template Library (Phase 4C) */

/* ==================== */

.sandbox-choice-options-3col {
    grid-template-columns: 1fr 1fr 1fr;
}

.sandbox-template-picker-content {
    max-width: 640px;
}

.sandbox-template-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
    max-height: 360px;
    overflow-y: auto;
}

.sandbox-template-card {
    background: #fff;
    border: 1.5px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    padding: 14px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sandbox-template-card:hover {
    border-color: var(--color-accent, #6366f1);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
    transform: translateY(-1px);
}

.sandbox-template-card-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
}

.sandbox-template-card-desc {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin: 0;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.sandbox-template-card-meta {
    font-size: 11px;
    color: var(--color-text-tertiary, #9ca3af);
    margin-top: auto;
}

@media (width <= 640px) {
    .sandbox-choice-options-3col {
        grid-template-columns: 1fr;
    }

    .sandbox-template-grid {
        grid-template-columns: 1fr;
    }
}
