/* Reset básico */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

/* Header */
header {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    color: #667eea;
}

header p {
    color: #666;
    margin-bottom: 20px;
}

nav {
    display: flex;
    gap: 10px;
    justify-content: center;
}

nav a {
    padding: 10px 20px;
    background: #f0f0f0;
    border-radius: 6px;
    text-decoration: none;
    color: #333;
    transition: all 0.3s;
}

nav a:hover {
    background: #667eea;
    color: white;
}

nav a.active {
    background: #667eea;
    color: white;
}

/* Sections */
section {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

section h2 {
    margin-bottom: 15px;
    color: #667eea;
}

section p {
    color: #666;
    margin-bottom: 20px;
}

/* Upload Section */
.upload-form {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

#fileInput {
    flex: 1;
    padding: 10px;
    border: 2px dashed #667eea;
    border-radius: 6px;
    cursor: pointer;
}

button {
    padding: 12px 24px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s;
}

button:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.status {
    padding: 12px;
    border-radius: 6px;
    margin-top: 10px;
    display: none;
}

.status.success {
    background: #d4edda;
    color: #155724;
    display: block;
}

.status.error {
    background: #f8d7da;
    color: #721c24;
    display: block;
}

.status.info {
    background: #d1ecf1;
    color: #0c5460;
    display: block;
}

/* Chat Section */
.rag-toggle {
    margin-bottom: 20px;
}

.rag-toggle label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 500;
}

.rag-toggle input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.chat-messages {
    height: 400px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    background: #f9f9f9;
}

.message {
    padding: 12px 16px;
    margin-bottom: 12px;
    border-radius: 8px;
    max-width: 80%;
}

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

.message.assistant {
    background: white;
    border: 1px solid #e0e0e0;
}

.message.system {
    background: #f0f0f0;
    color: #666;
    font-style: italic;
    text-align: center;
    max-width: 100%;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
}

.chat-input-container {
    display: flex;
    gap: 10px;
}

#chatInput {
    flex: 1;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 1em;
    resize: vertical;
}

#chatInput:focus {
    outline: none;
    border-color: #667eea;
}

/* QR Section */
.qr-section {
    text-align: center;
}

.qr-display {
    min-height: 350px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
}

.qr-display img {
    max-width: 350px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Instructions */
.instructions {
    background: #f9f9f9;
}

.instructions h3 {
    margin-bottom: 15px;
    color: #667eea;
}

.instructions ol {
    margin-left: 20px;
    color: #666;
    line-height: 1.8;
}

.instructions li {
    margin-bottom: 8px;
}

/* Loading spinner */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

/* OAuth Section */
.oauth-login-section {
    margin-bottom: 30px;
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
}

.oauth-step {
    margin: 20px 0;
    padding: 20px;
    background: white;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.oauth-step h4 {
    margin-top: 0;
    color: #667eea;
    font-size: 1.1em;
}

.oauth-instructions {
    margin: 15px 0;
}

.oauth-instructions p {
    margin: 10px 0;
    line-height: 1.6;
}

.oauth-url-box {
    background: #e8f4f8;
    padding: 15px;
    border-radius: 6px;
    margin: 10px 0;
}

.oauth-link {
    color: #667eea;
    font-weight: 600;
    font-size: 1.1em;
    text-decoration: none;
}

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

#callbackURL {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.9em;
    margin-bottom: 15px;
}

.oauth-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 15px;
}

.oauth-btn {
    flex: 1;
    min-width: 200px;
    padding: 15px 25px;
    font-size: 1.1em;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.oauth-btn span {
    font-size: 1.3em;
}

.openai-btn {
    background: linear-gradient(135deg, #10a37f 0%, #0d8a6a 100%);
    color: white;
}

.openai-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #0d8a6a 0%, #0a7157 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 163, 127, 0.3);
}

.claude-btn {
    background: linear-gradient(135deg, #cc785c 0%, #b8674d 100%);
    color: white;
}

.claude-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #b8674d 0%, #a4583e 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(204, 120, 92, 0.3);
}

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

.divider {
    text-align: center;
    margin: 30px 0;
    position: relative;
}

.divider::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: #ddd;
}

.divider span {
    background: white;
    padding: 0 15px;
    position: relative;
    color: #999;
    font-weight: 600;
}

.manual-token-section {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
}

.provider-selection {
    margin: 15px 0;
}

.provider-selection label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.provider-selection select {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 1em;
}

.instructions-box {
    background: #e8f4f8;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    border-left: 4px solid #667eea;
}

.instructions-box h3 {
    margin-top: 0;
    color: #667eea;
}

.instructions-box ol {
    margin-left: 20px;
    line-height: 1.8;
}

.instructions-box code {
    background: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
    color: #667eea;
}

.instructions-box a {
    color: #667eea;
    font-weight: 600;
}

.token-input-container {
    margin: 20px 0;
}

.token-input-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.token-input-container textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.9em;
    resize: vertical;
}

.current-status {
    background: #f0f0f0;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
}

.notes-section {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 20px;
}

.notes-section ul {
    margin-left: 20px;
    line-height: 1.8;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }

    .upload-form {
        flex-direction: column;
    }

    .chat-input-container {
        flex-direction: column;
    }

    .message {
        max-width: 90%;
    }

    .oauth-buttons {
        flex-direction: column;
    }

    .oauth-btn {
        min-width: 100%;
    }
}
