/* GPT-OSS Chat Styles */

:root {
    --gpt-primary: #1e3a5f;
    --gpt-primary-dark: #152a44;
    --gpt-bg: #f7f7f8;
    --gpt-sidebar-bg: #ffffff;
    --gpt-message-user-bg: #1e3a5f;
    --gpt-message-assistant-bg: #ffffff;
    --gpt-border: #e5e5e5;
    --gpt-text: #2d3748;
    --gpt-text-light: #6b7280;
}

.chat-interface {
    display: flex;
    gap: 20px;
    height: calc(100vh - 140px);
    min-height: calc(100vh - 140px);
    margin-top: 24px;
}

.chat-interface-wrapper {
    margin-top: 24px;
    min-height: calc(100vh - 120px);
}

.chat-interface-wrapper .side-tabs__panel {
    padding: 0;
    background: transparent;
}

.chat-interface-wrapper #gptChatMain.chat-interface {
    margin-top: 0;
}

.chat-interface-wrapper.api-docs-active .chat-interface {
    height: auto;
    min-height: 0;
}

.chat-interface-wrapper.api-docs-active {
    min-height: auto;
}

/* Sidebar */
.chat-sidebar {
    width: 300px;
    background: var(--gpt-sidebar-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
}

.model-selector label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--gpt-text);
}

.model-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gpt-border);
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.model-select:hover {
    border-color: var(--gpt-primary);
}

.model-select:focus {
    outline: none;
    border-color: var(--gpt-primary);
    box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.parameters-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--gpt-text);
}

.parameter-group {
    margin-bottom: 20px;
}

.parameter-group label {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--gpt-text);
}

.parameter-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e5e5e5;
    outline: none;
    -webkit-appearance: none;
}

.parameter-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gpt-primary);
    cursor: pointer;
    transition: transform 0.2s;
}

.parameter-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.parameter-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gpt-primary);
    cursor: pointer;
    border: none;
}

.parameter-group small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--gpt-text-light);
}

.actions-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-button {
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
}

.action-button.primary {
    background: var(--gpt-primary);
    color: white;
}

.action-button.primary:hover {
    background: var(--gpt-primary-dark);
}

.action-button.secondary {
    background: white;
    color: var(--gpt-text);
    border: 1px solid var(--gpt-border);
}

.action-button.secondary:hover {
    background: var(--gpt-bg);
}

.cost-info {
    padding: 16px;
    background: #e3f2fd;
    border-radius: 8px;
    border: 1px solid #90caf9;
}

.cost-info h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--gpt-text);
}

.cost-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--gpt-text);
}

.cost-item .separator {
    opacity: 0.6;
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    background: var(--gpt-sidebar-bg);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--gpt-text-light);
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.welcome-message h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--gpt-text);
    margin-bottom: 8px;
}

.welcome-message p {
    font-size: 16px;
    margin-bottom: 24px;
}

.quick-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-width: 600px;
}

.quick-prompt-btn {
    padding: 10px 16px;
    background: white;
    border: 1px solid var(--gpt-border);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-prompt-btn:hover {
    background: var(--gpt-bg);
    border-color: var(--gpt-primary);
}

/* Messages */
.message {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s ease;
}

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

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

.message-user .message-avatar {
    background: var(--gpt-message-user-bg);
}

.message-assistant .message-avatar {
    background: var(--gpt-bg);
}

.message-error .message-avatar {
    background: #fee2e2;
}

.message-content {
    flex: 1;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
    color: var(--gpt-text);
}

.message-user .message-content {
    background: var(--gpt-message-user-bg);
    color: white;
}

.message-assistant .message-content {
    background: var(--gpt-bg);
}

.message-error .message-content {
    background: #fee2e2;
    color: #991b1b;
}

.message-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
}

.message-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
}

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

.message-content p {
    margin: 0 0 0.75rem;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul,
.message-content ol {
    margin: 0 0 0.75rem 1.25rem;
    padding-left: 1.2rem;
    list-style-position: outside;
}

.message-usage {
    display: block;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--gpt-border);
    font-size: 0.85rem;
    color: var(--gpt-text-light);
}

.reasoning-details {
    margin: 0 0 12px;
    border: 1px solid var(--gpt-border);
    border-radius: 8px;
    background: #f9fafb;
    padding: 8px 12px;
}

.reasoning-details summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--gpt-primary);
    outline: none;
}

.reasoning-details[open] summary {
    margin-bottom: 8px;
}

.reasoning-content {
    background: #0f172a;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    white-space: pre-wrap;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
}

