/* style.css - SINGLE PAGE APP (Fixed & Cleaned) */

:root {
    --primary: #007AFF;
    --primary-gradient: linear-gradient(135deg, #007AFF, #00C6FF);
    --bg-image: none;
    --page-bg: #f2f2f7; 
    --bg-filter: none;
    --text-color: #000000;
    --label-color: #333333;
    
    /* Стекло (День) */
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: 1px solid rgba(0, 0, 0, 0.15);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
    --glass-inset: inset 0 0 20px rgba(255, 255, 255, 0.5);
    
    --input-bg: rgba(255, 255, 255, 0.5);
    --input-border: 1px solid rgba(0, 0, 0, 0.2);
    --radius: 24px;
}

[data-theme="dark"] {
    --bg-image: none !important; 
    --page-bg: #000000 !important; 
    --bg-filter: none;
    
    --text-color: #ffffff;
    --label-color: #eeeeee;
    
    --glass-bg: rgba(30, 30, 30, 0.6);
    --glass-border: 1px solid rgba(255, 255, 255, 0.15);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    --glass-inset: inset 0 0 20px rgba(0, 0, 0, 0.5);
    
    --input-bg: rgba(0, 0, 0, 0.3);
    --input-border: 1px solid rgba(255, 255, 255, 0.2);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; -webkit-tap-highlight-color: transparent; }

body {
    width: 100vw; min-height: 100vh; color: var(--text-color);
    background-color: var(--page-bg); overflow-x: hidden;
    transition: background-color 0.3s ease;
}

.bg-image {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-image) center/cover no-repeat;
    z-index: -2; transition: opacity 0.5s ease;
}

.main-container { max-width: 600px; margin: 0 auto; padding: 20px; position: relative; z-index: 1; }

/* ЭКРАНЫ */
.screen { display: none; animation: fadeIn 0.5s ease; }
.screen.active { display: block; }
.screen.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* СТИЛИ КАРТОЧЕК */
.glass-element, .liquid-card, .menu-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: var(--glass-border); border-radius: var(--radius);
    box-shadow: var(--glass-shadow), var(--glass-inset);
}

.liquid-card { padding: 30px; position: relative; overflow: hidden; }
.liquid-card::before {
    content: ''; position: absolute; inset: 0; z-index: -1;
    background: inherit; filter: url(#liquid-distortion); opacity: 0.3; pointer-events: none;
}
[data-theme="dark"] .liquid-card::before { display: none; }

/* HEADER */
.app-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; margin-top: 10px; }
.icon-btn { padding: 10px 20px; border: none; font-size: 16px; font-weight: 600; color: var(--text-color); cursor: pointer; background: transparent; }
.theme-switcher { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; font-size: 22px; cursor: pointer; }

/* WELCOME */
.center-card { 
    margin-top: 2vh; 
    padding: 30px 20px; 
    text-align: center; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
}
.main-logo { width: 100px; height: 100px; object-fit: contain; margin-bottom: 20px; }
.app-title { font-size: 32px; font-weight: 800; margin-bottom: 5px; }
.app-subtitle { opacity: 0.6; margin-bottom: 30px; }
.lang-grid { display: flex; flex-direction: column; gap: 15px; width: 100%; }
.lang-select-btn { background: var(--input-bg); border: var(--input-border); padding: 15px; border-radius: 16px; font-size: 18px; font-weight: 600; color: var(--text-color); cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; gap: 10px; }

