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

/* Theme Variables */
:root {
    /* Light Theme */
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f8f9fa;
    --bg-quaternary: #e8f0fe;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --text-tertiary: #3c4043;
    --border-primary: #e8eaed;
    --border-secondary: #dadce0;
    --accent-primary: #4285f4;
    --accent-hover: #3367d6;
    --message-user-bg: #4285f4;
    --message-assistant-bg: #f8f9fa;
    --suggestion-card-bg: #f8f9fa;
    --suggestion-card-hover: #e8f0fe;
    --input-bg: #f8f9fa;
    --scrollbar-thumb: #dadce0;
    --scrollbar-thumb-hover: #bdc1c6;
}

[data-theme="dark"] {
    /* Dark Theme */
    --bg-primary: #202124;
    --bg-secondary: #2d2e30;
    --bg-tertiary: #3c4043;
    --bg-quaternary: #1a73e8;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-tertiary: #bdc1c6;
    --border-primary: #3c4043;
    --border-secondary: #5f6368;
    --accent-primary: #4285f4;
    --accent-hover: #5094ed;
    --message-user-bg: #4285f4;
    --message-assistant-bg: #3c4043;
    --suggestion-card-bg: #3c4043;
    --suggestion-card-hover: #4285f4;
    --input-bg: #3c4043;
    --scrollbar-thumb: #5f6368;
    --scrollbar-thumb-hover: #9aa0a6;
}

