/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Modern color palette */
    --primary-color: #4299e1;
    --primary-hover: #3182ce;
    --primary-light: #ebf8ff;
    --secondary-color: #667eea;
    --accent-color: #ff6b6b;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --bg-tertiary: #edf2f7;
    --border-color: #e2e8f0;
    --border-light: #f0f4f8;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-overflow-scrolling: touch;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* App Container - Mobile First */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    background: var(--bg-primary);
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    height: 100dvh;
    position: relative;
}

/* Tablet styles (768px - 1024px) */
@media (min-width: 768px) {
    .app-container {
        width: 100%;
        max-width: none;
        height: 100vh;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }
}

/* Desktop styles (1024px+) */
@media (min-width: 1024px) {
    body {
        background: var(--bg-primary);
    }

    .app-container {
        width: 100%;
        max-width: none;
        height: 100vh;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        border: none;
    }
}

/* Large Desktop (1440px+) */
@media (min-width: 1440px) {
    .app-container {
        max-width: none;
        width: 100%;
        height: 100vh;
    }
}

/* Header */
.app-header {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    box-shadow: none;
    position: relative;
    z-index: 100;
}

/* Tablet header */
@media (min-width: 768px) {
    .app-header {
        padding: 1.25rem 1.5rem;
    }
}

/* Desktop header */
@media (min-width: 1024px) {
    .app-header {
        padding: 1rem 2rem;
        border-bottom: 2px solid var(--border-light);
    }
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

/* Desktop header content */
@media (min-width: 1024px) {
    .header-content {
        gap: 1.5rem;
        flex-wrap: nowrap;
    }

    .logo-section {
        gap: 1.25rem;
    }
}

.logo-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
    transition: transform 0.3s ease;
}

.logo-icon:hover {
    transform: scale(1.05);
}

.header-logo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

/* Desktop logo styles */
@media (min-width: 1024px) {
    .logo-icon {
        width: 48px;
        height: 48px;
    }

    .header-logo {
        border-radius: 10px;
    }
}

.logo-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.125rem;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logo-text p {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Desktop logo text */
@media (min-width: 1024px) {
    .logo-text h1 {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
    }

    .logo-text p {
        font-size: 0.875rem;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
    }
}

/* Clear Chat Button - Fixed styling */
.header-actions .btn-secondary {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-sm);
}

.header-actions .btn-secondary:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

@media (min-width: 1024px) {
    .header-actions .btn-secondary {
        padding: 0.625rem 1.25rem;
        font-size: 0.9375rem;
        border-radius: 12px;
    }
}

/* Main Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--bg-primary);
    min-height: 0;
    overflow: hidden;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
    background: var(--bg-primary);
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) var(--bg-primary);
    min-height: 0;
    max-height: calc(100vh - 200px);
    -webkit-overflow-scrolling: touch;
}

/* Tablet chat messages */
@media (min-width: 768px) {
    .chat-messages {
        padding: 1.5rem;
        gap: 1.25rem;
    }
}

/* Desktop chat messages */
@media (min-width: 1024px) {
    .chat-messages {
        padding: 1.5rem 2.5rem;
        gap: 1.25rem;
        max-height: calc(92vh - 200px);
    }
}

/* Custom scrollbar for webkit browsers */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
    transition: background 0.3s ease;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Message Styles */
.message {
    display: flex;
    gap: 0.75rem;
    max-width: 85%;
    animation: slideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Tablet message styles */
@media (min-width: 768px) {
    .message {
        gap: 1rem;
        max-width: 75%;
    }
}

/* Desktop message styles */
@media (min-width: 1024px) {
    .message {
        gap: 1.25rem;
        max-width: 65%;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

.message.assistant {
    align-self: flex-start;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s ease;
}

.message-avatar:hover {
    transform: scale(1.1);
}

/* Desktop message avatar */
@media (min-width: 1024px) {
    .message-avatar {
        width: 40px;
        height: 40px;
        font-size: 1.125rem;
    }
}

.message.user .message-avatar {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.message.assistant .message-avatar {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    color: white;
}

.avatar-logo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.message-content {
    background: var(--bg-primary);
    padding: 0.875rem 1rem;
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    position: relative;
    line-height: 1.6;
    border: 1px solid var(--border-light);
    font-size: 0.9375rem;
    transition: all 0.3s ease;
}

.message-content:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* Desktop message content */
@media (min-width: 1024px) {
    .message-content {
        padding: 0.875rem 1.25rem;
        border-radius: 20px;
        font-size: 0.9375rem;
        line-height: 1.6;
    }
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    border: 1px solid var(--primary-hover);
}

.message.assistant .message-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
}

/* Message content typography */
.message-content h3 {
    color: var(--accent-color);
    margin-bottom: 0.75rem;
    font-size: 1.125rem;
    font-weight: 600;
}

.message-content ul {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
    list-style-type: disc;
}

.message-content li {
    margin-bottom: 0.375rem;
    line-height: 1.6;
}

.message-content a {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px dotted var(--secondary-color);
    transition: all 0.2s ease;
}

.message-content a:hover {
    color: var(--primary-color);
    border-bottom-style: solid;
}

.message.user .message-content a {
    color: rgba(255, 255, 255, 0.95);
    border-bottom-color: rgba(255, 255, 255, 0.5);
}

.message.user .message-content a:hover {
    color: white;
    border-bottom-color: white;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 2rem;
    color: var(--text-muted);
    font-style: italic;
    background: var(--bg-primary);
    margin: 0 1rem;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

@media (min-width: 1024px) {
    .typing-indicator {
        margin: 0 3rem;
        padding: 1.25rem 2rem;
        border-radius: 16px;
    }
}

.typing-dots {
    display: flex;
    gap: 4px;
}

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

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

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Input Container */
.chat-input-container {
    background: var(--bg-primary);
    border-top: 2px solid var(--border-light);
    padding: 1rem;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
}

/* Desktop input container */
@media (min-width: 1024px) {
    .chat-input-container {
        padding: 1.25rem 2.5rem;
    }
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 14px;
    padding: 0.75rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Desktop input wrapper */
@media (min-width: 1024px) {
    .input-wrapper {
        gap: 1rem;
        border-radius: 16px;
        padding: 1rem 1.25rem;
    }
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(66, 153, 225, 0.15);
    background: var(--bg-primary);
}

#message-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-family: inherit;
    font-size: 0.9375rem;
    line-height: 1.5;
    max-height: 100px;
    min-height: 20px;
    color: var(--text-primary);
}

#message-input::placeholder {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

/* Desktop input field */
@media (min-width: 1024px) {
    #message-input {
        font-size: 0.9375rem;
        max-height: 150px;
        min-height: 24px;
    }

    #message-input::placeholder {
        font-size: 0.875rem;
    }
}

.send-button {
    width: 38px;
    height: 38px;
    border: none;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    font-size: 1rem;
    box-shadow: var(--shadow-sm);
}

/* Desktop send button */
@media (min-width: 1024px) {
    .send-button {
        width: 44px;
        height: 44px;
        border-radius: 12px;
        font-size: 1.125rem;
    }
}

.send-button:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--secondary-color) 100%);
    transform: translateY(-2px) scale(1.05);
    box-shadow: var(--shadow-lg);
}

