/* K250 Tech Support - Clean Minimal Theme */

:root {
    --color-bg: #1a1a1a;
    --color-surface: #242424;
    --color-surface-hover: #2e2e2e;
    --color-border: #333333;
    --color-text: #e8e8e8;
    --color-text-muted: #888888;
    --color-accent: #d4a574;
    --color-accent-hover: #e8b989;
    --color-success: #4ade80;
    --color-error: #f87171;
    --radius: 12px;
    --radius-sm: 8px;
    --max-width: 100%;
    --artifact-width: 50%;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

.hidden {
    display: none !important;
}

/* App Layout */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    transition: width 0.3s ease;
}

/* When artifact is open, shrink main content and align left */
body.artifact-open .app {
    width: 50%;
    max-width: 50%;
    margin: 0;
    padding-left: 20px;
    padding-right: 20px;
}

/* Welcome Screen */
.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-content {
    text-align: center;
    padding: 40px 20px;
}

.welcome-title {
    font-size: 2.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 12px;
}

.welcome-subtitle {
    font-size: 1.1rem;
    color: var(--color-text-muted);
    margin-bottom: 48px;
}

/* Suggestion Pills */
.suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.suggestion-pill {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    padding: 10px 18px;
    color: var(--color-text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggestion-pill:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-accent);
}

/* Chat Interface */
.chat-interface {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding-top: 20px;
    position: relative;
}

/* Messages Container */
.messages {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}

/* Individual Message */
.message {
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-user {
    padding: 16px 0;
}

.message-user .message-content {
    color: var(--color-text);
}

.message-assistant {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 20px;
}

.message-content {
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Markdown Styling */
.message-content h1, .message-content h2, .message-content h3 {
    margin-top: 1em;
    margin-bottom: 0.5em;
}

.message-content p {
    margin-bottom: 1em;
}

.message-content ul, .message-content ol {
    margin-left: 1.5em;
    margin-bottom: 1em;
}

.message-content li {
    margin-bottom: 0.5em;
}

.message-content code {
    background: var(--color-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "SF Mono", Monaco, Consolas, monospace;
    font-size: 0.9em;
}

.message-content pre {
    background: var(--color-bg);
    padding: 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin-bottom: 1em;
}

.message-content pre code {
    background: none;
    padding: 0;
}

.message-content a {
    color: var(--color-accent);
    text-decoration: none;
}

.message-content a:hover {
    text-decoration: underline;
}

.message-content strong {
    font-weight: 600;
}

/* Chat Option Buttons */
.chat-option {
    display: block;
    width: 100%;
    text-align: left;
    background: var(--color-bg);
    border: 2px solid var(--color-accent);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin: 8px 0;
    color: var(--color-text);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-option:hover {
    background: var(--color-accent);
    color: var(--color-bg);
}

/* Streaming Indicator */
.streaming-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--color-accent);
    border-radius: 50%;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Search Status */
.search-status {
    color: var(--color-text-muted);
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-status::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--color-accent);
    border-radius: 50%;
    animation: pulse 1s infinite;
}

/* Input Area */
.input-area {
    padding: 16px 0;
    border-top: 1px solid var(--color-border);
    margin-top: auto;
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 8px 8px 8px 16px;
    transition: border-color 0.2s ease;
}

.input-container:focus-within {
    border-color: var(--color-accent);
}

#message-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--color-text);
    font-size: 1rem;
    line-height: 1.5;
    padding: 8px 0;
    resize: none;
    max-height: 150px;
    outline: none;
    font-family: inherit;
}

#message-input::placeholder {
    color: var(--color-text-muted);
}

.send-btn {
    background: var(--color-accent);
    border: none;
    border-radius: var(--radius-sm);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--color-bg);
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background: var(--color-accent-hover);
}

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

/* Feedback Row */
.feedback-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding-left: 4px;
}

.feedback-btn {
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 6px 10px;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.feedback-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-text);
}

.feedback-btn.active {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.sources-btn {
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 6px 12px;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}

.sources-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-text);
}