/* MENU */
.menu-grid { display: flex; flex-direction: column; gap: 20px; }
.menu-card { padding: 30px; display: flex; align-items: center; gap: 20px; cursor: pointer; transition: transform 0.2s; color: var(--text-color); }
.menu-card:active { transform: scale(0.97); }
.menu-icon { font-size: 40px; background: rgba(255,255,255,0.2); width: 70px; height: 70px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.menu-text h3 { margin: 0; font-size: 20px; font-weight: 700; }
.menu-text p { margin: 5px 0 0; opacity: 0.7; font-size: 14px; }

/* FORMS */
h2 { font-size: 26px; margin-bottom: 5px; }
.subtitle { opacity: 0.7; margin-bottom: 25px; }
.input-group { margin-bottom: 20px; }
label { display: block; font-weight: 700; margin-bottom: 8px; color: var(--label-color); padding-left: 5px; }
.input-wrapper { background: var(--input-bg); border: var(--input-border); border-radius: 16px; transition: 0.3s; }
.input-wrapper:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.2); }
input, select, textarea { width: 100%; padding: 16px; border: none; background: transparent; color: var(--text-color); font-size: 16px; outline: none; }
input[type="file"] { display: none; }
.file-label { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 15px; cursor: pointer; font-weight: 600; border: 2px dashed var(--text-color); opacity: 0.7; }
#file-name-display { text-align: center; margin-top: 8px; font-size: 13px; color: var(--primary); font-weight: 700; min-height: 20px; }
.checkbox-group { display: flex; align-items: center; gap: 15px; padding: 15px; margin-bottom: 20px; cursor: pointer; }
.checkbox-group input { width: 24px; height: 24px; cursor: pointer; accent-color: var(--primary); }
.checkbox-group label { margin: 0; font-weight: 500; font-size: 14px; cursor: pointer; line-height: 1.4; }
.primary-btn { width: 100%; padding: 18px; border-radius: 20px; border: none; background: var(--primary-gradient); color: white; font-size: 18px; font-weight: bold; cursor: pointer; margin-top: 10px; }

/* === ЧАТ: Вариант Glassmorphism (НОВЫЙ) === */

.chat-container-glass {
    /* Внешний вид (фон, стекло, границы) */
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    
    /* Тень */
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
    
    /* Фиксация на весь экран */
    position: fixed;       
    top: 0; left: 0; right: 0; bottom: 0; 
    width: 100%;
    height: 100%;       
    height: 100dvh;      
    z-index: 9999;         
    
    /* === ГЛАВНОЕ ИЗМЕНЕНИЕ ЗДЕСЬ === */
    display: none; /* По умолчанию скрыт! */
}

/* Показываем чат только когда добавлен класс .active */
.chat-container-glass.active {
    display: flex !important; 
    flex-direction: column;
    overflow: hidden;      
}