body {
    font-family: 'Poppins', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
    z-index: 1000;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-primary);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.logo .material-icons {
    font-size: 32px;
    background: linear-gradient(45deg, #4285f4, #34a853, #fbbc04, #ea4335);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo h1 {
    font-size: 24px;
    font-weight: 500;
    color: var(--text-primary);
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: var(--text-tertiary);
}

.new-chat-btn:hover {
    background: var(--bg-quaternary);
    border-color: var(--accent-primary);
}

.new-chat-btn .material-icons {
    font-size: 20px;
}

/* Chat History */
.chat-history {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.history-section h3 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.history-item {
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-bottom: 4px;
    font-size: 14px;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.history-item:hover {
    background: var(--bg-tertiary);
}

.history-item .material-icons {
    font-size: 18px;
    color: var(--text-secondary);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-primary);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.user-profile:hover {
    background: var(--bg-tertiary);
}

.avatar .material-icons {
    font-size: 32px;
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-secondary);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.menu-toggle:hover {
    background: var(--bg-tertiary);
}

.menu-toggle .material-icons {
    font-size: 24px;
    color: var(--text-secondary);
}

.header-title h2 {
    font-size: 22px;
    font-weight: 400;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.action-btn:hover {
    background: var(--bg-tertiary);
}

.action-btn .material-icons {
    font-size: 20px;
    color: var(--text-secondary);
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px 20px;
}

.welcome-content {
    text-align: center;
    max-width: 600px;
}

.tushar-ai-logo {
    margin-bottom: 24px;
}

.tushar-ai-logo .material-icons {
    font-size: 64px;
    background: linear-gradient(45deg, #4285f4, #34a853, #fbbc04, #ea4335);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-content h1 {
    font-size: 48px;
    font-weight: 400;
    margin-bottom: 16px;
    background: linear-gradient(45deg, #4285f4, #34a853, #fbbc04, #ea4335);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-content p {
    font-size: 20px;
    color: #5f6368;
    margin-bottom: 40px;
}

/* Suggestion Cards */
.suggestion-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-top: 32px;
}

.suggestion-card {
    background: var(--suggestion-card-bg);
    border: 1px solid var(--border-primary);
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.suggestion-card:hover {
    background: var(--suggestion-card-hover);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.15);
}

.suggestion-card .material-icons {
    font-size: 24px;
    color: var(--accent-primary);
    margin-bottom: 12px;
}

.suggestion-card p {
    font-size: 14px;
    color: var(--text-tertiary);
    margin: 0;
}

/* Messages Container */
.messages-container {
    flex: 1;
    padding: 20px 0;
    display: none;
}

.message {
    margin-bottom: 24px;
    display: flex;
    gap: 16px;
    max-width: 90vw;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: #4285f4;
    color: white;
}

.message.assistant .message-avatar {
    background: linear-gradient(45deg, #4285f4, #34a853, #fbbc04, #ea4335);
    color: white;
}

.message-content {
    flex: 1;
    max-width: calc(100% - 48px);
}

.message.user .message-content {
    text-align: right;
}

.message-bubble {
    background: var(--message-assistant-bg);
    border-radius: 18px;
    padding: 12px 16px;
    display: inline-block;
    max-width: 100%;
    word-wrap: break-word;
}

.message.user .message-bubble {
    background: var(--message-user-bg);
    color: white;
}

.message-text {
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--message-assistant-bg);
    border-radius: 18px;
    margin-bottom: 24px;
}

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

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

/* Input Section */
.input-section {
    padding: 24px;
    border-top: 1px solid var(--border-primary);
    background: var(--bg-secondary);
}

.input-container {
    max-width: 800px;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    background: var(--input-bg);
    border: 1px solid var(--border-primary);
    border-radius: 24px;
    padding: 12px 16px;
    transition: all 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.1);
}

#messageInput {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    resize: none;
    font-size: 16px;
    line-height: 1.5;
    max-height: 120px;
    min-height: 24px;
    font-family: inherit;
    color: var(--text-primary);
}

#messageInput::placeholder {
    color: var(--text-secondary);
}

.input-actions {
    display: flex;
    gap: 8px;
    margin-left: 12px;
}

.attach-btn, .image-btn, .send-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attach-btn:hover, .image-btn:hover {
    background: var(--bg-tertiary);
}

.image-btn .material-icons {
    font-size: 20px;
    color: var(--text-secondary);
}

.send-btn {
    background: #4285f4;
    color: white;
}

.send-btn:hover:not(:disabled) {
    background: #3367d6;
}

.send-btn:disabled {
    background: var(--border-primary);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.send-btn .material-icons,
.attach-btn .material-icons,
.image-btn .material-icons {
    font-size: 20px;
}

/* Image Preview Styles */
.image-preview {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    border: 1px solid var(--border-primary);
}

.preview-container {
    position: relative;
    display: inline-block;
    max-width: 200px;
}

.preview-container img {
    width: 100%;
    height: auto;
    max-height: 150px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

.remove-image {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ea4335;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.remove-image:hover {
    background: #d33b2c;
    transform: scale(1.1);
}

.remove-image .material-icons {
    font-size: 16px;
}

/* Message with image styles */
.message-image {
    margin-top: 8px;
    max-width: 300px;
}

.message-image img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.message-image img:hover {
    transform: scale(1.02);
}

.input-footer {
    text-align: center;
    margin-top: 12px;
}

.input-footer p {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(var(--bg-primary), 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

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

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-primary);
    border-top: 4px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

.loading-spinner p {
    font-size: 16px;
    color: var(--text-secondary);
}

/* Responsive Design */
/* Tablet and small desktop */
@media (max-width: 1024px) {
    .sidebar {
        width: 260px;
    }
    
    .welcome-content h1 {
        font-size: 42px;
    }
    
    .suggestion-cards {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 14px;
    }
}

/* Mobile landscape and tablet portrait */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        width: 280px;
        transform: translateX(-100%);
        z-index: 1001;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .menu-toggle {
        display: block;
    }

    .header {
        padding: 12px 16px;
    }

    .header-title h2 {
        font-size: 18px;
    }

    .welcome-content h1 {
        font-size: 32px;
    }

    .welcome-content p {
        font-size: 16px;
        margin-bottom: 32px;
    }

    .suggestion-cards {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-top: 24px;
    }

    .chat-container {
        padding: 0 16px;
    }

    .input-section {
        padding: 16px;
    }

    .input-wrapper {
        padding: 8px 12px;
    }

    #messageInput {
        font-size: 16px;
    }

    .message {
        margin-bottom: 20px;
        gap: 12px;
    }

    .message-avatar {
        width: 28px;
        height: 28px;
    }

    .message-content {
        max-width: calc(100% - 40px);
    }

    .message-bubble {
        padding: 10px 14px;
    }

    .message-text {
        font-size: 14px;
    }
}

/* Mobile portrait */
@media (max-width: 480px) {
    .app-container {
        height: 100vh;
        height: 100dvh;
    }

    .header {
        padding: 10px 12px;
    }

    .header-title h2 {
        font-size: 16px;
    }

    .action-btn {
        padding: 6px;
    }

    .action-btn .material-icons {
        font-size: 18px;
    }

    .welcome-content {
        padding: 20px 10px;
    }

    .welcome-content h1 {
        font-size: 28px;
        margin-bottom: 12px;
    }

    .welcome-content p {
        font-size: 14px;
        margin-bottom: 24px;
    }

    .tushar-ai-logo .material-icons {
        font-size: 48px;
    }

    .suggestion-card {
        padding: 16px;
        border-radius: 12px;
    }

    .suggestion-card .material-icons {
        font-size: 20px;
        margin-bottom: 8px;
    }

    .suggestion-card p {
        font-size: 13px;
    }

    .message {
        margin-bottom: 16px;
        gap: 10px;
    }

    .message-avatar {
        width: 24px;
        height: 24px;
    }

    .message-avatar .material-icons {
        font-size: 16px;
    }

    .message-content {
        max-width: calc(100% - 34px);
    }

    .message-bubble {
        padding: 8px 12px;
        border-radius: 14px;
    }

    .message-text {
        font-size: 13px;
        line-height: 1.4;
    }

    .input-section {
        padding: 12px;
    }

    .input-wrapper {
        padding: 6px 10px;
        border-radius: 20px;
    }

    #messageInput {
        font-size: 14px;
        min-height: 20px;
    }

    .input-actions {
        gap: 6px;
        margin-left: 8px;
    }

    .attach-btn, .image-btn, .send-btn {
        padding: 6px;
    }

    .attach-btn .material-icons,
    .image-btn .material-icons,
    .send-btn .material-icons {
        font-size: 18px;
    }

    .image-preview {
        margin-top: 8px;
        padding: 8px;
    }

    .preview-container {
        max-width: 150px;
    }

    .preview-container img {
        max-height: 100px;
    }

    .message-image {
        max-width: 250px;
    }

    .input-footer {
        margin-top: 8px;
    }

    .input-footer p {
        font-size: 11px;
    }

    .sidebar {
        width: 260px;
    }

    .sidebar-header {
        padding: 16px;
    }

    .logo h1 {
        font-size: 20px;
    }

    .logo .material-icons {
        font-size: 28px;
    }

    .new-chat-btn {
        padding: 10px 14px;
        font-size: 13px;
        border-radius: 20px;
    }

    .chat-history {
        padding: 16px;
    }

    .history-item {
        padding: 10px 12px;
        font-size: 13px;
    }

    .sidebar-footer {
        padding: 16px;
    }
}

/* Very small screens */
@media (max-width: 360px) {
    .welcome-content h1 {
        font-size: 24px;
    }

    .suggestion-card {
        padding: 12px;
    }

    .input-section {
        padding: 8px;
    }

    .sidebar {
        width: 240px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background: #202124;
        color: #e8eaed;
    }

    .sidebar {
        background: #2d2e30;
        border-right-color: #3c4043;
    }

    .main-content {
        background: #202124;
    }

    .header {
        background: #2d2e30;
        border-bottom-color: #3c4043;
    }

    .new-chat-btn {
        background: #3c4043;
        border-color: #5f6368;
        color: #e8eaed;
    }

    .new-chat-btn:hover {
        background: #4285f4;
        border-color: #4285f4;
    }

    .input-wrapper {
        background: #3c4043;
        border-color: #5f6368;
    }

    .input-wrapper:focus-within {
        border-color: #4285f4;
    }

    #messageInput {
        color: #e8eaed;
    }

    .message-bubble {
        background: #3c4043;
        color: #e8eaed;
    }

    .message.user .message-bubble {
        background: #4285f4;
        color: white;
    }

    .suggestion-card {
        background: #3c4043;
        border-color: #5f6368;
        color: #e8eaed;
    }

    .suggestion-card:hover {
        background: #4285f4;
        border-color: #4285f4;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* Smooth transitions */
* {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

