@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary-color: #4f46e5;
    --primary-light: rgba(79, 70, 229, 0.1);
    --primary-dark: #4338ca;
    --text-color: #333;
    --text-light: #6b7280;
    --bg-color: #f5f7fb;
    --white: #fff;
    --border-color: #e5e7eb;
    --shadow-sm: 0 2px 5px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --sidebar-width: 280px;
    --header-height: 64px;
    --transition: all 0.3s ease;
}

/* Dark mode variables */
[data-theme="dark"] {
    --primary-color: #6366f1;
    --primary-light: rgba(99, 102, 241, 0.2);
    --primary-dark: #4f46e5;
    --text-color: #e2e8f0;
    --text-light: #94a3b8;
    --bg-color: #111827;
    --white: #1f2937;
    --border-color: #374151;
    --shadow-sm: 0 2px 5px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

button#toggle-debug {
    display: none;
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background-color: var(--white);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 10;
}

/* Mobile overlay for closing sidebar when clicking outside */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 5;
}

.sidebar-overlay.show {
    display: block;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    height: var(--header-height);
}

.sidebar-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.chat-item {
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.chat-item:hover {
    background-color: var(--primary-light);
}

.chat-item.active {
    background-color: var(--primary-light);
}

.chat-item-icon {
    color: var(--primary-color);
    font-size: 18px;
}

.chat-item-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-time {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-right: 24px; /* Make room for delete button */
}

.chat-item-delete {
    position: absolute;
    right: 12px;
    color: var(--text-light);
    font-size: 14px;
    opacity: 0;
    transition: var(--transition);
}

.chat-item:hover .chat-item-delete {
    opacity: 1;
}

.chat-item-delete:hover {
    color: #ff4d4f;
}

#new-chat {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

#new-chat:hover {
    background-color: var(--primary-dark);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--white);
    border-radius: 0;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.chat-header {
    padding: 0 20px;
    height: var(--header-height);
    min-height: var(--header-height);
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.chat-header h1 {
    margin: 0;
    font-size: 1.25rem;
}

/* Header buttons container */
.header-buttons {
    display: flex;
    gap: 8px;
}

#toggle-debug, 
#clear-history,
#toggle-sidebar {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition);
}

#toggle-debug:hover, 
#clear-history:hover,
#toggle-sidebar:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.chat-input-container {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background-color: var(--white);
}

.input-area {
    display: flex;
    gap: 10px;
    align-items: center;
}

#user-input {
    flex-grow: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    outline: none;
    font-size: 1rem;
    background-color: var(--white);
    color: var(--text-color);
    transition: var(--transition);
}

#user-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.image-upload {
    position: relative;
}

.image-upload label {
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    background-color: var(--white);
    color: var(--text-light);
    display: flex;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    transition: var(--transition);
}

.image-upload label:hover {
    background-color: var(--border-color);
    color: var(--primary-color);
}

#image-input {
    display: none;
}

form button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition);
}

form button:hover {
    background-color: var(--primary-dark);
}

.message {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    word-wrap: break-word;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.user-message {
    align-self: flex-end;
    background-color: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message {
    align-self: flex-start;
    background-color: var(--primary-light);
    color: var(--text-color);
    border-bottom-left-radius: 4px;
}

[data-theme="dark"] .ai-message {
    background-color: rgba(99, 102, 241, 0.15);
}

.message-content {
    display: flex;
    flex-direction: column;
}

.message-text {
    white-space: pre-wrap;
    line-height: 1.5;
}

.message-image {
    max-width: 300px;
    max-height: 300px;
    width: auto;
    height: auto;
    border-radius: var(--radius-sm);
    margin-top: 8px;
    cursor: pointer;
    transition: transform 0.3s ease;
    object-fit: contain;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.message-image:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.hidden {
    display: none !important;
}

.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(79, 70, 229, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
}

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

.image-preview {
    margin-top: 10px;
    position: relative;
    display: inline-block;
}

.image-preview img {
    max-height: 100px;
    max-width: 200px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--white);
}

#remove-image {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4d4f;
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    padding: 0;
}

/* Debug Panel Styles */
.debug-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    max-height: 300px;
    background-color: rgba(0, 0, 0, 0.8);
    color: #10ff10;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    font-family: monospace;
    font-size: 12px;
    z-index: 1000;
    display: none;
    overflow: hidden;
}

.debug-panel.show {
    display: flex;
    flex-direction: column;
}

.debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background-color: rgba(0, 0, 0, 0.9);
    border-bottom: 1px solid #333;
}

.debug-header h3 {
    margin: 0;
    font-size: 14px;
    color: #fff;
}

.debug-content {
    padding: 10px;
    overflow-y: auto;
    max-height: 260px;
    line-height: 1.4;
}

