﻿/* Enhanced CSS for Visit Famagusta AI Assistant */

/* Base styles with enhanced support */
:root {
    --primary-color: #1d84b5;
    --primary-dark: #1a75a0;
    --primary-light: #3b9bcf;
    --light-bg: #f8fafc;
    --dark-bg: #1f2937;
    --light-text: #f9fafb;
    --dark-text: #111827;
    --border-light: #e2e8f0;
    --border-dark: #374151;
    --sidebar-width: 260px;
    --sidebar-width-desktop: 360px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --vh: 100vh;
    --keyboard-height: 0px;
    /* Enhanced color palette */
    --surface-primary: #ffffff;
    --surface-secondary: #f1f5f9;
    --surface-tertiary: #e2e8f0;
    --accent-blue: #0ea5e9;
    --accent-green: #10b981;
    --accent-amber: #f59e0b;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    /* Border radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html {
    height: 100%;
    height: calc(var(--vh, 1vh) * 100);
    width: 100%;
    overflow: hidden;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background-color: var(--light-bg);
    color: var(--text-primary);
    display: flex;
    height: 100%;
    height: calc(var(--vh, 1vh) * 100);
    min-height: -webkit-fill-available;
    width: 100%;
    overflow: hidden;
    overscroll-behavior-y: none;
    -webkit-overflow-scrolling: touch;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* App container */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
    height: calc(var(--vh, 1vh) * 100);
    min-height: -webkit-fill-available;
    overflow: hidden;
    position: relative;
    padding: var(--safe-top) var(--safe-right) 0 var(--safe-left);
    background: linear-gradient(135deg, var(--light-bg) 0%, #f1f5f9 100%);
}

/* Enhanced Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    height: calc(var(--vh, 1vh) * 100);
    background: linear-gradient(180deg, var(--surface-primary) 0%, #fefefe 100%);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 100;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.sidebar-content {
    padding: 20px 16px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden; /* Fix horizontal scrollbar */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--border-light) transparent;
}

    /* Custom scrollbar for sidebar */
    .sidebar-content::-webkit-scrollbar {
        width: 4px;
    }

    .sidebar-content::-webkit-scrollbar-track {
        background: transparent;
    }

    .sidebar-content::-webkit-scrollbar-thumb {
        background: var(--border-light);
        border-radius: 2px;
    }

        .sidebar-content::-webkit-scrollbar-thumb:hover {
            background: var(--text-tertiary);
        }

.toggle-sidebar-btn {
    display: none;
    position: absolute;
    top: 50%;
    right: -12px;
    transform: translateY(-50%);
    background-color: var(--surface-primary);
    border: 1px solid var(--border-light);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    z-index: 101;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

    .toggle-sidebar-btn:hover {
        box-shadow: var(--shadow-md);
        color: var(--primary-color);
    }

.menu-toggle-btn {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    margin-right: 8px;
    font-size: 18px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

    .menu-toggle-btn:hover,
    .menu-toggle-btn:active {
        background-color: var(--surface-secondary);
        color: var(--primary-color);
        transform: scale(1.05);
    }

/* Logo container */
.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 0 8px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 20px;
}

    .logo-container img {
        max-height: 36px;
        width: auto;
        object-fit: contain;
    }

    .logo-container h1 {
        font-size: 16px;
        font-weight: 600;
        color: var(--text-primary);
    }

/* New chat button */
.new-chat {
    margin-bottom: 24px;
}

#new-chat-btn {
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 44px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

    #new-chat-btn:before {
        content: '';
        position: absolute;
        inset: 0;
        background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.1));
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    #new-chat-btn:hover:before {
        opacity: 1;
    }

    #new-chat-btn:hover,
    #new-chat-btn:active {
        transform: translateY(-1px);
        box-shadow: var(--shadow-md);
    }

    #new-chat-btn i {
        margin-right: 8px;
        font-size: 16px;
    }

/* Chat history */
.history-container {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden; /* Fix horizontal scrollbar */
    margin-bottom: 16px;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 0 4px;
}

    .history-header h2 {
        font-size: 13px;
        font-weight: 600;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.025em;
        margin: 0;
    }

