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

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --bg-primary: #ffffff;
    --bg-secondary: #f5f7fa;
    --bg-sidebar: #2c3e50;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #e0e6ed;
    --success-color: #48bb78;
    --error-color: #f56565;
    --warning-color: #ed8936;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--bg-sidebar);
    color: white;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    margin-bottom: 15px;
    font-size: 24px;
}

.btn-new-chat {
    width: 100%;
    padding: 10px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.3s;
}

.btn-new-chat:hover {
    background: #5a67d8;
}

.sidebar-sessions {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.sidebar-sessions h3 {
    font-size: 12px;
    text-transform: uppercase;
    opacity: 0.7;
    margin-bottom: 15px;
}

.sessions-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.session-item {
    padding: 12px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
}

.session-item:hover {
    background: rgba(255,255,255,0.1);
}

.session-item.active {
    background: var(--primary-color);
}

.session-title {
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    opacity: 0.7;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    text-align: center;
}

.user-name {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
}

.user-actions {
    display: flex;
    justify-content: space-around;
    font-size: 14px;
}

.user-actions a {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: color 0.3s;
}

.user-actions a:hover {
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.chat-header {
    padding: 20px 30px;
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h2 {
    font-size: 20px;
    color: var(--text-primary);
}

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

.btn-icon {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s;
}

.btn-icon:hover {
    background: var(--bg-secondary);
    transform: translateY(-2px);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    background: var(--bg-secondary);
}

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

.welcome-message h2 {
    color: var(--text-primary);
    margin-bottom: 10px;
}

.message {
    display: flex;
    margin-bottom: 25px;
    animation: fadeIn 0.3s;
}

@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: 15px 20px;
    border-radius: 15px;
    position: relative;
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: white;
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.message-role {
    font-weight: 600;
    font-size: 0.9em;
    color: rgba(0,0,0,0.6);
}

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

.message-time {
    font-size: 0.85em;
    color: rgba(0,0,0,0.4);
    font-style: italic;
}

.message.user .message-time {
    color: rgba(255,255,255,0.7);
}

.message-text {
    line-height: 1.6;
    word-wrap: break-word;
}

/* Formatted message styles */
.formatted-message {
    font-size: 14px;
    line-height: 1.6;
}

.formatted-message p {
    margin: 0 0 12px 0;
    line-height: 1.7;
}

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

.formatted-message ul, 
.formatted-message ol {
    margin: 12px 0;
    padding-left: 25px;
}

.formatted-message li {
    margin: 8px 0;
    line-height: 1.6;
}

/* Sources section with better formatting */
.sources-section {
    margin: 15px 0;
}

.formatted-message .sources-list {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(102, 126, 234, 0.02) 100%);
    border-left: 3px solid var(--primary-color);
    padding: 12px 15px;
    margin: 8px 0;
    border-radius: 6px;
    list-style: none;
}

.formatted-message .sources-list li {
    position: relative;
    padding-left: 25px;
    margin: 6px 0;
    color: #555;
}

.formatted-message .sources-list li:before {
    content: "📁";
    position: absolute;
    left: 0;
    font-size: 14px;
}

/* Note sections */
.formatted-message .note-section {
    background: linear-gradient(135deg, rgba(237, 137, 54, 0.08) 0%, rgba(237, 137, 54, 0.03) 100%);
    border-left: 3px solid var(--warning-color);
    padding: 12px 15px;
    margin: 15px 0;
    border-radius: 6px;
    line-height: 1.6;
}

/* Source info styling */
.formatted-message .source-info {
    color: #666;
    font-size: 13px;
    font-style: italic;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #ddd;
}

/* Item numbers and prices */
.formatted-message .item-number {
    background: #f0f4f8;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
    color: #2c5282;
    font-family: monospace;
}

.formatted-message .price {
    background: #e6fffa;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
    color: #00695c;
    font-family: monospace;
}

.formatted-message strong {
    color: var(--text-primary);
    font-weight: 600;
}

.formatted-message br {
    display: block;
    content: "";
    margin-top: 8px;
}

/* Make assistant messages slightly different background */
.message.assistant .formatted-message {
    background: rgba(245, 247, 250, 0.3);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.05);
}

.message-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(0,0,0,0.05);
}

.message-action {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;
}

/* No Answer Button Styles */
.message-action.no-answer-btn {
    background-color: #dc3545 !important;
    color: white !important;
    border: none !important;
}

.message-action.no-answer-btn:hover {
    background-color: #c82333 !important;
    transform: scale(1.05);
}

.message-action.no-answer-btn:disabled {
    background-color: #28a745 !important;
    opacity: 0.8;
    cursor: not-allowed;
}

.message-action:hover {
    background: rgba(0,0,0,0.05);
}

.message-action.liked {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

.message-action.disliked {
    background: var(--error-color);
    color: white;
    border-color: var(--error-color);
}

/* Chat Input */
.chat-input-area {
    padding: 20px 30px;
    background: white;
    border-top: 1px solid var(--border-color);
}

.typing-indicator {
    padding: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-style: italic;
}

.dots {
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

.input-wrapper {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

#messageInput {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    resize: none;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    max-height: 150px;
}

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

.btn-send {
    padding: 12px 30px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
}

.btn-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Modal */
.modal {
    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: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    min-width: 400px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

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

.modal-content select,
.modal-content textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 20px;
    font-family: inherit;
}

.modal-content textarea {
    min-height: 100px;
    resize: vertical;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}

.modal-actions button:first-child {
    background: var(--primary-color);
    color: white;
}

.modal-actions button:last-child {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -300px;
        z-index: 100;
        transition: left 0.3s;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .message-content {
        max-width: 85%;
    }
}