.send-button:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

.send-button:disabled {
    background: var(--border-color);
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    gap: 1rem;
}

.footer-left {
    display: flex;
    align-items: center;
}

.privacy-link {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
    font-weight: 500;
}

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

.character-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

@media (min-width: 1024px) {
    .character-count {
        font-size: 0.8125rem;
    }

    .privacy-link {
        font-size: 0.8125rem;
    }
}

/* Quick Actions */
.quick-actions {
    display: none;
    gap: 0.5rem;
}

@media (min-width: 768px) {
    .quick-actions {
        display: flex;
    }
}

.quick-action {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.375rem 0.875rem;
    border-radius: 20px;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.quick-action:hover {
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
    margin: 0 auto 1.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner p {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 1.125rem;
}

/* Error Toast */
.error-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, var(--accent-color) 0%, #dc3545 100%);
    color: white;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    z-index: 10000;
    max-width: 400px;
    animation: slideInRight 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideInRight {
    from {
        transform: translateX(110%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toast-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.5rem;
    margin-left: auto;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.toast-close:hover {
    transform: rotate(90deg);
}

/* Additional mobile-specific optimizations */
@media (max-width: 767px) {
    /* Ensure proper touch targets */
    .send-button {
        min-width: 44px;
        min-height: 44px;
    }

    /* Better mobile typography */
    .message-content {
        font-size: 0.9375rem;
    }

    .message-content h3 {
        font-size: 1.0625rem;
    }

    .message-content ul li {
        margin-bottom: 0.5rem;
    }

    /* Improve link touch targets */
    .message-content a {
        padding: 0.25rem 0;
        display: inline-block;
        min-height: 44px;
        line-height: 1.4;
    }

    /* Prevent zoom on input focus */
    #message-input {
        font-size: 16px;
    }

    /* Better loading indicator on mobile */
    .typing-indicator {
        padding: 0.75rem 1rem;
        margin: 0 0.5rem;
    }

    /* Mobile input footer */
    .input-footer {
        margin-top: 0.5rem;
    }

    /* Compact header on small screens */
    .logo-text h1 {
        font-size: 1.125rem;
    }

    .logo-text p {
        font-size: 0.75rem;
    }
}

/* Print styles */
@media print {
    body {
        background: white;
    }

    .app-container {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .header-actions,
    .chat-input-container,
    .typing-indicator,
    .loading-overlay,
    .error-toast {
        display: none;
    }

    .chat-messages {
        max-height: none;
        overflow: visible;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Dark mode support (if you want to add it in the future) */
@media (prefers-color-scheme: dark) {
    /* Dark mode variables would go here */
}

/* Non-suite apps recommendation styling */
.non-suite-apps-recommendation {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-left: 4px solid var(--primary-color);
    padding: 1rem;
    margin: 0.5rem 0;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.non-suite-apps-recommendation strong {
    color: var(--primary-color);
    font-size: 1rem;
    display: block;
    margin-bottom: 0.5rem;
}

.non-suite-apps-recommendation ul {
    margin: 0.75rem 0 0 0;
    padding-left: 1.25rem;
}

.non-suite-apps-recommendation li {
    margin: 0.5rem 0;
    line-height: 1.6;
}

.non-suite-apps-recommendation a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
    border-bottom: 1px solid transparent;
}

.non-suite-apps-recommendation a:hover {
    color: var(--primary-hover);
    border-bottom-color: var(--primary-hover);
}

/* Mobile adjustments */
@media (max-width: 767px) {
    .non-suite-apps-recommendation {
        padding: 0.875rem;
        margin: 0.375rem 0;
    }
    
    .non-suite-apps-recommendation strong {
        font-size: 0.9375rem;
    }
}
