/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #333;
}

.container {
    width: 100%;
    max-width: 1400px;
    height: 90vh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);

}

/* Header styles */
.header {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    padding: 30px;
    text-align: center;
    color: white;
    position: relative;
    overflow: hidden;
}

.header-nav {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 2;
}

.home-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: white;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.home-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.home-btn svg {
    width: 18px;
    height: 18px;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="50" cy="50" r="1" fill="white" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    pointer-events: none;
}

.app-title {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.app-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
    position: relative;
    z-index: 1;
}

/* Chat container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
}

.chat-window {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.chat-window::-webkit-scrollbar {
    width: 6px;
}

.chat-window::-webkit-scrollbar-track {
    background: transparent;
}

.chat-window::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.chat-window::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Message styles */
.message {
    margin-bottom: 25px;
    display: flex;
    animation: fadeInUp 0.3s ease-out;
}

/* Collapsible message styles */
.message-text.truncated {
    max-height: 5.6em; /* Approximately 4-5 lines */
    overflow: hidden;
    position: relative;
}

.message-text.truncated::after {
    content: '...';
    position: absolute;
    bottom: 0;
    right: 0;
    background: inherit;
    padding-left: 8px;
}

.user-message .message-text.truncated::after {
    background: linear-gradient(to right, transparent, #8b5cf6 20%);
}

.ai-message .message-text.truncated::after {
    background: linear-gradient(to right, transparent, #f8fafc 20%);
}

.expand-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 6px 12px;
    margin-top: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
    color: #6366f1;
}

.user-message .expand-btn {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}

.expand-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.user-message .expand-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.expand-icon {
    transition: transform 0.2s ease;
}

.expand-btn.collapsed .expand-icon {
    transform: rotate(0deg);
}

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

.message.user-message {
    justify-content: flex-end;
}

.message.ai-message {
    justify-content: flex-start;
}

.message.system-message {
    justify-content: center;
}

.message-content {
    max-width: 85%;
    background: white;
    border-radius: 16px;
    padding: 18px 22px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.user-message .message-content {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
}

.ai-message .message-content {
    background: #f8fafc;
    border-left: 4px solid #6366f1;
}

.system-message .message-content {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    max-width: 60%;
    text-align: center;
}

.system-message .message-text {
    text-align: center;
}

.message-text {
    font-size: 1rem;
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 8px;
    text-align: right;
}

.system-message .message-time {
    text-align: center;
}

/* Loading styles */
.loading-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    gap: 15px;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(99, 102, 241, 0.1);
    border-top: 3px solid #6366f1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    color: #6366f1;
    font-weight: 500;
}

/* Input section */
.input-section {
    background: white;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    padding: 25px 30px;
}

/* Preset buttons */
.preset-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: absolute;
    right: 20px;
    top: 20px;
    z-index: 10;
}

.preset-btn {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    transition: all 0.2s ease;
    min-width: 100px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(5px);
}

.preset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.preset-btn:active {
    transform: translateY(0);
}

.preset-label {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 1px;
}

.preset-desc {
    font-size: 0.65rem;
    opacity: 0.6;
    font-weight: 400;
}

.normal-preset {
    border-color: #10b981;
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
}

.normal-preset:hover {
    border-color: #059669;
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
}

.normal-preset .preset-label {
    color: #065f46;
}

.normal-preset .preset-desc {
    color: #047857;
}

.injection-preset {
    border-color: #ef4444;
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
}

.injection-preset:hover {
    border-color: #dc2626;
    background: linear-gradient(135deg, #fee2e2, #fecaca);
}

.injection-preset .preset-label {
    color: #991b1b;
}

.injection-preset .preset-desc {
    color: #dc2626;
}

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

#textInput {
    flex: 1;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 15px 18px;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    resize: vertical;
    min-height: 60px;
    max-height: 150px;
    transition: all 0.2s ease;
    background: #fafafa;
}

#textInput:focus {
    outline: none;
    border-color: #6366f1;
    background: white;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#textInput::placeholder {
    color: #9ca3af;
    line-height: 1.4;
}

.summarize-btn {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 15px 25px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    min-width: 130px;
    justify-content: center;
}

.summarize-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.summarize-btn:active {
    transform: translateY(0);
}

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

.btn-icon {
    transition: transform 0.2s ease;
}

.summarize-btn:hover .btn-icon {
    transform: translateX(2px);
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    font-size: 0.85rem;
    color: #6b7280;
}

.input-hint {
    font-style: italic;
    opacity: 0.8;
}

/* Error toast */
.error-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #ef4444;
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(239, 68, 68, 0.3);
    z-index: 1000;
    transform: translateX(400px);
    transition: transform 0.3s ease;
    max-width: 400px;
}

.error-toast.show {
    transform: translateX(0);
}

.error-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.error-icon {
    flex-shrink: 0;
}

.error-message {
    font-weight: 500;
}

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

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

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        height: 95vh;
        border-radius: 15px;
    }
    
    .header {
        padding: 20px;
    }
    
    .app-title {
        font-size: 2rem;
    }
    
    .chat-window {
        padding: 20px;
    }
    
    .input-section {
        padding: 20px;
    }
    
    .input-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .summarize-btn {
        margin-top: 10px;
    }
    
    .input-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .message-content {
        max-width: 90%;
    }
    
    .preset-buttons {
        position: static;
        flex-direction: row;
        justify-content: center;
        margin-bottom: 15px;
        gap: 10px;
    }

    .preset-btn {
        min-width: auto;
        width: auto;
        padding: 10px 15px;
    }

    .preset-label {
        font-size: 0.8rem;
    }

    .preset-desc {
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .app-title {
        font-size: 1.75rem;
    }
    
    .app-subtitle {
        font-size: 1rem;
    }
    
    .chat-window {
        padding: 15px;
    }
    
    .input-section {
        padding: 15px;
    }
}