.clear-history-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 11px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    min-height: 28px;
    font-weight: 500;
}

    .clear-history-btn:hover,
    .clear-history-btn:active {
        background-color: rgba(239, 68, 68, 0.1);
        color: #ef4444;
        transform: scale(1.05);
    }

#chat-history {
    list-style: none;
}

    #chat-history li {
        padding: 10px 12px;
        border-radius: var(--radius-md);
        margin-bottom: 6px;
        font-size: 13px;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-height: 36px;
        display: flex;
        align-items: center;
        color: var(--text-secondary);
        position: relative;
        max-width: 100%; /* Ensure it doesn't overflow */
    }

        #chat-history li:before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 3px;
            height: 0;
            background: var(--primary-color);
            border-radius: 0 2px 2px 0;
            transition: height 0.2s ease;
        }

        #chat-history li:hover,
        #chat-history li:active {
            background-color: var(--surface-secondary);
            color: var(--text-primary);
            transform: translateX(2px);
        }

            #chat-history li:hover:before {
                height: 60%;
            }

        #chat-history li.active {
            background: linear-gradient(135deg, rgba(29, 132, 181, 0.1), rgba(29, 132, 181, 0.05));
            color: var(--primary-color);
            font-weight: 600;
        }

            #chat-history li.active:before {
                height: 80%;
            }

/* Main content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    height: calc(var(--vh, 1vh) * 100);
    overflow: hidden;
    position: relative;
    min-width: 0;
    background: var(--surface-primary);
}

/* Enhanced header */
.chat-header {
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 5;
    flex-shrink: 0;
    min-height: 64px;
    box-shadow: var(--shadow-sm);
}

    .chat-header h1 {
        font-size: 18px;
        font-weight: 700;
        color: var(--text-primary);
        line-height: 1.2;
        background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }

.header-actions {
    display: flex;
    gap: 8px;
}

    .header-actions button {
        background: var(--surface-secondary);
        border: 1px solid var(--border-light);
        width: 40px;
        height: 40px;
        border-radius: var(--radius-lg);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: var(--text-secondary);
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        font-size: 16px;
    }

        .header-actions button:hover,
        .header-actions button:active {
            background: var(--primary-color);
            color: white;
            transform: translateY(-1px);
            box-shadow: var(--shadow-md);
            border-color: var(--primary-color);
        }

/* Enhanced chat messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    min-height: 0;
    padding-bottom: calc(160px + var(--safe-bottom));
    background: linear-gradient(180deg, var(--surface-primary) 0%, var(--surface-secondary) 100%);
}

    /* Custom scrollbar for chat messages */
    .chat-messages::-webkit-scrollbar {
        width: 6px;
    }

    .chat-messages::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.05);
        border-radius: 3px;
    }

    .chat-messages::-webkit-scrollbar-thumb {
        background: var(--border-light);
        border-radius: 3px;
        transition: background 0.2s ease;
    }

        .chat-messages::-webkit-scrollbar-thumb:hover {
            background: var(--text-tertiary);
        }

