/* css/style.css */

:root {
    --primary-bg: #0f172a;
    --egg-bg: rgba(255, 255, 255, 0.05);
    --egg-border: rgba(255, 255, 255, 0.1);
    --accent-color: #38bdf8;
    --text-color: #f1f5f9;
    --rod-color: #38bdf8;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    color: var(--text-color);
}

/* Электронное Яйцо */
.egg-container {
    width: 400px;
    height: 600px;
    background: var(--egg-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--egg-border);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5),
                inset 0 0 20px rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    padding: 40px;
    position: relative;
    transition: all 0.5s ease;
    animation: float 6s ease-in-out infinite;
    overflow: hidden;
}

/* Спящий режим — без плавания, приглушённый */
.egg-container.sleeping {
    animation: none;
    opacity: 0.7;
    border-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: all 0.8s ease;
}

.egg-container.talking {
    border-color: var(--rod-color);
    box-shadow: 0 0 40px rgba(56, 189, 248, 0.3);
    background: radial-gradient(circle at top, rgba(56, 189, 248, 0.1) 0%, rgba(15, 23, 42, 0.2) 100%);
}

.egg-container.loading-voice {
    border-color: #f7931a;
    box-shadow: 0 0 30px rgba(247, 147, 26, 0.3);
    animation: loading-pulse 2s infinite ease-in-out;
}

@keyframes loading-pulse {
    0%, 100% { transform: translateY(0) scale(1); opacity: 1; }
    50% { transform: translateY(-5px) scale(0.98); opacity: 0.8; }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

/* Род (Помощник) */
.rod-section {
    height: 150px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

#rod-svg {
    width: 120px;
    height: 120px;
    filter: drop-shadow(0 0 10px var(--rod-color));
}

.rod-eye {
    fill: var(--rod-color);
    animation: blink 4s infinite;
    transform-origin: center;
    transition: cx 0.1s, cy 0.1s, transform 0.3s, opacity 0.5s;
}

/* Спящие глаза — полузакрыты, без моргания */
.sleeping .rod-eye {
    transform: scaleY(0.15);
    animation: none;
    opacity: 0.4;
}

.sleeping #rod-svg {
    filter: drop-shadow(0 0 5px rgba(56, 189, 248, 0.3));
}

/* Zzz — плавающий текст рядом с лицом */
.sleeping .rod-section::after {
    content: 'z z z';
    position: absolute;
    right: 25%;
    top: 15%;
    font-size: 1.2rem;
    color: var(--accent-color);
    opacity: 0.3;
    animation: zzz 3s ease-in-out infinite;
    letter-spacing: 4px;
}

@keyframes zzz {
    0%, 100% { opacity: 0.15; transform: translateY(0); }
    50% { opacity: 0.4; transform: translateY(-8px); }
}

@keyframes blink {
    0%, 90%, 100% { transform: scaleY(1); }
    95% { transform: scaleY(0); }
}

#rod-mouth {
    stroke: var(--rod-color);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: var(--rod-color);
    transition: d 0.1s ease;
}

/* Чат */
.chat-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    scrollbar-width: none;
    mask-image: linear-gradient(to bottom, transparent 0%, black 10%, black 90%, transparent 100%);
}

.chat-container::-webkit-scrollbar { display: none; }

.message {
    padding: 10px 15px;
    border-radius: 15px;
    margin-bottom: 10px;
    font-size: 0.9rem;
    max-width: 85%;
    line-height: 1.4;
    animation: msg-appear 0.3s ease-out;
}

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

.message.user {
    background: rgba(255, 255, 255, 0.1);
    align-self: flex-end;
    margin-left: auto;
}

.message.rod {
    background: rgba(56, 189, 248, 0.1);
    border-left: 2px solid var(--accent-color);
}

.message.typing {
    font-style: italic;
    opacity: 0.6;
    width: 50px;
    display: flex;
    justify-content: center;
    animation: typing-blink 1s infinite;
}

@keyframes typing-blink {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* Контролы */
.controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding-top: 20px;
}

.mic-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--egg-border);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.mic-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.mic-btn.active {
    background: #ef4444;
    box-shadow: 0 0 20px #ef4444;
    animation: pulse 1.5s infinite;
}

