* { margin: 0; padding: 0; box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, sans-serif; }

/* =========================================
   SPLASH SCREEN (Жүктелу экраны)
   ========================================= */
#splash-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: #ffffff; display: flex; justify-content: center; align-items: center; z-index: 99999; transition: opacity 0.5s ease, visibility 0.5s ease; }
.splash-content { text-align: center; animation: pulse-logo 1.5s infinite alternate ease-in-out; }
.splash-content img { width: 80px; height: 80px; border-radius: 18px; margin-bottom: 12px; box-shadow: 0 15px 35px rgba(0,0,0,0.08); }
.splash-text { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.5px; margin: 0; background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%); background-size: 200% auto; -webkit-background-clip: text; -webkit-text-fill-color: transparent; animation: gradient-shift 3s ease infinite; }
@keyframes pulse-logo { 0% { transform: scale(0.96); opacity: 0.9; } 100% { transform: scale(1.04); opacity: 1; } }
@keyframes gradient-shift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }

/* =========================================
   НЕГІЗГІ СТИЛЬДЕР
   ========================================= */
html, body { height: 100%; width: 100%; }
body { background-color: #f8fafc; color: #0f172a; display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }

/* Навигация */
.top-nav { display: flex; justify-content: space-between; align-items: center; padding: 12px 24px; background: #ffffff; border-bottom: 1px solid #e2e8f0; z-index: 10; flex-shrink: 0; }
.logo-box { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.25rem; }
.logo-box img { width: 32px; height: 32px; border-radius: 8px; }
.tabs { display: flex; gap: 8px; background: #f1f5f9; padding: 4px; border-radius: 10px; }
.tab-btn { display: flex; align-items: center; gap: 6px; padding: 8px 16px; border: none; background: transparent; color: #64748b; font-weight: 500; border-radius: 6px; cursor: pointer; transition: 0.2s; font-size: 0.9rem; }
.tab-btn i { width: 16px; height: 16px; }
.tab-btn.active { background: #ffffff; color: #0f172a; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.btn-primary { background: #0f172a; color: white; border: none; padding: 8px 16px; border-radius: 8px; font-weight: 500; cursor: pointer; transition: 0.2s; }
.btn-primary:hover { background: #000000; }

/* Көріністер (Views) */
.view { display: none; flex: 1; flex-direction: column; width: 100%; max-width: 1000px; margin: 0 auto; padding: 20px; overflow: hidden; min-height: 0; }
.active-view { display: flex; }

/* Home терезесі (Sidebar және Чат) */
#view-home.active-view { flex-direction: row; gap: 20px; }

/* Чат аймағы */
.chat-wrapper { flex: 1; display: flex; flex-direction: column; background: #ffffff; border: 1px solid #e2e8f0; border-radius: 16px; overflow: hidden; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); min-height: 0; }
.chat-history { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.welcome-box { text-align: center; margin: auto; padding: 20px; }
.welcome-box img { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 12px; }
.welcome-box h2 { font-size: 1.5rem; margin-bottom: 8px; }
.welcome-box p { color: #64748b; }
.msg { max-width: 80%; padding: 12px 16px; border-radius: 12px; font-size: 0.95rem; line-height: 1.5; }
.msg.user { align-self: flex-end; background: #f1f5f9; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: #ffffff; border: 1px solid #e2e8f0; border-bottom-left-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }

/* Инпут аймағы */
.input-area { display: flex; align-items: center; gap: 12px; padding: 16px; border-top: 1px solid #e2e8f0; background: #ffffff; flex-shrink: 0; }
#prompt-input { flex: 1; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px 16px; font-size: 1rem; outline: none; transition: 0.2s; background: #f8fafc; }
#prompt-input:focus { border-color: #cbd5e1; background: #ffffff; }
.icon-btn { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: none; border-radius: 10px; cursor: pointer; transition: 0.2s; }
.send-btn { background: #0f172a; color: white; }
.send-btn:hover { background: #000000; }

/* Preview аймағы */
.preview-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; background: #ffffff; border: 1px solid #e2e8f0; border-radius: 12px; margin-bottom: 16px; flex-shrink: 0; }
.preview-title { font-weight: 600; font-size: 1rem; }
.preview-actions { display: flex; gap: 12px; }
.btn-outline { background: #ffffff; border: 1px solid #e2e8f0; padding: 8px 16px; border-radius: 8px; display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; font-size: 0.9rem; transition: 0.2s; }
.btn-outline:hover { background: #f8fafc; }
.btn-netlify { background: #00C7B7; color: white; border: none; padding: 8px 16px; border-radius: 8px; display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; font-size: 0.9rem; }
.btn-netlify:hover { background: #00b0a2; }
.iframe-container { flex: 1; background: #ffffff; border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden; min-height: 0; }
iframe { width: 100%; height: 100%; border: none; }

/* Авторизация Модаль */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal.hidden { display: none !important; }
.modal-content { background: #ffffff; padding: 30px; border-radius: 16px; width: 90%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; position: relative; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1); }
.close-modal { position: absolute; top: 12px; right: 12px; background: none; border: none; cursor: pointer; color: #64748b; }
.auth-input { width: 100%; padding: 12px 16px; border: 1px solid #e2e8f0; border-radius: 10px; font-size: 1rem; outline: none; transition: 0.2s; background: #f8fafc; }
.auth-input:focus { border-color: #0f172a; background: #ffffff; }
.auth-buttons { display: flex; gap: 10px; margin-top: 10px; }

/* ПРОФИЛЬ АВАТАР ЖӘНЕ МӘЗІР */
.profile-container { position: relative; display: inline-block; }
.avatar-circle { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, #0f172a, #334155); color: white; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 1.2rem; cursor: pointer; user-select: none; transition: 0.2s; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.avatar-circle:hover { transform: scale(1.05); }
.profile-dropdown { position: absolute; right: 0; top: 50px; background: white; border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1); width: 200px; padding: 8px; z-index: 100; display: flex; flex-direction: column; }
.dropdown-header { padding: 8px 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: none; background: transparent; width: 100%; text-align: left; cursor: pointer; border-radius: 8px; transition: 0.2s; font-size: 0.9rem; color: #0f172a; }
.dropdown-item:hover { background: #f1f5f9; }
.dropdown-item i { width: 16px; height: 16px; }
.text-red { color: #dc2626; }
.text-red:hover { background: #fef2f2; }
.hidden { display: none !important; }

/* TOAST NOTIFICATIONS */
.toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 12px; z-index: 999999; }
.toast { display: flex; align-items: center; gap: 12px; min-width: 250px; padding: 14px 20px; background: #ffffff; border-left: 4px solid #0f172a; border-radius: 10px; box-shadow: 0 10px 30px -5px rgba(0,0,0,0.15); font-size: 0.95rem; font-weight: 500; color: #0f172a; animation: slideInRight 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }
.toast.success { border-left-color: #10b981; }
.toast.success i { color: #10b981; }
.toast.error { border-left-color: #ef4444; }
.toast.error i { color: #ef4444; }
.toast.fadeOut { animation: fadeOutRight 0.4s ease forwards; }
@keyframes slideInRight { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOutRight { from { transform: translateX(0); opacity: 1; } to { transform: translateX(120%); opacity: 0; } }

/* Толық экран режимі */
.fullscreen-mode { position: fixed !important; top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important; width: 100% !important; height: 100dvh !important; z-index: 99999 !important; background: white !important; border-radius: 0 !important; padding: 0 !important; margin: 0 !important; }
.fullscreen-mode iframe { width: 100% !important; height: 100% !important; border: none !important; }

/* SIDEBAR (ЧАТТАР ТІЗІМІ) СТИЛЬДЕРІ */
.sidebar { width: 260px; background: #ffffff; border: 1px solid #e2e8f0; border-radius: 16px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }
.sidebar-header { padding: 16px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; background: #f8fafc; }
.sidebar-header h3 { font-size: 0.95rem; margin: 0; color: #0f172a; font-weight: 700; }
.chat-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-item { padding: 10px 12px; background: #f8fafc; border: 1px solid transparent; border-radius: 8px; font-size: 0.85rem; color: #334155; cursor: pointer; transition: 0.2s; display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-item:hover { background: #e2e8f0; }
.chat-item.active { background: #0f172a; color: white; }

/* =========================================
   МОБИЛЬДІК БЕЙІМДЕЛУ
   ========================================= */
@media (max-width: 768px) {
    #view-home.active-view { flex-direction: column; gap: 10px; }
    .sidebar { width: 100%; height: 140px; flex-shrink: 0; margin-bottom: 0px; }
    
    .top-nav { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
    .logo-box { order: 1; }
    .auth-box { order: 2; }
    .tabs { order: 3; width: 100%; justify-content: center; }
    
    .view { padding: 10px; } 
    .chat-history { padding: 16px; }
    .input-area { padding: 12px; }
    
    .preview-header { flex-direction: column; align-items: stretch; gap: 12px; }
    .preview-actions { flex-direction: column; }
    .btn-outline, .btn-netlify { justify-content: center; }
    
    .toast-container { bottom: 20px; left: 20px; right: 20px; }
    .toast { width: 100%; min-width: auto; }
}