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

:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --bg-hover: #2d2d2d;
    --text-primary: #ffffff;
    --text-secondary: #9ca3af;
    --accent: #10a37f;
    --accent-hover: #0d8f6e;
    --accent-light: rgba(16, 163, 127, 0.1);
    --border-color: #2d2d2d;
    --border-light: #1a1a1a;
    --sidebar-width: 260px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.7);
    --gradient-primary: linear-gradient(135deg, #10a37f 0%, #0d8f6e 100%);
}

* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: pan-y;
}

/* Language Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(4px);
}

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

.modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 32px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.modal-content h2 {
    margin-bottom: 24px;
    font-size: 24px;
    text-align: center;
    color: var(--text-primary);
}

.language-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.language-option {
    padding: 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    font-size: 14px;
    color: var(--text-primary);
}

.language-option:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    transform: translateY(-2px);
}

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

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

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 12px;
}

.site-logo-text {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 20px;
}

.site-name {
    font-size: 22px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.new-chat-btn {
    width: 100%;
    padding: 12px 16px;
    background: var(--accent);
    border: none;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.new-chat-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

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

.chat-item {
    padding: 12px 14px;
    margin: 4px 0;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    font-size: 14px;
    color: var(--text-secondary);
    border: 1px solid transparent;
    position: relative;
}

.chat-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.chat-item.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 500;
}

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

.chat-delete-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    opacity: 0;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
}

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

.chat-delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-profile-section {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    margin-bottom: 8px;
}

.user-profile-section:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.user-profile-section.login-section {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

.user-profile-section.login-section:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.user-avatar-initial {
    width: 100%;
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
}

.user-profile-section.login-section .user-avatar-initial.login-avatar {
    background: var(--gradient-primary);
    color: white;
}

.user-avatar-small-initial {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 12px;
}

.dropdown-arrow {
    margin-left: auto;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.user-profile-section.active .dropdown-arrow {
    transform: rotate(180deg);
}

.user-dropdown {
    margin-top: 0;
    margin-bottom: 12px;
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
    animation: slideDown 0.2s ease;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
}

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

.dropdown-item.logout-item {
    color: #ef4444;
}

.dropdown-item.logout-item:hover {
    background: rgba(239, 68, 68, 0.1);
}

.dropdown-item svg {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.dropdown-item.logout-item svg {
    color: #ef4444;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-info-text {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-handle {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
    animation: slideDown 0.2s ease;
}

.sidebar-menu-item {
    padding: 12px 14px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    transition: all 0.2s ease;
    width: 100%;
    font-weight: 500;
    text-decoration: none;
    position: relative;
}

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

.sidebar-menu-item.upgrade-plan {
    background: rgba(16, 163, 127, 0.15);
    border: 1px solid rgba(16, 163, 127, 0.3);
}

.sidebar-menu-item.upgrade-plan:hover {
    background: rgba(16, 163, 127, 0.2);
    border-color: var(--accent);
}

.sidebar-menu-item svg {
    flex-shrink: 0;
    color: var(--text-secondary);
    width: 20px;
    height: 20px;
}

.sidebar-menu-item.upgrade-plan svg {
    color: var(--accent);
}

.sidebar-menu-item .chevron {
    margin-left: auto;
    opacity: 0.5;
    width: 16px;
    height: 16px;
}

.sidebar-menu-item.logout-item {
    color: #ef4444;
}

.sidebar-menu-item.logout-item svg {
    color: #ef4444;
}

.sidebar-menu-item.logout-item:hover {
    background: rgba(239, 68, 68, 0.1);
}

.account-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-top: auto;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.account-status:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.account-status.active {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.account-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-bottom: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideUp 0.2s ease;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
}

.dropdown-item:last-child {
    border-bottom: none;
}

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

.dropdown-item.upgrade-plan {
    background: rgba(16, 163, 127, 0.15);
    border-bottom: 1px solid rgba(16, 163, 127, 0.3);
}

.dropdown-item.upgrade-plan:hover {
    background: rgba(16, 163, 127, 0.2);
}

.dropdown-item.logout-item {
    color: #ef4444;
}

.dropdown-item.logout-item:hover {
    background: rgba(239, 68, 68, 0.1);
}

.dropdown-item svg {
    flex-shrink: 0;
    color: var(--text-secondary);
    width: 20px;
    height: 20px;
}

.dropdown-item.upgrade-plan svg {
    color: var(--accent);
}

.dropdown-item.logout-item svg {
    color: #ef4444;
}

.dropdown-item .chevron {
    margin-left: auto;
    opacity: 0.5;
    width: 16px;
    height: 16px;
}

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

.user-avatar-small {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.account-info {
    flex: 1;
    min-width: 0;
}

.account-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.account-type {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
    letter-spacing: 0.5px;
}

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

.chat-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.welcome-content {
    max-width: 700px;
    width: 100%;
    text-align: center;
}

.welcome-logo-container {
    margin-bottom: 24px;
    display: flex;
    justify-content: center;
}

.welcome-logo-text {
    width: 100px;
    height: 100px;
    border-radius: 20px;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 48px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.welcome-content h1 {
    font-size: 42px;
    margin-bottom: 16px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.suggestions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 32px;
}

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

.suggestion-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.suggestion-card h3 {
    font-size: 15px;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 600;
}

.suggestion-card p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.messages-container {
    padding: 24px;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}

.message {
    display: flex;
    gap: 20px;
    padding: 20px 0;
    animation: fadeIn 0.3s ease;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 700;
    font-size: 14px;
}

.message.user .message-avatar {
    background: var(--accent);
    color: white;
}

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

.message-content {
    flex: 1;
    line-height: 1.7;
    word-wrap: break-word;
    font-size: 15px;
    color: var(--text-primary);
}

.message-content pre {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: 10px;
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid var(--border-color);
    font-size: 14px;
}

.message-content code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
}

.message-content pre code {
    background: transparent;
    padding: 0;
}

.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.message:hover .message-actions {
    opacity: 1;
}

.action-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.action-btn:hover {
    background: var(--bg-hover);
    color: var(--accent);
    border-color: var(--accent);
}

/* File Preview */
.file-preview {
    max-width: 800px;
    margin: 0 auto 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.file-preview-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.file-preview-name {
    flex: 1;
    color: var(--text-primary);
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-preview-remove {
    background: rgba(239, 68, 68, 0.1);
    border: none;
    color: #ef4444;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.file-preview-remove:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Message Files */
.message-file {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.message-file-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    margin-top: 8px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

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

.message-file-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.message-file-link:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

.message-file-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-light);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-file-info {
    flex: 1;
    min-width: 0;
}

.message-file-name {
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-file-size {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Input Container */
.input-container {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 12px 16px;
    transition: all 0.2s ease;
}

.attach-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.attach-btn:hover {
    background: var(--bg-tertiary);
    color: var(--accent);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

#messageInput {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    resize: none;
    max-height: 200px;
    font-family: inherit;
    outline: none;
    line-height: 1.6;
}

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

.send-btn {
    background: var(--accent);
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

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

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

/* Loading Animation */
.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 12px 0;
    align-items: center;
}

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

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

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

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

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

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

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

/* Selection */
::selection {
    background-color: var(--accent);
    color: white;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1001;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
}

.mobile-menu-toggle:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* Responsive Design */

/* Large Tablets and Small Desktops */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
    
    .messages-container {
        padding: 20px;
    }
    
    .welcome-content h1 {
        font-size: 36px;
    }
}

/* Tablets */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 260px;
    }
    
    .mobile-menu-toggle {
        display: flex !important;
    }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
    }

    [dir="rtl"] .sidebar {
        left: auto;
        right: 0;
        transform: translateX(100%);
    }

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

    .main-content {
        width: 100%;
        padding-top: 0;
    }
    
    .suggestions-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .welcome-content {
        padding: 20px;
    }
    
    .welcome-content h1 {
        font-size: 32px;
        margin-bottom: 12px;
    }
    
    .welcome-logo {
        width: 80px;
        height: 80px;
    }

    .messages-container {
        padding: 16px;
    }
    
    .message {
        padding: 16px 0;
        gap: 12px;
    }
    
    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    
    .message-content {
        font-size: 14px;
    }

    .input-container {
        padding: 12px;
    }
    
    .input-wrapper {
        padding: 10px 14px;
    }
    
    #messageInput {
        font-size: 14px;
    }
    
    .attach-btn,
    .send-btn {
        width: 28px;
        height: 28px;
    }
    
    .file-preview {
        padding: 10px;
        margin-bottom: 8px;
    }
    
    .user-profile-section {
        padding: 10px;
    }
    
    .user-name {
        font-size: 13px;
    }
    
    .user-handle {
        font-size: 11px;
    }
    
    .account-status {
        padding: 10px;
    }
    
    .account-name {
        font-size: 12px;
    }
    
    .account-type {
        font-size: 10px;
    }
}

