/* ========================================
   SANDBOX CHAT PAGE STYLES
   Glass chat shell over page gradient; bubbles stay high-contrast.
   Uses: sandbox.php + shared page-header from page-header.css
   ======================================== */

/* MARK: - Chat Wrapper (glass pane) */

.sandbox-chat-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 600px;
    height: calc(100vh - 200px);
    margin: 0 0 24px;
    width: 100%;
    box-sizing: border-box;
    border-radius: var(--radius-floating);
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.14);
    box-shadow: var(--shadow-floating);
    overflow: hidden;
}

@supports (backdrop-filter: blur(20px)) {
    .sandbox-chat-wrapper {
        background: rgba(255, 255, 255, 0.12);
        backdrop-filter: saturate(180%) blur(22px);
        -webkit-backdrop-filter: saturate(180%) blur(22px);
    }
}

/* MARK: - Message Feed */

.sandbox-messages {
    flex: 1;
    overflow-y: auto;
    padding: 32px var(--section-padding-x);
    scroll-behavior: smooth;
    scrollbar-color: rgba(255, 255, 255, 0.35) transparent;
}

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

.sandbox-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 8px;
}

.sandbox-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

/* MARK: - Welcome Screen */

.sandbox-welcome {
    text-align: center;
    padding: 80px var(--section-padding-x) 40px;
    max-width: 600px;
    margin: 0 auto;
}

.sandbox-welcome-icon {
    margin-bottom: 16px;
}

.sandbox-welcome-img {
    height: 64px;
    width: auto;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
}

.sandbox-welcome h2 {
    font-size: 1.8em;
    color: var(--color-text-primary);
    font-weight: 700;
    margin-bottom: 16px;
}

.sandbox-welcome > p {
    font-size: 1em;
    line-height: 1.7;
    color: var(--color-text-muted);
    margin-bottom: 0;
}

/* MARK: Disclaimer Box */

.sandbox-disclaimer-box {
    margin-top: 32px;
    padding: 24px 28px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: var(--radius-panel);
    text-align: left;
    max-width: 540px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.sandbox-disclaimer-box p {
    font-size: 13px;
    line-height: 1.7;
    color: var(--color-text-inverse-muted);
    margin: 0 0 10px;
}

.sandbox-disclaimer-box p:last-of-type {
    margin-bottom: 16px;
}

.sandbox-disclaimer-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--color-accent-deep);
    margin-bottom: 8px;
}

.sandbox-agree-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-accent-deep);
    line-height: 1.4;
    padding-top: 16px;
    border-top: 1px solid rgba(15, 23, 42, 0.1);
}

.sandbox-agree-checkbox {
    width: 18px;
    height: 18px;
    margin-top: 1px;
    flex-shrink: 0;
    accent-color: var(--color-accent-deep);
    cursor: pointer;
}

/* MARK: Post-Agree Section */

.sandbox-post-agree {
    margin-top: 24px;
}

.sandbox-try-label {
    font-size: 13px;
    color: var(--color-text-subtle);
    margin-bottom: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* MARK: Suggestion Buttons */

.sandbox-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.sandbox-suggestion {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 113, 173, 0.45);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-accent-deep);
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    max-width: 300px;
    text-align: left;
    line-height: 1.4;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.sandbox-suggestion:hover {
    background: #fff;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
}

/* MARK: - Chat Bubble Rows */

.sandbox-bubble-row {
    margin-bottom: 20px;
    max-width: 75%;
}

.sandbox-row-user {
    margin-left: auto;
    text-align: right;
}

.sandbox-row-ai {
    margin-right: auto;
    text-align: left;
}

.sandbox-row-error {
    margin: 0 auto;
    text-align: center;
    max-width: 90%;
}

/* MARK: - Chat Labels */

.sandbox-chat-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    color: rgba(255, 255, 255, 0.55);
}

.sandbox-row-user .sandbox-chat-label {
    color: rgba(255, 255, 255, 0.7);
}

.sandbox-row-ai .sandbox-chat-label {
    color: #93c5fd;
}

/* MARK: - Chat Bubbles */

.sandbox-bubble {
    padding: 16px 20px;
    border-radius: 12px;
    line-height: 1.7;
    font-size: 15px;
    text-align: left;
    display: inline-block;
    max-width: 100%;
    word-wrap: break-word;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
}