.welcome-message,
.message {
    display: flex;
    gap: 16px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    animation: messageSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Enhanced avatars */
.ai-avatar,
.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.ai-avatar {
    background: linear-gradient(135deg, #f5e1ba, #e6d3a3);
    color: var(--primary-color);
    border: 2px solid var(--surface-primary);
}

    .ai-avatar img {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        object-fit: cover;
    }

.user-avatar {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    border: 2px solid var(--surface-primary);
}

/* Enhanced message bubbles */
.message-content {
    flex-grow: 1;
    line-height: 1.6;
    padding-top: 2px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    position: relative;
}

.user-message .message-content {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    padding: 16px 20px;
    border-radius: 20px 20px 4px 20px;
    box-shadow: var(--shadow-md);
    margin-left: 40px;
}

.ai-message .message-content {
    background: var(--surface-primary);
    border: 1px solid var(--border-light);
    padding: 16px 20px;
    border-radius: 20px 20px 20px 4px;
    box-shadow: var(--shadow-sm);
    position: relative;
    width: 88%;
}

    .ai-message .message-content:before {
        content: '';
        position: absolute;
        left: -8px;
        top: 16px;
        width: 0;
        height: 0;
        border: 8px solid transparent;
        border-right-color: var(--surface-primary);
        border-left: 0;
    }

.message-content h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: inherit;
}

.message-content p {
    margin-bottom: 16px;
    color: inherit;
}

    .message-content p:last-child {
        margin-bottom: 0;
    }

/* Enhanced AI Response Styling */
.ai-response {
    line-height: 1.7;
}

    .ai-response h1, .ai-response h2, .ai-response h3,
    .ai-response h4, .ai-response h5, .ai-response h6 {
        margin: 24px 0 12px 0;
        font-weight: 600;
        color: var(--text-primary);
        border-bottom: 2px solid var(--border-light);
        padding-bottom: 8px;
        background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }

    .ai-response h1 {
        font-size: 20px;
    }

    .ai-response h2 {
        font-size: 18px;
    }

    .ai-response h3 {
        font-size: 16px;
    }

    .ai-response h4 {
        font-size: 15px;
    }

    .ai-response h5 {
        font-size: 14px;
    }

    .ai-response h6 {
        font-size: 13px;
    }

    .ai-response p {
        margin-bottom: 16px;
        color: var(--text-primary);
    }

    .ai-response ul, .ai-response ol {
        padding-left: 24px;
        margin-bottom: 16px;
    }

    .ai-response li {
        margin-bottom: 8px;
        line-height: 1.6;
        position: relative;
    }

    .ai-response ul li::marker {
        color: var(--primary-color);
    }

    .ai-response ol li::marker {
        color: var(--primary-color);
        font-weight: 600;
    }

    /* Enhanced link styling */
    .ai-response a, .message-content a {
        color: var(--primary-color);
        text-decoration: none;
        font-weight: 500;
        padding: 4px 8px;
        border-radius: var(--radius-sm);
        transition: all 0.2s ease;
        position: relative;
        display: inline-flex;
        align-items: center;
        gap: 4px;
        min-height: 32px;
        background: rgba(29, 132, 181, 0.05);
        border: 1px solid transparent;
    }

       

        .ai-response a[href^="http"]:after,
        .message-content a[href^="http"]:after {
            content: "↗";
            font-size: 12px;
            opacity: 0.7;
            margin-left: 2px;
        }

    .ai-response strong, .message-content strong {
        font-weight: 600;
        color: var(--primary-color);
    }

    .ai-response em, .message-content em {
        font-style: italic;
        color: var(--text-secondary);
    }

    .ai-response code, .message-content code {
        background: var(--surface-secondary);
        padding: 2px 6px;
        border-radius: var(--radius-sm);
        font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
        font-size: 0.9em;
        border: 1px solid var(--border-light);
        color: var(--accent-blue);
    }

    .ai-response blockquote, .message-content blockquote {
        border-left: 4px solid var(--primary-color);
        margin: 16px 0;
        padding: 16px 20px;
        background: linear-gradient(135deg, rgba(29, 132, 181, 0.05), rgba(29, 132, 181, 0.02));
        border-radius: 0 var(--radius-md) var(--radius-md) 0;
        font-style: italic;
        position: relative;
    }

/* Enhanced suggestion chips */
.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
}

.suggestion-chip {
    background: linear-gradient(135deg, var(--surface-primary), var(--surface-secondary));
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 12px 18px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--primary-color);
    text-align: center;
    display: inline-block;
    min-height: 44px;
    line-height: 1.3;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

    .suggestion-chip:before {
        content: '';
        position: absolute;
        inset: 0;
        background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .suggestion-chip:hover:before {
        opacity: 0.1;
    }

    .suggestion-chip:hover,
    .suggestion-chip:active {
        transform: translateY(-2px) scale(1.02);
        box-shadow: var(--shadow-lg);
        border-color: var(--primary-color);
    }

.user-message {
    flex-direction: row-reverse;
}

    .user-message .message-content {
        text-align: left;
    }

/* Enhanced chat input */
.chat-input-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-light);
    z-index: 10;
    padding: 20px 24px;
    padding-bottom: max(20px, var(--safe-bottom));
    transform: translateY(0);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--surface-primary);
    border: 2px solid var(--border-light);
    border-radius: 24px;
    padding: 12px 20px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    min-height: 52px;
 
    margin: 0 auto;
}

    .chat-input-area:focus-within {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 4px rgba(29, 132, 181, 0.1), var(--shadow-md);
        background: var(--surface-primary);
    }