/* Passive — слушает команды (мягкий синий пульс) */
.mic-btn.mode-passive.active {
    background: #2563eb;
    box-shadow: 0 0 15px #2563eb;
}

/* Active — слушает сообщение (яркий зелёный) */
.mic-btn.mode-active {
    background: #22c55e;
    box-shadow: 0 0 25px #22c55e;
    animation: pulse-active 0.8s infinite;
}

@keyframes pulse-active {
    0%, 100% { transform: scale(1); box-shadow: 0 0 25px #22c55e; }
    50% { transform: scale(1.08); box-shadow: 0 0 40px #22c55e; }
}

/* Cooldown — обработка (оранжевый) */
.mic-btn.mode-cooldown {
    background: #f59e0b;
    box-shadow: 0 0 15px #f59e0b;
}

.settings-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.settings-btn:hover { opacity: 1; }

.modal {
    display: none;
    position: fixed; /* Вынесено из яйца, теперь на весь экран */
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(12px);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.glass-premium {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), inset 0 0 15px rgba(255, 255, 255, 0.05);
    padding: 30px;
    border-radius: 24px;
    width: 90%;
    max-width: 450px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 15px;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.icon-btn-close {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}

.icon-btn-close:hover {
    background: rgba(239, 68, 68, 0.8);
    transform: scale(1.1);
}

.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.glass-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.glass-item label {
    font-size: 0.9rem;
    color: #cbd5e1;
    font-weight: 500;
}

.premium-input {
    width: 100%;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 12px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.premium-input:focus {
    border-color: var(--accent-color);
}

.premium-input option {
    background: #1e293b;
    color: white;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.badge {
    background: rgba(56, 189, 248, 0.2);
    color: var(--accent-color);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.premium-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
}

.premium-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
    transition: transform 0.2s;
}

.premium-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

.glass-btn {
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.glass-btn.primary {
    background: var(--accent-color);
    color: #0f172a;
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3);
}

.glass-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(56, 189, 248, 0.5);
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

svg.icon {
    width: 24px;
    height: 24px;
    fill: white;
}

/* Кнопка "Показать историю" */
.history-btn-wrap {
    display: flex;
    justify-content: center;
    padding: 4px 0 0;
}

.history-btn {
    background: none;
    border: none;
    color: var(--accent-color);
    font-size: 0.8rem;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    text-decoration: underline;
    font-family: inherit;
}

.history-btn:hover {
    opacity: 1;
}

/* Модальное окно истории (фулскрин) */
.history-modal-content {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 24px;
    overflow: hidden;
}

.history-modal-content .modal-header {
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 8px;
}

.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.history-msg {
    padding: 10px 15px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
    max-width: 80%;
}

.history-msg.user {
    background: rgba(255, 255, 255, 0.1);
    align-self: flex-end;
}

.history-msg.rod {
    background: rgba(56, 189, 248, 0.1);
    border-left: 2px solid var(--accent-color);
    align-self: flex-start;
}

.history-msg .history-time {
    font-size: 0.7rem;
    opacity: 0.4;
    margin-top: 4px;
}

/* ── Login overlay ──────────────────────────────────────────────────────── */

.login-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.login-card {
    text-align: center;
    padding: 48px 56px;
    border-radius: 28px;
    background: rgba(30, 41, 59, 0.5);
    backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.login-logo { margin-bottom: 4px; }

.login-title {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-color);
    letter-spacing: -0.5px;
}

.login-subtitle {
    font-size: 0.95rem;
    color: #94a3b8;
    margin-bottom: 12px;
}

.google-signin-container {
    min-height: 44px;
    display: flex;
    justify-content: center;
}

.login-error {
    color: #ef4444;
    font-size: 0.85rem;
    min-height: 20px;
}

/* App hidden state */
.app-hidden {
    display: none !important;
}

/* ── User bar ───────────────────────────────────────────────────────────── */

.user-bar {
    display: none;
    position: fixed;
    top: 12px;
    right: 16px;
    align-items: center;
    gap: 8px;
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 6px 12px 6px 6px;
    z-index: 100;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.user-name {
    font-size: 0.8rem;
    color: #94a3b8;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
}

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

/* Settings button SVG color */
.settings-btn {
    color: var(--accent-color);
}
