/* Study Chat Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #4B9CD3 0%, #13294B 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 90px 20px 20px;
}

.study-container {
    width: 100%;
    max-width: 1400px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    height: 90vh;
    max-height: 900px;
}

/* Header */
.header {
    padding: 20px 30px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    border-radius: 16px 16px 0 0;
}

.header h1 {
    font-size: 24px;
    color: #333;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.nav-btn, .settings-btn {
    background: #4B9CD3;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.nav-btn:hover, .settings-btn:hover {
    background: #3A7BB0;
}

/* Main Content Layout */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 300px;
    border-right: 1px solid #e0e0e0;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    font-size: 18px;
    color: #333;
}

.btn-icon {
    background: #4B9CD3;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s;
}

.btn-icon:hover {
    background: #3A7BB0;
}

/* Export Menu */
.export-menu {
    position: relative;
    display: inline-block;
}

.export-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: white;
    min-width: 180px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    z-index: 1000;
    margin-top: 5px;
}

.export-dropdown.show {
    display: block;
}

.export-dropdown button {
    display: block;
    width: 100%;
    padding: 10px 15px;
    border: none;
    background: white;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background 0.2s;
    border-bottom: 1px solid #f0f0f0;
}

.export-dropdown button:first-child {
    border-radius: 6px 6px 0 0;
}

.export-dropdown button:last-child {
    border-radius: 0 0 6px 6px;
    border-bottom: none;
}

.export-dropdown button:hover {
    background: #f5f5f5;
}

.topics-list {
    flex: 1;
    overflow-y: auto;
}

.topic-item {
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    transition: background 0.2s;
}

.topic-item:hover {
    background: #f0f0f0;
}

.topic-item.active {
    background: #e8f4f8;
    border-left: 4px solid #4B9CD3;
}

.topic-item-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.topic-item-desc {
    font-size: 13px;
    color: #666;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Center Content */
.center-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Topic Input Section */
.topic-input-section {
    padding: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.empty-state {
    margin-bottom: 30px;
}

.empty-state h2 {
    font-size: 28px;
    color: #333;
    margin-bottom: 10px;
}

.empty-state p {
    font-size: 16px;
    color: #666;
    max-width: 600px;
}

.topic-input-wrapper {
    width: 100%;
    max-width: 700px;
}

.topic-input-wrapper label {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    text-align: left;
}

.topic-input-wrapper textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: border-color 0.3s;
}

.topic-input-wrapper textarea:focus {
    border-color: #4B9CD3;
}

.topic-input-wrapper button {
    width: 100%;
    margin-top: 15px;
    background: #4B9CD3;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: background 0.3s;
}

.topic-input-wrapper button:hover:not(:disabled) {
    background: #3A7BB0;
}

.topic-input-wrapper button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Overview Section */
.overview-section {
    padding: 30px;
    background: #f9f9f9;
    border-bottom: 1px solid #e0e0e0;
    overflow-y: auto;
    max-height: 250px;
}

.overview-section h2 {
    font-size: 22px;
    color: #333;
    margin-bottom: 15px;
}

.overview-content {
    color: #555;
    line-height: 1.8;
}

/* Chat Section */
.chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    padding: 15px 30px;
    border-bottom: 1px solid #e0e0e0;
    background: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    font-size: 18px;
    color: #333;
}

.btn-export {
    background: #13294B;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.btn-export:hover {
    background: #0d1d35;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 30px;
    background: #f9f9f9;
}

.empty-chat {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.message {
    margin-bottom: 20px;
    display: flex;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message.user .message-content {
    background: #4B9CD3;
    color: white;
}

.message.assistant .message-content {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
}

/* Markdown styling for assistant messages */
.message.assistant .message-content h1,
.message.assistant .message-content h2,
.message.assistant .message-content h3 {
    margin-top: 12px;
    margin-bottom: 8px;
    font-weight: 600;
    color: #13294B;
}

.message.assistant .message-content h1 { font-size: 1.5em; }
.message.assistant .message-content h2 { font-size: 1.3em; }
.message.assistant .message-content h3 { font-size: 1.1em; }

.message.assistant .message-content p {
    margin-bottom: 8px;
}

.message.assistant .message-content ul,
.message.assistant .message-content ol {
    margin-left: 20px;
    margin-bottom: 8px;
}

.message.assistant .message-content li {
    margin-bottom: 4px;
}

.message.assistant .message-content strong {
    font-weight: 600;
    color: #13294B;
}

.message.assistant .message-content em {
    font-style: italic;
}

.message.assistant .message-content code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #c7254e;
}

.message.assistant .message-content pre {
    background: #f5f5f5;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.message.assistant .message-content pre code {
    background: none;
    padding: 0;
    color: #333;
}

.message.assistant .message-content blockquote {
    border-left: 4px solid #4B9CD3;
    padding-left: 12px;
    margin: 8px 0;
    color: #666;
    font-style: italic;
}

.message.assistant .message-content a {
    color: #4B9CD3;
    text-decoration: none;
    border-bottom: 1px solid #4B9CD3;
}

.message.assistant .message-content a:hover {
    color: #3A7BB0;
    border-bottom-color: #3A7BB0;
}

/* Tables */
.message.assistant .message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
}

.message.assistant .message-content th,
.message.assistant .message-content td {
    border: 1px solid #e0e0e0;
    padding: 8px;
    text-align: left;
}

.message.assistant .message-content th {
    background: #f5f5f5;
    font-weight: 600;
    color: #13294B;
}

/* Input Container */
.input-container {
    padding: 20px 30px;
    border-top: 1px solid #e0e0e0;
    background: white;
}

.input-wrapper {
    display: flex;
    gap: 10px;
}

#userInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

#userInput:focus {
    border-color: #4B9CD3;
}

#sendBtn {
    background: #4B9CD3;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.3s;
}

#sendBtn:hover:not(:disabled) {
    background: #3A7BB0;
}

#sendBtn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Typing Indicator */
.typing-indicator {
    padding: 12px 16px;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4B9CD3;
    margin: 0 2px;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease-in;
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 22px;
    color: #333;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
    font-size: 14px;
}

.form-group label.checkbox-inline-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group label.checkbox-inline-label input[type="checkbox"] {
    width: auto;
    margin: 0;
    cursor: pointer;
}

.form-group label.checkbox-inline-label span {
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s, opacity 0.3s, background-color 0.3s;
    font-family: inherit;
}

.form-group input:disabled,
.form-group select:disabled,
.form-group textarea:disabled {
    opacity: 0.5;
    background-color: #f5f5f5;
    cursor: not-allowed;
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #4B9CD3;
}

.form-group small {
    color: #666;
    font-size: 12px;
    margin-top: 5px;
    display: block;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-primary {
    background: #4B9CD3;
    color: white;
}

.btn-primary:hover {
    background: #3A7BB0;
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.status-message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 8px;
    font-size: 14px;
    display: none;
}

.status-message.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.status-message.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* Slider container styles */
.slider-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

.slider-container input[type="range"] {
    flex: 1;
    padding: 0;
    height: 6px;
    border: none;
}

.slider-container input[type="number"] {
    width: 70px;
    padding: 6px 10px;
    text-align: center;
}

/* Info tooltip styles */
.info-tooltip {
    cursor: help;
    display: inline-block;
    background: #4B9CD3;
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    text-align: center;
    font-size: 12px;
    line-height: 16px;
    margin-left: 5px;
}

.info-tooltip:hover {
    background: #3A7BB0;
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4B9CD3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