.chat-header-glass {
    padding: 20px 24px 15px;
    background: rgba(255, 255, 255, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

/* Аватар и Инфо */
.bot-avatar-glass {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 22px; font-weight: bold;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.bot-info h3 { font-size: 18px; font-weight: 700; margin: 0 0 4px; color: var(--text-color); }
.bot-info p { font-size: 13px; margin: 0; color: var(--text-color); opacity: 0.8; display: flex; align-items: center; gap: 6px; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: #00d95f; display: inline-block; animation: pulse 2s infinite; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }

/* === ОБЛАСТЬ СООБЩЕНИЙ === */
.chat-messages-glass {
    flex: 1;               
    overflow-y: auto;      
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    
    min-height: 0;         /* Важно для скролла */
    scroll-behavior: smooth;
}

/* Стили сообщений */
.message-glass {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.5;
    position: relative;
    animation: messageAppear 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes messageAppear { from { opacity: 0; transform: translateY(10px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }

.message-user-glass { align-self: flex-end; background: linear-gradient(135deg, var(--primary), #5d8aff); color: white; border-bottom-right-radius: 6px; box-shadow: 0 4px 12px rgba(0, 122, 255, 0.25); }
.message-bot-glass { align-self: flex-start; background: rgba(255, 255, 255, 0.7); color: var(--text-color); border-bottom-left-radius: 6px; border: 1px solid rgba(0, 0, 0, 0.05); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); }
.message-time-glass { font-size: 11px; margin-top: 6px; opacity: 0.7; text-align: right; }

/* === ОБЛАСТЬ ВВОДА === */
.chat-input-container-glass {
    padding: 18px 24px;
    background: rgba(255, 255, 255, 0.25);
    border-top: 1px solid rgba(255, 255, 255, 0.25);
    display: flex;
    gap: 12px;
    align-items: center;
    
    flex-shrink: 0;        
    padding-bottom: max(18px, env(safe-area-inset-bottom));
}

.input-glass-wrapper {
    flex: 1;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 22px;
    padding: 2px;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
}
.input-glass-wrapper:focus-within { background: rgba(255, 255, 255, 0.8); border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15); }

#chat-input-glass, #chat-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 14px 18px;
    font-size: 16px;
    color: var(--text-color);
    outline: none;
}

.input-actions { display: flex; gap: 8px; padding: 0 10px; }
.input-action-btn { background: none; border: none; font-size: 20px; cursor: pointer; opacity: 0.7; transition: opacity 0.2s; color: var(--text-color); }
.input-action-btn:hover { opacity: 1; }

.send-btn-glass {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #5d8aff);
    color: white; border: none;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}
.send-btn-glass:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 122, 255, 0.4); }
.send-btn-glass:active { transform: translateY(0); }

/* Быстрые ответы */
.quick-replies-glass {
    display: flex; flex-wrap: wrap; gap: 10px; padding: 0 24px 18px;
    background: rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}
.quick-reply-btn {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 18px; padding: 10px 16px; font-size: 14px;
    color: var(--text-color); cursor: pointer; transition: all 0.2s;
    backdrop-filter: blur(10px);
}
.quick-reply-btn:hover { background: rgba(255, 255, 255, 0.8); transform: translateY(-2px); }

/* Индикатор печати */
.typing-indicator-glass {
    display: flex; gap: 5px; padding: 12px 20px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 20px; border-bottom-left-radius: 6px;
    width: fit-content; margin-left: 8px; align-items: center;
}
.typing-text { font-size: 14px; opacity: 0.7; margin-right: 8px; }
.typing-dot-glass { width: 8px; height: 8px; background: #8e8e93; border-radius: 50%; animation: typingGlass 1.4s infinite ease-in-out; }
.typing-dot-glass:nth-child(2) { animation-delay: 0.2s; }
.typing-dot-glass:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingGlass { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

/* Темная тема для чата */
[data-theme="dark"] .chat-container-glass { background: rgba(30, 30, 35, 0.7); border: 1px solid rgba(255, 255, 255, 0.1); }
[data-theme="dark"] .message-bot-glass { background: rgba(60, 60, 65, 0.8); color: #f0f0f0; }
[data-theme="dark"] .input-glass-wrapper { background: rgba(60, 60, 65, 0.6); border: 1px solid rgba(255, 255, 255, 0.1); }
[data-theme="dark"] .quick-reply-btn { background: rgba(60, 60, 65, 0.6); color: #f0f0f0; }

/* === LIVE INFO BAR === */
.live-info-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 15px;
    margin-top: 10px; /* <--- Tepadan ozgina joy tashladik */
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.4);
    gap: 5px;
}

.info-section {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: center;
    min-width: 0; /* Matn kesilib qolmasligi uchun */
}

.info-icon {
    font-size: 20px;
}

.info-content {
    display: flex;
    flex-direction: column;
}

.info-title {
    font-size: 15px;
    font-weight: 800;
    line-height: 1.1;
    color: var(--text-color);
}

.info-subtitle {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.currency-row {
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.divider {
    width: 1px;
    height: 25px;
    background: rgba(0,0,0,0.1);
    margin: 0 5px;
}

[data-theme="dark"] .live-info-container {
    background: rgba(60, 60, 60, 0.6);
}
[data-theme="dark"] .divider {
    background: rgba(255,255,255,0.2);
}

/* === MOBIL ADAPTATSIYA (MUHIM QISM) === */
@media (max-width: 420px) {
    .live-info-container {
        padding: 10px; /* Paddingni kamaytiradik */
        border-radius: 16px;
    }

    .info-section {
        gap: 5px; /* Oradagi masofani qisamiz */
    }

    .info-icon {
        font-size: 16px; /* Ikonkani kichraytiramiz */
    }

    .info-title {
        font-size: 13px; /* Asosiy matn kichraydi */
    }

    .info-subtitle {
        font-size: 10px;
        max-width: 60px; /* Uzun so'zlar sig'ishi uchun */
    }

    .currency-row {
        font-size: 9px; /* Valyuta kichraydi */
    }
    
    /* Agar ekran juda kichik bo'lsa, chiziqlarni olib tashlaymiz */
    .divider {
        display: none; 
    }
    
    /* Har bir seksiyani o'rtaga joylaymiz */
    .info-section {
        justify-content: space-around;
        text-align: center;
    }
}

/* === MOBIL UCHUN IXCHAMLASHTIRISH === */
@media (max-width: 420px) {
    /* Asosiy konteynerni ekranga sig'diramiz */
    .main-container {
        padding-top: 10px;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }

    /* Logotipni sal kichraytiramiz */
    .main-logo {
        width: 80px;  /* 100px dan 80px ga */
        height: 80px;
        margin-bottom: 15px;
    }

    /* Sarlavhani sal kichraytiramiz */
    .app-title {
        font-size: 26px;
    }
    
    /* Vidjet matnlarini kichraytirish (avvalgi kod) */
    .live-info-container {
        padding: 8px;
    }
    .info-title { font-size: 14px; }
    .info-subtitle { font-size: 11px; }
}