.feedback-status {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-left: 8px;
}

.feedback-status.success {
    color: var(--color-success);
}

/* Artifact Panel (Sources Sidebar) - 50/50 split */
.artifact-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 50%;
    height: 100vh;
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.artifact-panel.visible {
    transform: translateX(0);
}

.artifact-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}

.artifact-title {
    font-weight: 600;
    font-size: 1rem;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

.close-btn:hover {
    color: var(--color-text);
}

.artifact-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Artifact iframe for documents */
.artifact-doc {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.artifact-doc-title {
    font-weight: 500;
    margin-bottom: 12px;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.artifact-iframe {
    flex: 1;
    width: 100%;
    min-height: 500px;
    border: none;
    border-radius: var(--radius-sm);
    background: white;
}

/* Artifact links in chat */
.artifact-link {
    color: var(--color-accent) !important;
    text-decoration: none !important;
    border-bottom: 1px dashed var(--color-accent);
    cursor: pointer;
}

.artifact-link:hover {
    border-bottom-style: solid;
}

.artifact-link::after {
    content: " \2197";
    font-size: 0.8em;
    opacity: 0.7;
}

.sources-link {
    color: var(--color-text-muted) !important;
    text-decoration: none !important;
    border-bottom: 1px dashed var(--color-text-muted);
    cursor: pointer;
    font-size: 0.9em;
}

.sources-link:hover {
    color: var(--color-accent) !important;
    border-bottom-color: var(--color-accent);
}

.sources-link::before {
    content: "\1F4C4 ";
}

/* Source Items */
.source-item {
    padding: 12px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.source-type {
    display: inline-block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-accent);
    margin-bottom: 6px;
}

.source-title {
    font-weight: 500;
    margin-bottom: 4px;
}

.source-title a {
    color: var(--color-text);
    text-decoration: none;
}

.source-title a:hover {
    color: var(--color-accent);
}

.source-citation {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.source-expand {
    color: var(--color-accent) !important;
    cursor: pointer;
}

.source-expand:hover {
    text-decoration: underline !important;
}

.source-content {
    margin-top: 10px;
    padding: 12px;
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-accent);
    max-height: 300px;
    overflow-y: auto;
}

.source-content pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--color-text);
    margin: 0;
}

/* Sources Sections */
.sources-section {
    margin-bottom: 24px;
}

.sources-section-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-accent);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
}

/* Image Thumbnail Grid */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.image-thumb {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s, transform 0.2s;
    background: var(--color-surface);
}

.image-thumb:hover {
    border-color: var(--color-accent);
    transform: scale(1.02);
}

.image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-thumb-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 4px 6px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-size: 0.7rem;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

/* Image Detail Panel */
.image-detail-panel {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 12px;
    border: 1px solid var(--color-border);
    position: relative;
}

.image-detail-close {
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-muted);
    line-height: 1;
}

.image-detail-close:hover {
    color: var(--color-text);
}

.image-detail-img {
    text-align: center;
    margin-bottom: 12px;
}

.image-detail-img img {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}

.image-detail-info {
    font-size: 0.9rem;
}

.image-detail-info strong {
    display: block;
    margin-bottom: 8px;
    color: var(--color-text);
}

.image-detail-system,
.image-detail-board {
    display: inline-block;
    background: var(--color-accent);
    color: var(--color-bg);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-right: 6px;
    margin-bottom: 8px;
}

.image-detail-board {
    background: var(--color-border);
    color: var(--color-text);
}

.image-detail-essay {
    margin-top: 12px;
    padding: 12px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--color-text-muted);
    max-height: 200px;
    overflow-y: auto;
}

