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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    margin: 0;
    padding: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    display: grid;
    grid-template-columns: 1fr; /* Single column layout for mobile */
    grid-template-areas:
        "header"
        "input-wrapper"
        "chat-container"
        "api-preview";
}

.mobile-only {
    display: block;
}

.header {
    grid-area: header;
    text-align: center;
    color: white;
    margin-bottom: 20px;
}

.header h1 {
    margin: 0 0 10px 0;
    font-size: 2.5rem;
    font-weight: 700;
}

.header p {
    margin: 0;
    font-size: 1.1rem;
    opacity: 0.9;
}

.beta-badge {
    font-size: 0.8rem;
    background: #ff6b35;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    margin-left: 10px;
    vertical-align: middle;
    animation: pulse 2s infinite;
}

.beta-notice {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
    font-size: 0.9rem;
    text-align: left;
    backdrop-filter: blur(10px);
}

.beta-notice strong {
    display: block;
    margin-bottom: 8px;
    font-size: 1rem;
}

.beta-notice ul {
    margin: 0;
    padding-left: 20px;
    list-style: none;
}

.beta-notice li {
    margin: 5px 0;
    padding-left: 5px;
}

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

.chat-container {
    grid-area: chat-container;
    background: white;
    border-radius: 0;
    overflow-y: auto;
}

.container:not(.has-review) .chat-container {
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.api-preview {
    grid-area: api-preview;
    background: white;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    display: none;
    flex-direction: column;
}

.api-preview h3 {
    margin: 0;
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    font-size: 18px;
    color: #495057;
}

.chat-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.chat-history-header h3 {
    margin: 0;
    font-size: 18px;
    color: #495057;
}

.toggle-button {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #6c757d;
    transition: transform 0.2s ease;
    padding: 4px;
    border-radius: 4px;
}

.toggle-button:hover {
    background: #e9ecef;
}

.toggle-button.collapsed {
    transform: rotate(-90deg);
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: white;
    transition: max-height 0.3s ease;
}

.messages.collapsed {
    max-height: 0;
    padding: 0 20px;
    overflow: hidden;
}

.message {
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-in;
}

.message-content {
    max-width: 80%;
    padding: 15px 20px;
    border-radius: 18px;
    line-height: 1.5;
}

.bot-message .message-content {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    margin-right: auto;
}

.user-message .message-content {
    background: #667eea;
    color: white;
    margin-left: auto;
}

.message-content ul {
    margin: 10px 0;
    padding-left: 20px;
}

.message-content li {
    margin: 5px 0;
    color: #666;
}

.user-message .message-content li {
    color: rgba(255, 255, 255, 0.9);
}

.input-wrapper {
    grid-area: input-wrapper;
    background: white;
    padding: 20px;
    border-radius: 12px 12px 0 0;
    border-bottom: 1px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    gap: 10px;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.input-wrapper #chatInput {
    flex-grow: 1;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.input-wrapper #chatInput:focus {
    border-color: #667eea;
}

.input-wrapper #sendButton {
    padding: 12px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 70px;
}

.input-wrapper #sendButton:hover:not(:disabled) {
    background: #5a6fd8;
}

.input-wrapper #sendButton:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.preview-content {
    flex: 1;
    white-space: pre-wrap;
    background: white;
    padding: 20px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    overflow-y: auto;
    margin: 0;
}

.preview-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin: 30px 20px;
    padding: 25px 20px;
    border-top: 1px solid #dee2e6;
    flex-wrap: wrap;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
}

