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

:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338CA;
    --secondary-color: #6B7280;
    --success-color: #10B981;
    --error-color: #EF4444;
    --background: #F9FAFB;
    --surface: #FFFFFF;
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --border-color: #E5E7EB;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    padding: 20px;
}

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

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

header h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Question Section */
.question-section {
    background: var(--surface);
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.input-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-size: 1.1rem;
}

textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.input-footer {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.name-input {
    flex: 1;
    min-width: 200px;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.name-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Buttons */
.primary-btn, .secondary-btn, .icon-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    min-width: 200px;
}

.primary-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.primary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.secondary-btn {
    background: var(--surface);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

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

.icon-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    padding: 8px;
    cursor: pointer;
    transition: transform 0.3s;
}

.icon-btn:hover {
    transform: rotate(180deg);
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Answer Section */
.answer-section {
    background: var(--surface);
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    border-left: 4px solid var(--success-color);
}

.answer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.answer-header h2 {
    color: var(--success-color);
}

.answer-meta {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.answer-content {
    background: var(--background);
    padding: 20px;
    border-radius: 8px;
    line-height: 1.6;
    margin-bottom: 20px;
    word-wrap: break-word;
}

/* Styling for HTML content inside answer */
.answer-content h1,
.answer-content h2,
.answer-content h3,
.answer-content h4 {
    color: var(--text-primary);
    margin-top: 1.5em;
    margin-bottom: 0.75em;
    font-weight: 600;
    line-height: 1.3;
}

.answer-content h1 {
    font-size: 1.8em;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.3em;
}

.answer-content h2 {
    font-size: 1.5em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.25em;
}

.answer-content h3 {
    font-size: 1.3em;
}

.answer-content h4 {
    font-size: 1.1em;
}

.answer-content p {
    margin: 0.75em 0;
    line-height: 1.6;
}

.answer-content strong {
    font-weight: 600;
    color: var(--primary-color);
}

.answer-content em {
    font-style: italic;
    color: var(--text-secondary);
}

.answer-content code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #e83e8c;
    border: 1px solid #e0e0e0;
}

.answer-content pre {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    margin: 1em 0;
}

.answer-content pre code {
    background: transparent;
    padding: 0;
    border: none;
    color: #333;
    font-size: 0.9em;
}

.answer-content ul,
.answer-content ol {
    margin: 1em 0;
    padding-left: 2em;
}

.answer-content ul {
    list-style-type: disc;
}

.answer-content ol {
    list-style-type: decimal;
}

.answer-content li {
    margin: 0.5em 0;
    line-height: 1.6;
}

.answer-content ul ul,
.answer-content ol ul {
    list-style-type: circle;
    margin-top: 0.25em;
}

.answer-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1em;
    margin: 1em 0;
    color: var(--text-secondary);
    font-style: italic;
}

.answer-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1.5em 0;
}

.answer-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
    border: 1px solid var(--border-color);
}

.answer-content th,
.answer-content td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

.answer-content th {
    background: var(--background);
    font-weight: 600;
}

.answer-content a {
    color: var(--primary-color);
    text-decoration: underline;
}

.answer-content a:hover {
    color: var(--primary-hover);
}

.answer-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

/* Error Section */
.error-section {
    background: #FEE2E2;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    border-left: 4px solid var(--error-color);
}

.error-content h3 {
    color: var(--error-color);
    margin-bottom: 10px;
}

.error-text {
    color: var(--error-color);
    font-size: 0.9rem;
    margin-top: 10px;
}

/* History Section */
.history-section {
    background: var(--surface);
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.history-list {
    max-height: 500px;
    overflow-y: auto;
}

.history-item {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.3s;
}

.history-item:hover {
    background: var(--background);
}

.history-item:last-child {
    border-bottom: none;
}

.history-question {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.history-details {
    display: flex;
    gap: 15px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.loading-text {
    text-align: center;
    color: var(--text-secondary);
    padding: 20px;
}

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

.modal-content {
    background: var(--surface);
    padding: 40px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: 90%;
}

.modal-content h2 {
    margin-bottom: 10px;
    color: var(--primary-color);
}

.modal-content p {
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.login-form input {
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Footer */
footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
}

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

    .input-footer {
        flex-direction: column;
    }

    .name-input {
        width: 100%;
    }

    .primary-btn {
        width: 100%;
    }

    .answer-actions {
        flex-direction: column;
    }

    .secondary-btn {
        width: 100%;
    }
}