/* Larger image grid for Images-only view */
.image-grid-large {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.image-grid-large .image-thumb {
    aspect-ratio: 4/3;
}

.image-grid-large .image-thumb-label {
    font-size: 0.75rem;
    padding: 6px 8px;
}

/* Images link styling */
.images-link {
    color: var(--color-accent) !important;
    text-decoration: none;
    cursor: pointer;
}

.images-link:hover {
    text-decoration: underline;
}

.images-link::before {
    content: "\1F4F7 ";
}

/* Footer */
.footer {
    text-align: center;
    padding: 16px 20px;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.footer-credits {
    margin-top: 10px;
}

.footer a {
    color: var(--color-text-muted);
    text-decoration: none;
}

.footer a:hover {
    color: var(--color-accent);
}

/* Mode Selector */
.mode-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mode-label {
    color: var(--color-text-muted);
    margin-right: 4px;
}

.mode-btn {
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 4px 12px;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-text);
}

.mode-btn.active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-bg);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-content {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 24px;
    width: 90%;
    max-width: 400px;
}

.modal-content h3 {
    margin-bottom: 16px;
}

.modal-content textarea {
    width: 100%;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 12px;
    color: var(--color-text);
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    min-height: 100px;
    margin-bottom: 16px;
}

.modal-content textarea:focus {
    outline: none;
    border-color: var(--color-accent);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-primary, .btn-secondary {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--color-accent);
    color: var(--color-bg);
    border: none;
}

.btn-primary:hover {
    background: var(--color-accent-hover);
}

.btn-secondary {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    border-color: var(--color-text-muted);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .welcome-title {
        font-size: 1.8rem;
    }

    .welcome-subtitle {
        font-size: 1rem;
    }

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

    .suggestion-pill {
        text-align: center;
    }

    /* Artifact panel slides from bottom on mobile - 50% height */
    .artifact-panel {
        top: auto;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 50vh;
        max-height: 50vh;
        border-left: none;
        border-top: 1px solid var(--color-border);
        border-radius: var(--radius) var(--radius) 0 0;
        transform: translateY(100%);
    }

    .artifact-panel.visible {
        transform: translateY(0);
    }

    /* On mobile, shrink chat to top 50% when artifact is open */
    body.artifact-open .app {
        width: 100%;
        max-width: 100%;
        height: 50vh;
        max-height: 50vh;
        overflow: hidden;
        padding-right: 16px;
    }

    body.artifact-open .chat-interface {
        height: calc(50vh - 20px);
        max-height: calc(50vh - 20px);
        overflow: hidden;
    }

    body.artifact-open .messages {
        max-height: calc(50vh - 100px);
        overflow-y: auto;
    }

    .app {
        padding: 0 16px;
    }

    .message-assistant {
        padding: 16px;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* Overlay when artifact panel is open on mobile */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

/* ===== Signup Gate Overlay ===== */
.gate-overlay{position:fixed;inset:0;background:rgba(20,20,22,.92);display:flex;
  align-items:center;justify-content:center;z-index:1000;}
.gate-card{background:var(--color-bg, #1e1e22);border:1px solid rgba(255,255,255,.1);
  border-radius:12px;padding:32px;max-width:380px;width:90%;text-align:center;
  box-shadow:0 10px 40px rgba(0,0,0,.5);}
.gate-card h2{margin:0 0 8px;font-size:1.3em;}
.gate-sub{color:#aaa;font-size:.9em;margin:0 0 18px;}
.gate-card input[type=email],.gate-card input[type=text]{width:100%;padding:12px;
  border-radius:8px;border:1px solid rgba(255,255,255,.15);background:#111;color:#fff;
  font-size:1em;margin-bottom:12px;box-sizing:border-box;}
.gate-consent{display:flex;gap:8px;align-items:center;font-size:.85em;color:#bbb;
  text-align:left;margin-bottom:16px;}
.gate-btn{width:100%;padding:12px;border:none;border-radius:8px;cursor:pointer;
  font-size:1em;font-weight:600;background:linear-gradient(135deg,#d4a574,#e8c49a);color:#000;}
.gate-link{background:none;border:none;color:#9ab;cursor:pointer;margin-top:10px;font-size:.85em;}
.gate-error{color:#ff8080;font-size:.85em;min-height:1em;margin-top:10px;}
