/* Основные стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.app-container {
    display: flex;
    height: 100vh;
    background: #ffffff;
}

/* Сайдбар */
.sidebar {
    width: 260px;
    background: #202123;
    color: #fff;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #4d4d4f;
}

.sidebar-header h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #fff;
}

.new-chat-btn {
    width: 100%;
    padding: 12px;
    background: #10a37f;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    transition: background 0.3s;
}

.new-chat-btn:hover {
    background: #0d8c6c;
}

.chats-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.chat-item {
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 5px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s;
}

.chat-item:hover {
    background: #2d2d2f;
}

.chat-item.active {
    background: #343541;
}

.chat-item-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
}

.chat-delete-btn {
    background: none;
    border: none;
    color: #8e8e9e;
    cursor: pointer;
    padding: 5px;
    border-radius: 3px;
}

.chat-delete-btn:hover {
    color: #fff;
    background: #ef4444;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid #4d4d4f;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: #10a37f;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
}

.user-details {
    flex: 1;
}

.user-name {
    display: block;
    font-size: 14px;
    font-weight: 500;
}

.user-plan {
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 10px;
    display: inline-block;
    margin-top: 2px;
}

.user-plan.free {
    background: #6b7280;
    color: white;
}

.user-plan.pro {
    background: #f59e0b;
    color: white;
}

.settings-btn {
    color: #8e8e9e;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    border-radius: 3px;
}

.settings-btn:hover {
    color: #fff;
    background: #4d4d4f;
}

.auth-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Основной контент */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
}

.main-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    color: #374151;
    cursor: pointer;
    padding: 8px;
    border-radius: 5px;
}

.menu-toggle:hover {
    background: #f3f4f6;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-title h1 {
    font-size: 20px;
    color: #374151;
}

.upgrade-badge {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: transform 0.3s;
}

.upgrade-badge:hover {
    transform: translateY(-2px);
}

.header-actions {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 8px 16px;
    border-radius: 5px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: #10a37f;
    color: white;
}

.btn-primary:hover {
    background: #0d8c6c;
}

.btn-outline {
    background: white;
    color: #10a37f;
    border: 1px solid #10a37f;
}

.btn-outline:hover {
    background: #f0f9f7;
}

.btn-ads {
    background: #3b82f6;
    color: white;
}

.btn-ads:hover {
    background: #2563eb;
}

.btn-admin {
    background: #ef4444;
    color: white;
}

.btn-admin:hover {
    background: #dc2626;
}

/* Контейнер чата */
.chat-container {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: #f7f7f8;
}

.welcome-message {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
    padding: 40px 20px;
}

.welcome-message h2 {
    font-size: 32px;
    color: #374151;
    margin-bottom: 15px;
}

.welcome-message p {
    color: #6b7280;
    font-size: 16px;
    margin-bottom: 30px;
}

.examples {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 30px;
}

.example-card {
    padding: 20px;
    background: white;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.example-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    border-color: #10a37f;
}

.example-card i {
    font-size: 24px;
    color: #10a37f;
    margin-bottom: 10px;
    display: block;
}

.example-card span {
    font-size: 14px;
    color: #374151;
    font-weight: 500;
}

/* Сообщения */
.message {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.message-user {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 20px;
    margin-left: auto;
}

.message-ai {
    background: #f7f7f8;
    border-radius: 10px;
    padding: 20px;
    border: 1px solid transparent;
}

.message-ad {
    background: linear-gradient(135deg, #fff8e1, #ffe8a1);
    border: 2px solid #f59e0b;
    border-radius: 10px;
    padding: 20px;
    position: relative;
}

.message-ad::before {
    content: "Реклама • Партнер";
    position: absolute;
    top: -10px;
    left: 20px;
    background: #f59e0b;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.user-avatar-bg {
    background: #10a37f;
    color: white;
}

.ai-avatar-bg {
    background: #8b5cf6;
    color: white;
}

.message-content {
    line-height: 1.6;
    color: #374151;
}

.message-content pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 15px 0;
    position: relative;
}

.message-content code {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2d2d2d;
    padding: 8px 15px;
    border-radius: 5px 5px 0 0;
    color: #ccc;
    font-size: 12px;
}

.copy-code-btn {
    background: #404040;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
}

.copy-code-btn:hover {
    background: #505050;
}

.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.message-content th,
.message-content td {
    border: 1px solid #e5e7eb;
    padding: 10px;
    text-align: left;
}

.message-content th {
    background: #f3f4f6;
    font-weight: 600;
}

.link-preview {
    display: block;
    margin-top: 15px;
    padding: 15px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s;
}

.link-preview:hover {
    border-color: #10a37f;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.link-preview-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.link-favicon {
    width: 16px;
    height: 16px;
}

.link-title {
    font-weight: 600;
    color: #374151;
    flex: 1;
}

.link-description {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.4;
}

.link-url {
    color: #10a37f;
    font-size: 12px;
    margin-top: 5px;
    display: block;
}

/* Блок ввода */
.input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid #e5e7eb;
    position: sticky;
    bottom: 0;
}

