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

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --bg-color: #f8fafc;
    --text-color: #1e293b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

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

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    padding: 30px 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 30px;
}

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

header p {
    color: var(--secondary-color);
    font-size: 1.1rem;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 20px;
}

/* Chat Container */
.chat-container {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    height: 600px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

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

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

.message-content {
    padding: 15px 20px;
    border-radius: 12px;
    max-width: 80%;
}

.bot-message .message-content {
    background: #f1f5f9;
    border-left: 4px solid var(--primary-color);
}

.user-message .message-content {
    background: var(--primary-color);
    color: white;
    margin-left: auto;
}

.message-content p {
    margin-bottom: 10px;
}

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

/* Options */
.options-container {
    margin-top: 15px;
}

.option-btn {
    display: block;
    width: 100%;
    padding: 12px 20px;
    margin-bottom: 10px;
    background: white;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1rem;
}

.option-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* Derivatives */
.derivatives-list {
    margin-top: 15px;
}

.derivative-item {
    display: flex;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.derivative-item input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
}

.derivative-item label {
    cursor: pointer;
    flex: 1;
}

/* Suggestions */
.suggestions-container {
    margin-top: 20px;
}

.intent-group {
    margin-bottom: 25px;
}

.intent-group h4 {
    color: var(--primary-color);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
}

.suggestion-item {
    padding: 15px;
    margin-bottom: 12px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.3s;
}

.suggestion-item:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.suggestion-title {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 8px;
}

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

.suggestion-source {
    display: inline-block;
    padding: 3px 8px;
    background: var(--bg-color);
    border-radius: 4px;
    font-size: 0.85rem;
    margin-top: 5px;
}

/* Chat Input */
.chat-input-area {
    display: flex;
    padding: 20px;
    border-top: 1px solid var(--border-color);
    gap: 10px;
}

#messageInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

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

#sendButton {
    padding: 12px 30px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background 0.3s;
}

#sendButton:hover {
    background: #1d4ed8;
}

#sendButton:disabled {
    background: var(--secondary-color);
    cursor: not-allowed;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-section {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.sidebar-section h3 {
    margin-bottom: 15px;
    color: var(--text-color);
    font-size: 1.1rem;
}

.btn-secondary {
    display: block;
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    background: white;
    border: 2px solid var(--border-color);
    color: var(--text-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

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

.info-item {
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.info-item strong {
    color: var(--secondary-color);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.close {
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: var(--secondary-color);
}

.close:hover {
    color: var(--text-color);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
}

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

.btn-primary {
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-small {
    padding: 6px 12px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    margin-left: 10px;
}

/* Loader */
.loader {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Responsive */
@media (max-width: 968px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        order: -1;
    }
}

/* History List */
.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.empty-text {
    text-align: center;
    color: #888;
    font-size: 0.9em;
    padding: 20px 10px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
    gap: 10px;
}

.history-item:hover {
    background: #f1f5f9;
}

.history-item.active {
    background: #e0e7ff;
    border-left: 3px solid var(--primary-color);
}

.history-content {
    flex: 1;
    cursor: pointer;
    min-width: 0;
}

.history-keyword {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-date {
    font-size: 0.85em;
    color: #888;
}

.history-delete-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 5px 8px;
    border-radius: 4px;
    opacity: 0;
    transition: all 0.2s;
    flex-shrink: 0;
}

.history-item:hover .history-delete-btn {
    opacity: 1;
}

.history-delete-btn:hover {
    background: #fee;
    transform: scale(1.1);
}