#user-input {
    flex-grow: 1;
    padding: 8px 0;
    border: none;
    outline: none;
    font-size: 16px;
    resize: none;
    font-family: inherit;
    line-height: 1.5;
    color: var(--text-primary);
    max-height: 120px;
    overflow-y: auto;
    background: transparent;
    font-weight: 400;
}

    #user-input::placeholder {
        color: var(--text-tertiary);
        font-weight: 400;
    }

#send-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    border: none;
    color: white;
    cursor: pointer;
    font-size: 18px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

    #send-btn:hover,
    #send-btn:active {
        transform: scale(1.05);
        box-shadow: var(--shadow-md);
    }

    #send-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
        transform: none;
    }

/* Enhanced scroll button */
.scroll-bottom-btn {
    position: fixed;
    bottom: calc(140px + var(--safe-bottom));
    right: 30px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(20px) scale(0.8);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9;
    border: 2px solid var(--surface-primary);
}

    .scroll-bottom-btn.visible {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    .scroll-bottom-btn:hover {
        transform: translateY(-2px) scale(1.05);
        box-shadow: var(--shadow-xl);
    }

/* Enhanced media display */
.response-images,
.response-sources {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 2px solid var(--border-light);
}

    .response-images h4,
    .response-sources h4 {
        font-size: 15px;
        font-weight: 600;
        margin-bottom: 16px;
        color: var(--text-primary);
        background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }

.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.media-card {
    border-radius: var(--radius-xl);
    overflow: hidden;
    border: 1px solid var(--border-light);
    background: var(--surface-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

    .media-card:hover {
        transform: translateY(-4px) scale(1.02);
        box-shadow: var(--shadow-xl);
        border-color: var(--primary-color);
    }

    .media-card img,
    .media-card video {
        width: 100%;
        height: 160px;
        object-fit: cover;
        cursor: pointer;
        transition: all 0.3s ease;
    }

        .media-card img:hover,
        .media-card video:hover {
            opacity: 0.9;
           
        }

/* Enhanced source styling */
.sources-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.source-item {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, var(--surface-secondary), var(--surface-tertiary));
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    min-height: 36px;
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: var(--text-primary);
}


.source-number {
    margin-right: 8px;
    font-weight: 700;
    color: var(--primary-color);
    font-size: 12px;
    background: rgba(29, 132, 181, 0.1);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    min-width: 20px;
    text-align: center;
}



.source-item a {
    color: inherit;
    text-decoration: none;
    font-weight: 500;
}

.source-item .source-info {
    color: var(--text-tertiary);
    font-size: 10px;
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid var(--border-light);
}



/* Typing indicator */
.typing-indicator {
    padding: 16px 0;
}

.typing-dots {
    display: flex;
    gap: 6px;
    justify-content: center;
}

    .typing-dots span {
        animation: typingPulse 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite;
        font-size: 8px;
        width: 8px;
        height: 8px;
        background: var(--primary-color);
        border-radius: 50%;
        display: block;
    }

        .typing-dots span:nth-child(2) {
            animation-delay: 0.2s;
        }

        .typing-dots span:nth-child(3) {
            animation-delay: 0.4s;
        }

@keyframes typingPulse {
    0%, 60%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-8px) scale(1.2);
        opacity: 1;
    }
}

/* Sidebar footer */
.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

