/* ==========================================================================
   STUDY BUDDY - CUTE & MINIMALIST BLUE THEME STYLESHEET
   ========================================================================== */

:root {
    /* Color Palette */
    --primary: #3B82F6;
    --primary-hover: #2563EB;
    --primary-light: #BFDBFE;
    --primary-subtle: #EFF6FF;
    --accent: #60A5FA;
    
    --bg-main: #F0F9FF;
    --bg-card: #FFFFFF;
    
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    
    --chat-user-bg: #DBEAFE;
    --chat-user-text: #1E3A8A;
    --chat-bot-bg: #FFFFFF;
    --chat-bot-text: #1E293B;
    
    --border-color: #E2E8F0;
    --danger: #EF4444;
    --danger-hover: #DC2626;
    --success: #10B981;
    
    /* Typography */
    --font-family: 'Nunito', 'Poppins', sans-serif;
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(59, 130, 246, 0.05);
    --shadow-md: 0 4px 12px rgba(59, 130, 246, 0.08);
    --shadow-lg: 0 10px 25px rgba(59, 130, 246, 0.12);
}

/* Reset & Basic Setup */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* App Container Layout */
.app-container {
    width: 100%;
    max-width: 900px;
    height: 100vh;
    background-color: var(--bg-main);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: var(--shadow-lg);
}

@media (min-width: 901px) {
    .app-container {
        height: 95vh;
        border-radius: var(--radius-lg);
        border: 1px solid rgba(191, 219, 254, 0.6);
        overflow: hidden;
    }
}

/* Header Styles */
.app-header {
    background-color: var(--bg-card);
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

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

.avatar-logo {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 22px;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

.brand-info h1 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge {
    background-color: var(--primary-light);
    color: var(--primary-hover);
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 700;
}

.status {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* Header Action Buttons */
.header-actions {
    display: flex;
    gap: 8px;
}

button {
    font-family: var(--font-family);
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.2s ease;
}

.btn-secondary {
    background-color: var(--primary-subtle);
    color: var(--primary);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.btn-danger {
    background-color: #FEE2E2;
    color: var(--danger);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-danger:hover {
    background-color: #FCA5A5;
    color: var(--danger-hover);
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.95rem;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-icon {
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.2rem;
    padding: 4px;
}

.btn-icon:hover {
    color: var(--text-primary);
}

/* Main Chat Scrollable Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Welcome Box & Starter Suggestions */
.welcome-box {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    border: 1px solid rgba(191, 219, 254, 0.7);
    box-shadow: var(--shadow-md);
    margin-bottom: 10px;
}

.welcome-avatar {
    width: 60px;
    height: 60px;
    background: var(--primary-subtle);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 12px auto;
}

.welcome-box h2 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.welcome-box p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 20px;
    max-width: 550px;
    margin-left: auto;
    margin-right: auto;
}

.suggestion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.suggestion-card {
    background-color: var(--bg-main);
    border: 1px solid var(--primary-light);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    transition: all 0.2s ease;
}

.suggestion-card:hover {
    background-color: var(--primary-subtle);
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.card-icon {
    font-size: 22px;
}

.card-text {
    display: flex;
    flex-direction: column;
}

.card-text strong {
    font-size: 0.75rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-text span {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 600;
}

/* Chat Messages */
.messages-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeIn 0.3s ease-in-out;
}

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

.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-message.bot {
    align-self: flex-start;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

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

.user-avatar {
    background-color: var(--primary-light);
    color: var(--primary-hover);
}

.chat-bubble {
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    word-break: break-word;
}

.user-bubble {
    background-color: var(--chat-user-bg);
    color: var(--chat-user-text);
    border-bottom-right-radius: 4px;
}

.bot-bubble {
    background-color: var(--chat-bot-bg);
    color: var(--chat-bot-text);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.error-bubble {
    background-color: #FEF2F2;
    color: #991B1B;
    border: 1px solid #FCA5A5;
}

/* Formatted Content inside Bot Message */
.chat-bubble p {
    margin-bottom: 10px;
}

.chat-bubble p:last-child {
    margin-bottom: 0;
}

.chat-bubble strong {
    font-weight: 700;
}

.chat-bubble ul, .chat-bubble ol {
    margin: 8px 0 8px 20px;
}

.chat-bubble li {
    margin-bottom: 4px;
}

.chat-bubble code {
    background-color: #F1F5F9;
    color: #0F172A;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.88em;
}

.chat-bubble pre {
    background-color: #1E293B;
    color: #F8FAFC;
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 10px 0;
}

.chat-bubble pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

/* Typing Indicator Animation */
.typing-bubble {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 5px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background-color: var(--primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* Input Area Fixed Bottom */
.input-container {
    background-color: var(--bg-card);
    padding: 14px 20px;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.03);
}

.chat-form {
    display: flex;
    align-items: center;
}

.input-wrapper {
    width: 100%;
    display: flex;
    align-items: center;
    background-color: var(--bg-main);
    border: 2px solid var(--primary-light);
    border-radius: var(--radius-full);
    padding: 6px 10px 6px 18px;
    transition: all 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    background-color: #FFFFFF;
}

textarea {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-family: var(--font-family);
    font-size: 0.95rem;
    color: var(--text-primary);
    resize: none;
    max-height: 120px;
    padding: 6px 0;
}

textarea::placeholder {
    color: var(--text-muted);
}

.btn-send {
    width: 40px;
    height: 40px;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    margin-left: 8px;
}

.btn-send:hover {
    background-color: var(--primary-hover);
    transform: scale(1.05);
}

.btn-send:disabled {
    background-color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

.footer-note {
    text-align: center;
    margin-top: 6px;
    color: var(--text-muted);
}

/* Modal Window Styling */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-card {
    background: white;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 450px;
    padding: 24px;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-header h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-body p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.input-group input {
    width: 100%;
    padding: 10px 40px 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.9rem;
    outline: none;
}

.input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.btn-icon-inner {
    position: absolute;
    right: 10px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.api-help {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.api-help a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.api-help a:hover {
    text-decoration: underline;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
}

/* Helper Class */
.hidden {
    display: none !important;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .brand-info h1 {
        font-size: 1.1rem;
    }
    
    .btn-text {
        display: none;
    }
    
    .btn-secondary, .btn-danger {
        padding: 8px 10px;
    }
    
    .chat-message {
        max-width: 92%;
    }
    
    .suggestion-grid {
        grid-template-columns: 1fr;
    }

    .footer-note {
        display: none;
    }
}