.api-note {
    margin-top: 12px;
    font-size: 0.9rem;
    color: var(--gpt-text-light);
}

.thinking-indicator {
    display: flex;
    gap: 6px;
    padding: 8px 0;
}

.thinking-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--gpt-text-light);
}

.thinking-label {
    font-size: 0.95rem;
    letter-spacing: 0.02em;
}

.thinking-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gpt-primary);
    animation: thinking 1.4s infinite;
}

.thinking-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes thinking {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Chat Input */
.chat-input-container {
    border-top: 1px solid var(--gpt-border);
    padding: 16px 24px;
    background: white;
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--gpt-bg);
    border-radius: 12px;
    padding: 8px 12px;
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 15px;
    line-height: 1.6;
    color: var(--gpt-text);
    max-height: 150px;
    min-height: 24px;
    font-family: inherit;
}

.chat-input:focus {
    outline: none;
}

.chat-input::placeholder {
    color: var(--gpt-text-light);
}

.send-button {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: var(--gpt-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    background: var(--gpt-primary-dark);
    transform: scale(1.05);
}

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

.input-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--gpt-text-light);
}

.separator {
    color: var(--gpt-border);
}

.credit-cost {
    color: var(--gpt-primary);
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .chat-interface {
        flex-direction: column;
        height: auto;
        min-height: 600px;
    }

    .chat-sidebar {
        width: 100%;
        max-height: none;
    }

    .chat-main {
        height: 500px;
        min-height: 500px;
    }
}

@media (max-width: 768px) {
    .chat-interface {
        gap: 16px;
        min-height: 500px;
    }

    .chat-sidebar {
        padding: 18px;
        gap: 18px;
    }

    .parameters-section h3 {
        font-size: 15px;
    }

    .parameter-group label {
        font-size: 13px;
    }

    .parameter-group small {
        font-size: 11px;
    }

    .actions-section {
        flex-direction: column;
        gap: 10px;
    }

    .action-button {
        width: 100%;
        justify-content: center;
    }

    .chat-main {
        height: 450px;
        min-height: 450px;
    }

    .chat-messages {
        padding: 12px;
    }

    .message-bubble {
        max-width: 90%;
        padding: 12px 14px;
    }

    .message-content {
        font-size: 14px;
    }

    .message-timestamp {
        font-size: 11px;
    }

    .quick-prompts {
        flex-direction: column;
        gap: 8px;
    }

    .quick-prompt {
        width: 100%;
        text-align: left;
    }

    .chat-input-container {
        padding: 12px;
        gap: 8px;
    }

    .chat-input {
        font-size: 14px;
        min-height: 44px;
    }

    .send-button {
        min-width: 44px;
        height: 44px;
        padding: 0;
    }

    .model-select {
        font-size: 13px;
        padding: 9px 11px;
    }

    /* History panel improvements for mobile */
    .history-panel-content {
        width: 95%;
        max-height: 85vh;
    }

    .history-header {
        padding: 18px 20px;
    }

    .history-header h3 {
        font-size: 18px;
    }

    .history-list {
        padding: 12px;
    }

    .history-item {
        padding: 12px;
    }

    .history-title {
        font-size: 14px;
    }

    .history-meta {
        font-size: 12px;
    }
}

/* Chat History Panel */
.history-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.history-panel-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease-out;
}

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

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 28px;
    border-bottom: 1px solid var(--gpt-border);
}

.history-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--gpt-text);
}

.history-close-btn {
    background: none;
    border: none;
    font-size: 32px;
    color: var(--gpt-text-light);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.history-close-btn:hover {
    background: #f3f4f6;
    color: var(--gpt-text);
}

.history-list {
    overflow-y: auto;
    padding: 16px;
    flex: 1;
}

.no-history {
    text-align: center;
    padding: 60px 20px;
    color: var(--gpt-text-light);
    font-size: 15px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    margin-bottom: 8px;
}

.history-item:hover {
    background: #f9fafb;
    border-color: var(--gpt-border);
}

.history-item-content {
    flex: 1;
    min-width: 0;
}

.history-title {
    font-weight: 500;
    font-size: 15px;
    color: var(--gpt-text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta {
    font-size: 13px;
    color: var(--gpt-text-light);
}

.history-delete-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    opacity: 0;
    transition: all 0.2s;
    margin-left: 8px;
}

.history-item:hover .history-delete-btn {
    opacity: 1;
}

.history-delete-btn:hover {
    background: #fee2e2;
}