.footer-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--primary-color);
    text-decoration: none;
    border-radius: var(--radius-lg);
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
    min-height: 44px;
    background: linear-gradient(135deg, rgba(29, 132, 181, 0.05), rgba(29, 132, 181, 0.02));
    border: 1px solid rgba(29, 132, 181, 0.1);
    margin-bottom: 12px;
}

    .footer-link:hover {
        background: var(--primary-color);
        color: white;
        transform: translateY(-1px);
        box-shadow: var(--shadow-md);
    }

    .footer-link i {
        font-size: 16px;
        width: 20px;
        text-align: center;
    }

.powered-by {
    text-align: center;
    font-size: 11px;
    color: var(--text-tertiary);
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--surface-secondary);
    margin-bottom: 12px;
}

    .powered-by span {
        display: block;
        margin-bottom: 6px;
        font-weight: 500;
    }

.revitup-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    background: rgba(29, 132, 181, 0.1);
}

    .revitup-link:hover {
        background: var(--primary-color);
        color: white;
        transform: scale(1.05);
    }

    .revitup-link i {
        font-size: 10px;
        opacity: 0.8;
    }

.terms-disclaimer {
    text-align: center;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(29, 132, 181, 0.05), rgba(29, 132, 181, 0.02));
    border-radius: var(--radius-lg);
    border: 1px solid rgba(29, 132, 181, 0.1);
    opacity: 1;
    transform: translateY(0);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 120px;
    overflow: hidden;
}

    .terms-disclaimer.fade-out {
        opacity: 0;
        transform: translateY(-10px);
        max-height: 0;
        margin-bottom: 0;
        padding-top: 0;
        padding-bottom: 0;
    }

    .terms-disclaimer p {
        font-size: 12px;
        color: var(--text-secondary);
        margin: 0;
        line-height: 1.4;
        font-weight: 500;
    }

    .terms-disclaimer a {
        color: var(--primary-color);
        text-decoration: none;
        font-weight: 600;
        padding: 2px 6px;
        border-radius: var(--radius-sm);
        transition: all 0.2s ease;
    }

        .terms-disclaimer a:hover {
            background: rgba(29, 132, 181, 0.1);
            text-decoration: underline;
        }

/* Desktop optimizations */
@media (min-width: 1200px) {
    :root {
        --sidebar-width: var(--sidebar-width-desktop);
    }

    .sidebar {
        width: var(--sidebar-width-desktop);
    }

    .main-content {
       
        width: calc(100% - var(--sidebar-width-desktop));
    }

    .chat-input-container {
        left: var(--sidebar-width-desktop);
        width: calc(100% - var(--sidebar-width-desktop));
    }

    .welcome-message,
    .message {
        max-width: 1000px;
    }

    .message-content {
        font-size: 16px;
        line-height: 1.65;
    }

    .chat-header h1 {
        font-size: 20px;
    }

    .chat-messages {
        padding: 40px 48px;
        gap: 32px;
    }

    .message {
        gap: 20px;
    }
}

@media (min-width: 1600px) {
    .welcome-message,
    .message {
        max-width: 1200px;
    }

    .images-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 20px;
    }

    .media-card img,
    .media-card video {
        height: 200px;
    }
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .app-container {
        padding: var(--safe-top) 0 0 0;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: min(85vw, 320px);
        max-width: 320px;
        transform: translateX(-100%);
        z-index: 1000;
        box-shadow: var(--shadow-xl);
        transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        padding-top: var(--safe-top);
    }

        .sidebar.active {
            transform: translateX(0);
        }

            .sidebar.active + .sidebar-overlay {
                display: block;
            }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 99;
        backdrop-filter: blur(4px);
    }

    .menu-toggle-btn {
        display: flex;
    }

    .toggle-sidebar-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .chat-header {
        padding: 12px 16px;
        min-height: 60px;
    }

        .chat-header h1 {
            font-size: 16px;
        }

    .chat-messages {
        padding: 16px 12px;
        padding-bottom: calc(140px + var(--safe-bottom));
        gap: 20px;
    }

    .welcome-message,
    .message {
        max-width: 100%;
        margin: 0;
        gap: 12px;
    }

    .ai-avatar,
    .user-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

        .ai-avatar img {
            width: 24px;
            height: 24px;
        }

    .message-content {
        font-size: 15px;
    }

    .user-message .message-content,
    .ai-message .message-content {
        padding: 12px 16px;
        margin-left: 0;
        border-radius: 16px;
    }

    .suggestion-chips {
        flex-direction: column;
        gap: 12px;
        display: none;
    }

    .suggestion-chip {
        padding: 14px 18px;
        min-height: 48px;
        border-radius: 16px;
    }

    .chat-input-container {
        padding: 12px 16px;
        padding-bottom: max(12px, var(--safe-bottom));
    }

    .chat-input-area {
        padding: 10px 16px;
        border-radius: 20px;
        min-height: 48px;
    }

    .images-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 12px;
    }

    .media-card img,
    .media-card video {
        height: 120px;
    }

    .sources-list {
        gap: 8px;
        flex-direction: column;
    }

    .source-item {
        justify-content: space-between;
        width: 100%;
        padding: 10px 14px;
        font-size: 13px;
        min-height: 44px;
    }
}