.debug-message {
    margin-bottom: 8px;
    border-bottom: 1px solid #333;
    padding-bottom: 8px;
    word-wrap: break-word;
}

.debug-message.error {
    color: #ff5252;
}

.debug-message.warning {
    color: #ffbd2e;
}

.debug-message.info {
    color: #1e90ff;
}

.debug-message.success {
    color: #10ff10;
}

#clear-debug {
    background: transparent;
    color: #ccc;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 3px 6px;
    border-radius: 4px;
}

#clear-debug:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
}

.mobile-only {
    display: none;
}

/* Desktop specific styles */
@media (min-width: 769px) {
    .sidebar {
        position: relative;
    }
    
    .sidebar.hidden {
        width: 0;
        min-width: 0;
        overflow: hidden;
    }
    
    .main-content {
        transition: var(--transition);
    }
    
    .sidebar.hidden + .main-content {
        margin-left: 0;
    }
}

/* Mobile specific styles */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100%;
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .mobile-only {
        display: flex;
    }
    
    .chat-container {
        border-radius: 0;
        display: flex;
        flex-direction: column;
        height: 100vh;
    }
    
    .chat-header {
        position: sticky;
        top: 0;
        z-index: 20;
    }
    
    .chat-messages {
        flex: 1;
        overflow-y: auto;
    }
    
    .chat-input-container {
        position: sticky;
        bottom: 0;
        z-index: 20;
        background-color: var(--white);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    }
    
    .message {
        max-width: 90%;
    }
    
    .debug-panel {
        width: 90%;
        right: 5%;
    }
}

@media (max-width: 480px) {
    .chat-header h1 {
        font-size: 1.1rem;
    }
    
    #user-input {
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .chat-messages {
        padding: 16px 10px;
    }
    
    .message {
        max-width: 95%;
        padding: 12px 14px;
    }
    
    .header-buttons {
        gap: 4px;
    }
    
    #toggle-debug, 
    #clear-history,
    #toggle-sidebar {
        width: 32px;
        height: 32px;
    }
    
    .chat-input-container {
        padding: 8px 10px;
    }
    
    .input-area {
        gap: 6px;
    }
    
    form button,
    .image-upload label {
        width: 36px;
        height: 36px;
        padding: 8px;
    }
    
    .message-image {
        max-width: 250px;
        max-height: 250px;
        width: auto;
        height: auto;
    }
    
    .modal-content {
        padding: 15px;
        margin: 10px;
    }
    
    #modal-image {
        max-height: 60vh;
    }
    
    .close-modal {
        top: 5px;
        right: 10px;
        font-size: 24px;
    }
}

/* Add typing indicator styles */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 10px 16px;
}

.typing-indicator span {
    height: 8px;
    width: 8px;
    float: left;
    margin: 0 1px;
    background-color: #9e9ea1;
    display: block;
    border-radius: 50%;
    opacity: 0.4;
}

.typing-indicator span:nth-of-type(1) {
    animation: 1s blink infinite 0.3333s;
}

.typing-indicator span:nth-of-type(2) {
    animation: 1s blink infinite 0.6666s;
}

.typing-indicator span:nth-of-type(3) {
    animation: 1s blink infinite 0.9999s;
}

@keyframes blink {
    50% {
        opacity: 1;
    }
}

/* Image Modal Styles */
.image-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    overflow: auto;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
}

.modal-content {
    position: relative;
    background-color: var(--white);
    color: var(--text-color);
    margin: 20px;
    padding: 20px;
    border-radius: 12px;
    max-width: 90%;
    max-height: 90%;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    animation: modal-zoom 0.3s;
    display: flex;
    flex-direction: column;
}

@keyframes modal-zoom {
    from {transform: scale(0.8); opacity: 0;}
    to {transform: scale(1); opacity: 1;}
}

.close-modal {
    position: absolute;
    top: 6px;
    right: 6px;
    color: white;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    z-index: 20;
    transition: background-color 0.3s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.close-modal:hover {
    background-color: var(--primary-color);
}

#modal-image {
    max-width: 100%;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    margin-bottom: 0;
    border-radius: 8px;
}

.modal-actions {
    display: none;
}

#download-image {
    position: absolute;
    bottom: 30px;
    right: 30px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 20;
}

#download-image i {
    font-size: 18px;
}

#download-image:hover {
    background-color: var(--primary-color);
    transform: translateY(-2px);
}

/* Theme toggle button */
.theme-toggle {
    background: transparent;
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    border-radius: 50%;
}

.theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Dark mode specific overrides */
[data-theme="dark"] .chat-messages {
    background-color: var(--bg-color);
}

[data-theme="dark"] .image-upload label {
    background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] #remove-image {
    background: #ff4d4f;
    color: white;
} 