.primary-button {
    background: #007bff;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.primary-button:hover {
    background: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.secondary-button {
    background: #6c757d;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.secondary-button:hover {
    background: #545b62;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

@media (min-width: 768px) {
    .container:not(.has-review) {
        max-width: 960px;
        margin: 0 auto;
        grid-template-columns: 1fr; /* one-column layout for desktop */
        grid-template-areas:
            "header"
            "input-wrapper"
            "chat-container";
    }

    .container.has-review {
        max-width: 1420px;
        margin: 0 auto;
        grid-template-columns: 1fr 1fr; /* Two-column layout for desktop */
        grid-template-rows: auto minmax(auto, 100px) 1fr;
        grid-template-areas:
            "header header"
            "api-preview input-wrapper"
            "api-preview chat-container";
        column-gap: 20px;
    }

    .mobile-only {
        display: none;
    }

    .chat-container {
        border-radius: 0 0 12px 12px;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }

    .api-preview {
        border-radius: 12px;
    }
}   

/* API Preview Styles */
.entities-section, .endpoints-section {
    margin-bottom: 20px;
}

.entities-section h4, .endpoints-section h4 {
    color: #495057;
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
    padding-bottom: 5px;
}

.entity-block, .endpoint-block {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 12px;
    padding: 12px;
}

.entity-block h5, .endpoint-block h5 {
    margin: 0 0 8px 0;
    color: #007bff;
    font-size: 14px;
    font-weight: 600;
}

.property-list {
    margin: 0;
    padding-left: 16px;
    list-style: none;
}

.property-list li {
    margin-bottom: 4px;
    font-size: 13px;
}

.property-list code {
    background: #e9ecef;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 500;
}

.type-string { color: #28a745; font-weight: 500; }
.type-int { color: #007bff; font-weight: 500; }
.type-float { color: #17a2b8; font-weight: 500; }
.type-boolean { color: #ffc107; font-weight: 500; }
.type-datetime { color: #6f42c1; font-weight: 500; }
.type-foreign_key { color: #fd7e14; font-weight: 500; }
.type-uuid { color: #20c997; font-weight: 500; }
.type-decimal { color: #e83e8c; font-weight: 500; }

.method-block {
    margin-bottom: 12px;
    border-left: 3px solid #dee2e6;
    padding-left: 12px;
}

.method-header {
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 13px;
    margin-bottom: 8px;
    display: inline-block;
}

.method-get { background: #d4edda; color: #155724; }
.method-post { background: #d1ecf1; color: #0c5460; }
.method-put { background: #fff3cd; color: #856404; }
.method-delete { background: #f8d7da; color: #721c24; }

.method-detail {
    margin-bottom: 8px;
}

.method-detail strong {
    color: #495057;
    font-size: 12px;
}

.json-code {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 8px;
    font-size: 11px;
    font-family: 'Courier New', monospace;
    color: #495057;
    margin: 8px 0;
    overflow-x: auto;
    max-height: 120px;
    overflow-y: auto;
}

/* Field specification styling */
.field-specs {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 8px;
    margin: 4px 0;
}

.field-spec-item {
    margin: 0;
    padding: 1px 0;
    font-size: 11px;
    font-family: 'Courier New', monospace;
    display: block;
    margin-bottom: 2px;
}

.field-spec-item code {
    background: #e9ecef;
    padding: 1px 4px;
    border-radius: 2px;
    font-weight: 500;
    color: #495057;
    font-size: 10px;
    min-width: 60px;
}

.field-spec {
    font-family: 'Courier New', monospace;
    font-size: 10px;
}

.field-spec.entity-field {
    color: #0066cc;
    font-weight: 500;
    padding: 1px 3px;
    background: rgba(0, 102, 204, 0.1);
    border-radius: 2px;
    border: 1px solid rgba(0, 102, 204, 0.2);
}

.field-spec.entity-field .entity-name {
    color: #004d99;
    font-weight: 600;
}

.field-spec.entity-field .field-name {
    color: #0066cc;
}

.field-spec.basic-type {
    color: #6c757d;
    font-style: italic;
}

.field-spec.literal {
    color: #28a745;
}

.embedded-object {
    display: inline;
    padding: 1px 3px;
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 3px;
    font-size: 10px;
}

.embedded-array {
    display: inline;
    padding: 1px 3px;
    background: rgba(108, 117, 125, 0.1);
    border: 1px solid rgba(108, 117, 125, 0.3);
    border-radius: 3px;
    font-size: 10px;
}

.embedded-object-block {
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 3px;
    padding: 6px;
    margin: 4px 0;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    white-space: pre-line;
}

.embedded-array-block {
    background: rgba(108, 117, 125, 0.1);
    border: 1px solid rgba(108, 117, 125, 0.3);
    border-radius: 3px;
    padding: 6px;
    margin: 4px 0;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    white-space: pre-line;
}

.top-level-array-block {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 3px;
    padding: 6px;
    margin: 4px 0;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    white-space: pre-line;
}

.top-level-object-block {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 3px;
    padding: 6px;
    margin: 4px 0;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    white-space: pre-line;
}

.embedded-label {
    font-size: 10px;
    font-weight: 600;
    color: #495057;
}

.validation-errors {
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
    border-radius: 3px;
    padding: 6px;
    margin: 4px 0;
    font-size: 10px;
}

.error-icon {
    margin-right: 4px;
}

.error-text {
    font-weight: 600;
    color: #dc3545;
    margin-right: 4px;
}

.validation-error {
    color: #dc3545;
    margin: 2px 0 2px 16px;
    font-size: 9px;
}