/* iPhone specific optimizations */
@media (max-width: 480px) {
    .chat-header {
        padding: 10px 12px;
        min-height: 56px;
    }

        .chat-header h1 {
            font-size: 15px;
        }

    .chat-messages {
        padding: 12px 8px;
    }

    .suggestion-chip {
        font-size: 14px;
        padding: 12px 16px;
    }

    .source-item {
        font-size: 12px;
        padding: 8px 12px;
        min-height: 40px;
    }
}

/* Landscape optimizations */
@media (max-height: 480px) and (orientation: landscape) {
    .chat-messages {
        padding: 8px 12px;
        padding-bottom: calc(100px + var(--safe-bottom));
        gap: 16px;
    }

    .chat-header {
        padding: 8px 16px;
        min-height: 50px;
    }

    .scroll-bottom-btn {
        bottom: calc(90px + var(--safe-bottom));
        width: 40px;
        height: 40px;
    }
}

/* Accessibility enhancements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-contrast: high) {
    :root {
        --primary-color: #003d82;
        --border-light: #666666;
        --text-secondary: #333333;
    }
}

/* Dark mode enhancements */
@media (prefers-color-scheme: dark) {
    :root {
        --surface-primary: #1e293b;
        --surface-secondary: #334155;
        --surface-tertiary: #475569;
        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-tertiary: #94a3b8;
        --border-light: #475569;
    }

    body {
        background: linear-gradient(135deg, var(--dark-bg) 0%, #0f172a 100%);
    }

    .sidebar {
        background: linear-gradient(180deg, var(--surface-primary) 0%, #1a2332 100%);
        border-color: var(--border-light);
    }

    .chat-header {
        background: rgba(30, 41, 59, 0.95);
        border-color: var(--border-light);
    }

    .chat-messages {
        background: linear-gradient(180deg, var(--surface-primary) 0%, var(--surface-secondary) 100%);
    }

    .ai-message .message-content {
        background: var(--surface-secondary);
        border-color: var(--border-light);
    }

    .user-message .message-content {
        background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    }

    .chat-input-container {
        background: rgba(30, 41, 59, 0.95);
        border-color: var(--border-light);
    }

    .chat-input-area {
        background: var(--surface-secondary);
        border-color: var(--border-light);
    }

    .suggestion-chip {
        background: linear-gradient(135deg, var(--surface-secondary), var(--surface-tertiary));
        border-color: var(--border-light);
        color: var(--text-secondary);
    }

    .media-card {
        background: var(--surface-secondary);
        border-color: var(--border-light);
    }

    .source-item {
        background: linear-gradient(135deg, var(--surface-secondary), var(--surface-tertiary));
        border-color: var(--border-light);
        color: var(--text-primary);
    }
}

/* Performance optimizations */
@media (min-width: 1024px) {
    .message,
    .suggestion-chip,
    .media-card,
    .source-item {
        will-change: transform;
        backface-visibility: hidden;
    }

    .chat-messages {
        contain: layout style paint;
    }
}

/* Hide elements */
div#feedback-container {
    display: none !important;
}

div#chat-messages {
    padding-bottom: 9em;
}