.input-wrapper {
    position: relative;
    display: flex;
    gap: 10px;
}

.input-wrapper textarea {
    flex: 1;
    padding: 15px 50px 15px 20px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 16px;
    resize: none;
    max-height: 200px;
    min-height: 56px;
    line-height: 1.5;
    font-family: inherit;
}

.input-wrapper textarea:focus {
    outline: none;
    border-color: #10a37f;
    box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.send-btn,
.clear-btn,
.download-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 10px;
    border-radius: 5px;
    transition: all 0.3s;
}

.send-btn {
    right: 50px;
    color: #10a37f;
}

.clear-btn {
    right: 90px;
}

.download-btn {
    right: 130px;
}

.send-btn:hover,
.clear-btn:hover,
.download-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-footer {
    margin-top: 10px;
    text-align: center;
}

.disclaimer {
    font-size: 12px;
    color: #9ca3af;
}

/* Рекламный сайдбар */
.ads-sidebar {
    width: 300px;
    background: white;
    border-left: 1px solid #e5e7eb;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.ads-header {
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e7eb;
}

.ads-header span {
    font-weight: 600;
    color: #374151;
    font-size: 16px;
}

.ads-header small {
    color: #9ca3af;
    font-size: 12px;
    display: block;
    margin-top: 2px;
}

.ad-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
    transition: all 0.3s;
    cursor: pointer;
}

.ad-card:hover {
    border-color: #10a37f;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.ad-title {
    font-weight: 600;
    color: #374151;
    margin-bottom: 5px;
    font-size: 14px;
}

.ad-description {
    color: #6b7280;
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 10px;
}

.ad-link {
    color: #10a37f;
    font-size: 12px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ad-link:hover {
    text-decoration: underline;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 10px;
    width: 100%;
    max-width: 400px;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    color: #374151;
    font-size: 18px;
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    color: #6b7280;
    cursor: pointer;
    padding: 5px;
    border-radius: 3px;
}

.close-modal:hover {
    color: #374151;
    background: #f3f4f6;
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #374151;
    font-weight: 500;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #10a37f;
}

.btn-block {
    width: 100%;
    padding: 12px;
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.btn-link {
    background: none;
    border: none;
    color: #10a37f;
    cursor: pointer;
    font-size: 14px;
    padding: 5px;
}

.btn-link:hover {
    text-decoration: underline;
}

/* Адаптивность */
@media (max-width: 1024px) {
    .ads-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        transform: translateX(-100%);
        z-index: 100;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .menu-toggle {
        display: block;
    }
    
    .header-title h1 {
        font-size: 18px;
    }
    
    .examples {
        grid-template-columns: 1fr;
    }
    
    .input-wrapper textarea {
        padding-right: 120px;
    }
    
    .send-btn,
    .clear-btn,
    .download-btn {
        position: absolute;
        top: auto;
        bottom: 10px;
        transform: none;
    }
    
    .send-btn {
        right: 50px;
    }
    
    .clear-btn {
        right: 90px;
    }
    
    .download-btn {
        right: 10px;
    }
}

/* Загрузка */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #10a37f;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Уведомления */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1001;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification.success {
    border-left: 4px solid #10a37f;
}

.notification.error {
    border-left: 4px solid #ef4444;
}

.notification.warning {
    border-left: 4px solid #f59e0b;
}

.notification-icon {
    font-size: 20px;
}

.notification.success .notification-icon {
    color: #10a37f;
}

.notification.error .notification-icon {
    color: #ef4444;
}

.notification.warning .notification-icon {
    color: #f59e0b;
}

.notification-content {
    flex: 1;
}

.notification-title {
    font-weight: 600;
    color: #374151;
    font-size: 14px;
}

.notification-message {
    color: #6b7280;
    font-size: 13px;
    margin-top: 2px;
}

.close-notification {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 5px;
    border-radius: 3px;
}

.close-notification:hover {
    color: #374151;
    background: #f3f4f6;
}