.sandbox-bubble-user {
    background: #003A70;
    color: #fff;
    border-bottom-left-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.sandbox-bubble-ai {
    background: #F8FAFC;
    color: #1e293b;
    border-top-right-radius: 2px;
    border: 1px solid rgba(15, 23, 42, 0.12);
}

.sandbox-bubble-error {
    background: #FFF9E6;
    color: #8B6914;
    border: 1px solid #D4A017;
    font-size: 14px;
}

/* MARK: - Actions Row */

.sandbox-actions-row {
    margin: 8px 0 24px;
    text-align: center;
}

.sandbox-evaluate-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #003A70;
    border: none;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    padding: 14px 32px;
    border-radius: 8px;
    transition: background 0.2s ease;
    letter-spacing: 0.2px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.sandbox-evaluate-btn:hover:not(:disabled) {
    background: #004A8A;
}

.sandbox-evaluate-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* MARK: - Evaluation Bubble */

.sandbox-bubble-eval {
    background: #F0F7FF;
    color: #1e293b;
    border: 1px solid #007CBA;
    border-left: 4px solid #007CBA;
    border-radius: 4px;
}

.sandbox-bubble-eval p {
    margin: 0 0 10px;
}

.sandbox-bubble-eval p:last-child {
    margin-bottom: 0;
}

.sandbox-bubble-eval .sandbox-md-list {
    color: #333;
}

.sandbox-bubble-eval .sandbox-md-list li strong {
    color: #003A70;
}

.sandbox-bubble-eval code {
    background: rgba(0, 122, 186, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
    color: #003A70;
}

.sandbox-eval-label {
    color: #93c5fd;
    font-weight: 700;
}

/* MARK: - Typing Indicator */

.sandbox-typing {
    padding: 16px 24px;
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #93c5fd;
    border-radius: 50%;
    opacity: 0.7;
    animation: typingPulse 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingPulse {
    0%, 80%, 100% { opacity: 0.4; transform: scale(1); }
    40% { opacity: 1; transform: scale(1.2); }
}

/* MARK: - Input Area */

.sandbox-input-area {
    padding: 16px var(--section-padding-x) 20px;
    background: rgba(255, 255, 255, 0.08);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

@supports (backdrop-filter: blur(12px)) {
    .sandbox-input-area {
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }
}

.sandbox-input-form {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 12px;
    padding: 12px 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sandbox-input-form:focus-within {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px rgba(0, 113, 173, 0.2);
}

.sandbox-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    outline: none;
    color: #1e293b;
    max-height: 120px;
}

.sandbox-input::placeholder {
    color: #94a3b8;
}

.sandbox-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #003A70;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease, opacity 0.2s ease;
}

.sandbox-send-btn:hover:not(:disabled) {
    background: #004A8A;
}

.sandbox-send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.sandbox-disclaimer {
    font-size: 12px;
    color: var(--color-text-subtle);
    text-align: center;
    margin: 10px 0 0;
    line-height: 1.4;
}

/* MARK: - Footer Override */

.sandbox-footer {
    padding: 12px var(--section-padding-x);
}

/* MARK: - Markdown Rendered Content */

.sandbox-md-heading {
    color: #003A70;
    font-weight: 700;
    margin: 16px 0 8px;
}

.sandbox-md-heading:first-child {
    margin-top: 0;
}

h3.sandbox-md-heading { font-size: 1.1em; }
h4.sandbox-md-heading { font-size: 1em; }
h5.sandbox-md-heading { font-size: 0.95em; }

.sandbox-md-list {
    margin: 8px 0 12px 20px;
    line-height: 1.7;
    color: #333;
}

.sandbox-md-list li {
    margin-bottom: 6px;
}

.sandbox-md-list li strong {
    color: #003A70;
}

.sandbox-bubble-ai p {
    margin: 0 0 10px;
}

.sandbox-bubble-ai p:last-child {
    margin-bottom: 0;
}

.sandbox-bubble-ai code {
    background: rgba(0, 122, 186, 0.12);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
    color: #003A70;
}

/* MARK: - Responsive Overrides */

@media (max-width: 1024px) {
    .sandbox-messages {
        padding: 24px var(--section-padding-x);
    }

    .sandbox-input-area {
        padding: 16px var(--section-padding-x) 20px;
    }
}

@media (max-width: 868px) {
    .sandbox-messages {
        padding: 16px var(--section-padding-x);
    }

    .sandbox-input-area {
        padding: 12px var(--section-padding-x) 16px;
    }

    .sandbox-chat-wrapper {
        height: calc(100vh - 160px);
        min-height: 400px;
        margin: 0 0 16px;
    }

    .sandbox-bubble-row {
        max-width: 90%;
    }

    .sandbox-welcome {
        padding: 40px var(--section-padding-x) 24px;
    }

    .sandbox-welcome h2 {
        font-size: 1.4em;
    }

    .sandbox-suggestions {
        flex-direction: column;
        align-items: center;
    }

    .sandbox-suggestion {
        max-width: 100%;
        text-align: center;
    }
}