/* Mobile Phones */
@media (max-width: 480px) {
    .mobile-menu-toggle {
        display: flex !important;
    }
    
    .sidebar {
        width: 280px;
    }
    
    .sidebar-header {
        padding: 12px;
    }
    
    .logo-container {
        padding: 10px;
        margin-bottom: 12px;
    }
    
    .site-logo {
        width: 32px;
        height: 32px;
    }
    
    .site-name {
        font-size: 20px;
    }
    
    .new-chat-btn {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .sidebar-content {
        padding: 8px;
    }
    
    .chat-item {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .sidebar-footer {
        padding: 12px;
    }
    
    .welcome-content h1 {
        font-size: 28px;
    }
    
    .welcome-logo {
        width: 70px;
        height: 70px;
        padding: 12px;
    }
    
    .suggestion-card {
        padding: 16px;
    }
    
    .suggestion-card h3 {
        font-size: 14px;
    }
    
    .suggestion-card p {
        font-size: 12px;
    }
    
    .messages-container {
        padding: 12px;
    }
    
    .message {
        padding: 12px 0;
        gap: 10px;
    }
    
    .message-avatar {
        width: 24px;
        height: 24px;
        font-size: 11px;
    }
    
    .message-content {
        font-size: 13px;
        line-height: 1.6;
    }
    
    .message-content pre {
        padding: 12px;
        font-size: 12px;
    }
    
    .message-content code {
        font-size: 12px;
    }
    
    .input-container {
        padding: 10px;
    }
    
    .input-wrapper {
        padding: 8px 12px;
        border-radius: 20px;
    }
    
    #messageInput {
        font-size: 13px;
        padding: 4px 0;
    }
    
    .attach-btn {
        width: 24px;
        height: 24px;
        padding: 6px;
    }
    
    .send-btn {
        width: 28px;
        height: 28px;
    }
    
    .file-preview {
        padding: 8px;
    }
    
    .file-preview-name {
        font-size: 12px;
    }
    
    .file-preview-remove {
        width: 20px;
        height: 20px;
        font-size: 16px;
    }
    
    .message-file {
        padding: 10px;
    }
    
    .message-file-image {
        max-height: 250px;
    }
    
    .message-file-link {
        padding: 10px;
    }
    
    .message-file-icon {
        width: 36px;
        height: 36px;
    }
    
    .message-file-name {
        font-size: 13px;
    }
    
    .message-file-size {
        font-size: 11px;
    }
    
    .user-profile-section {
        padding: 10px;
    }
    
    .user-avatar {
        width: 32px;
        height: 32px;
    }
    
    .user-name {
        font-size: 13px;
    }
    
    .user-handle {
        font-size: 11px;
    }
    
    .sidebar-menu-item {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .sidebar-menu-item svg {
        width: 18px;
        height: 18px;
    }
    
    .account-status {
        padding: 8px;
    }
    
    .user-avatar-small {
        width: 24px;
        height: 24px;
    }
    
    .account-name {
        font-size: 12px;
    }
    
    .account-type {
        font-size: 10px;
    }
    
    .input-footer p {
        font-size: 11px;
    }
    
    .modal-content {
        padding: 24px;
        max-width: 90%;
    }
    
    .modal-content h2 {
        font-size: 20px;
        margin-bottom: 20px;
    }
    
    .language-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }
    
    .language-option {
        padding: 12px;
        font-size: 13px;
    }
}

/* Very Small Phones */
@media (max-width: 360px) {
    .welcome-content h1 {
        font-size: 24px;
    }
    
    .welcome-logo {
        width: 60px;
        height: 60px;
    }
    
    .suggestion-card {
        padding: 12px;
    }
    
    .message-content {
        font-size: 12px;
    }
    
    .sidebar {
        width: 100%;
    }
}

/* Landscape Orientation */
@media (max-width: 768px) and (orientation: landscape) {
    .welcome-content h1 {
        font-size: 28px;
    }
    
    .welcome-logo {
        width: 60px;
        height: 60px;
    }
    
    .suggestions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .chat-item:hover .chat-delete-btn {
        opacity: 1;
    }
    
    .message:hover .message-actions {
        opacity: 1;
    }
    
    .action-btn,
    .chat-delete-btn,
    .send-btn,
    .attach-btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    .sidebar-menu-item {
        min-height: 44px;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .site-logo,
    .welcome-logo,
    .user-avatar img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* RTL Support */
[dir="rtl"] {
    direction: rtl;
}

[dir="rtl"] .sidebar {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

[dir="ltr"] {
    direction: ltr;
}

[dir="ltr"] .sidebar {
    border-left: none;
    border-right: 1px solid var(--border-color);
}
