:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --text-color: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --user-msg-bg: #eff6ff;
    --assistant-msg-bg: #f1f5f9;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

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

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;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 20px;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary-color), #1e40af);
    color: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    flex-shrink: 0;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 4px;
    font-weight: 700;
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

.main-content {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 20px;
    align-items: start;
    flex: 1;
    min-height: 0;
}

/* Links Section */
.links-section {
    background: var(--surface-color);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.add-link-form {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.add-link-form input {
    flex: 1;
}

.links-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.link-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.link-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.link-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-size: 0.875rem;
    font-weight: 600;
    flex-shrink: 0;
}

.link-url {
    color: var(--text-color);
    text-decoration: none;
    word-break: break-all;
    font-size: 0.875rem;
    line-height: 1.4;
}

.link-url:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Chat Section */
.chat-section {
    background: var(--surface-color);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.chat-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
}

.message {
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

.message.user {
    background: var(--user-msg-bg);
    border: 1px solid #bfdbfe;
    margin-left: auto;
    margin-right: 0;
}

.message.assistant {
    background: var(--assistant-msg-bg);
    border: 1px solid var(--border-color);
    margin-right: auto;
    margin-left: 0;
}

.message-content {
    font-size: 0.9375rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

.chat-input-form {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.chat-input-form input {
    flex: 1;
}

/* Form Elements */
input[type="url"],
input[type="text"] {
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9375rem;
    transition: all 0.2s;
    background: var(--surface-color);
}

input[type="url"]:focus,
input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

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

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

.btn-secondary {
    background: var(--secondary-color);
    color: white;
    font-size: 0.875rem;
    padding: 8px 16px;
}

.btn-secondary:hover:not(:disabled) {
    background: #475569;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
    font-size: 0.9375rem;
}

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    background: var(--surface-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary-color);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 1000;
    max-width: 400px;
}

.notification.show {
    transform: translateX(0);
}

.notification.success {
    border-left-color: var(--success-color);
}

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

/* Scrollbar styling */
.chat-container::-webkit-scrollbar,
.links-section::-webkit-scrollbar {
    width: 8px;
}

.chat-container::-webkit-scrollbar-track,
.links-section::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb,
.links-section::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb:hover,
.links-section::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

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

    .links-section {
        position: static;
        max-height: none;
    }

    .chat-section {
        height: 600px;
    }
}

@media (max-width: 640px) {
    header h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 0.9375rem;
    }

    .add-link-form,
    .chat-input-form {
        flex-direction: column;
    }

    .add-link-form input,
    .chat-input-form input {
        width: 100%;
    }

    .message {
        max-width: 95%;
    }
}
