@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;700;800&family=Nunito:wght@400;600;700;800&display=swap');

:root {
    --primary: #FF4B72; --secondary: #8A4BFF; --bg: #F6F3FB; --card: #FFFFFF;
    --panel: #FBFAFD; --border: #E7E1F2; --text: #241B33; --muted: #7C7594;
    --success: #2F9E6E; --danger: #E5484D; --husband-color: #3E7BFA; --wife-color: #FF5C9A;
    --success-soft: #E1F7EE; --warning-soft: #FDF0E2; --danger-soft: #FDE4E4;
    --shadow: 0 10px 25px rgba(50, 30, 90, 0.06); --radius-lg: 20px; --radius-sm: 10px;
}

[data-theme="dark"] {
    --bg: #15111F; --card: #1E1830; --panel: #241D38; --border: #34294F;
    --text: #F2EEFB; --muted: #A79BC4; 
    --success-soft: #17332A; --warning-soft: #33240F; --danger-soft: #3A1E20;
    --shadow: 0 10px 25px rgba(0,0,0,0.35);
}

body { margin: 0; padding: 0; background-color: var(--bg); color: var(--text); font-family: 'Nunito', sans-serif; transition: background 0.3s, color 0.3s; }
body.theme-husband { --bg: #F6F3FB; }
body.theme-wife { --bg: #FFF5F7; }

[data-theme="dark"] body.theme-husband { --bg: #15111F; }
[data-theme="dark"] body.theme-wife { --bg: #1A1325; }

h1, h2, h3, h4, .brand-font { font-family: 'Baloo 2', sans-serif; }

/* Утилиты видимости */
.hidden { display: none !important; }
.mobile-only-btn { display: none !important; } /* Скрыто на ПК */

/* Сетка */
.app-wrapper {
    display: grid !important; 
    grid-template-columns: 250px 1fr 290px; gap: 22px;
    width: 100%; max-width: 1440px; margin: 0 auto; padding: 22px; min-height: 100vh; box-sizing: border-box; align-items: start;
}

/* Карточки */
.card { background: var(--card); padding: 22px; border-radius: var(--radius-lg); box-shadow: var(--shadow); border: 1px solid var(--border); display: flex; flex-direction: column; }
.section-title { font-size: 17px; font-weight: 800; margin-top: 0; margin-bottom: 14px; }

/* Левое меню (Сайдбар) */
.sidebar { position: sticky; top: 22px; height: calc(100vh - 44px); overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-bottom: 0; }
.sidebar .header-logo { font-size: 32px; font-weight: 800; color: var(--primary); text-align: center; margin-bottom: 20px; }
.menu-item {
    padding: 13px 16px; border-radius: var(--radius-sm); border: none; background: transparent;
    color: var(--muted); font-weight: 700; font-size: 15px; text-align: left;
    cursor: pointer; transition: 0.2s; font-family: inherit; display: flex; align-items: center; gap: 11px; width: 100%; box-sizing: border-box;
}
.menu-item:hover { background: var(--panel); color: var(--text); }
.menu-item.active { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; box-shadow: 0 4px 15px rgba(138,75,255,0.3); }

/* Центральная колонка */
.main-content { display: flex; flex-direction: column; gap: 20px; width: 100%; min-width: 0; }

/* Баннер "Экосистема" */
.hero-card { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; margin-bottom: 0; padding: 25px; border: none; position: relative; }
.hero-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px; }
.hero-title { font-size: 20px; font-weight: 700; margin: 0; }
.hero-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.badge { padding: 8px 16px; border-radius: 20px; font-weight: 800; font-size: 14px; display: flex; align-items: center; gap: 4px; }
.badge-xp { background: rgba(255,255,255,0.2); color: white; border: none; }
.badge-dia { background: linear-gradient(135deg, #F6E05E, #D69E2E); color: #5C3D0A; box-shadow: 0 4px 10px rgba(214,158,46,0.3); }
.icon-btn { background: rgba(255,255,255,0.2); border: none; border-radius: 50%; width: 40px; height: 40px; font-size: 16px; cursor: pointer; color: white; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.icon-btn:hover { background: rgba(255,255,255,0.3); }

.btn-logout-top {
    position: absolute; top: 15px; right: 15px;
    background: rgba(229, 72, 77, 0.9); border: none; border-radius: 50%;
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: white; font-size: 16px; z-index: 10;
    box-shadow: 0 4px 10px rgba(229,72,77,0.3); transition: 0.2s;
}
.btn-logout-top:active { transform: scale(0.9); }

/* Дашборды */
.dashboards { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.dash-panel { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 18px; position: relative; overflow: hidden; display: flex; flex-direction: column; }
.dash-panel::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 4px; }
.panel-my::before { background: var(--husband-color); }
.panel-partner::before { background: var(--wife-color); }

/* Аватары */
.avatar-container { text-align: center; margin-bottom: 15px; height: auto; }
.avatar-wrap { position: relative; display: inline-block; }
.avatar-img { width: 90px; height: 90px; border-radius: 50%; object-fit: cover; border: 4px solid var(--border); background: var(--card); }
.avatar-ring-good { border-color: var(--success); box-shadow: 0 0 20px rgba(47,158,110,0.4); }
.avatar-ring-ok { border-color: #F59E0B; box-shadow: 0 0 15px rgba(245,158,11,0.3); }
.avatar-ring-bad { border-color: var(--danger); box-shadow: 0 0 20px rgba(229,72,77,0.4); }

.avatar-badge {
    position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white; padding: 2px 14px; border-radius: 12px; font-size: 13px; font-weight: 800;
    box-shadow: 0 4px 10px rgba(138, 75, 255, 0.3); border: 2px solid var(--card); white-space: nowrap; z-index: 5;
}
.panel-title { font-size: 18px; font-weight: 800; color: var(--text); }

/* Шкалы */
.stat-row { margin-bottom: 16px; }
.stat-header { display: flex; justify-content: space-between; font-weight: 700; font-size: 13px; margin-bottom: 6px; color: var(--text); }
.progress-bar { height: 6px; background: var(--border); border-radius: 6px; overflow: hidden; cursor: pointer; display: flex; align-items: center; }
.progress-fill { height: 100%; transition: width 0.4s ease; }
.color-husband .progress-fill { background: var(--husband-color); }
.color-wife .progress-fill { background: var(--wife-color); }

.btn-decrease { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); width: 26px; height: 26px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 10px; cursor: pointer; flex-shrink: 0; transition: 0.15s; }
.btn-decrease:active { transform: scale(0.9); background: var(--danger); color: white; }

/* Правая панель */
.right-panel { display: flex; flex-direction: column; gap: 20px; position: sticky; top: 22px; height: calc(100vh - 44px); overflow-y: auto; }
.right-panel .card { margin-bottom: 0; }
.top-item { display: flex; justify-content: space-between; padding: 12px 14px; background: var(--panel); border-radius: 10px; font-weight: 700; font-size: 13px; margin-bottom: 8px; border: 1px solid var(--border); }
.top-item.gold { background: linear-gradient(135deg, #FFD700, #FDB931); color: #6B4E00; border: none; }
.top-item.you { border-left: 4px solid var(--primary); }

/* Формы, Кнопки, Модалки */
.auth-input { width: 100%; padding: 12px; margin-bottom: 15px; border: 1.5px solid var(--border); border-radius: 12px; font-family: inherit; box-sizing: border-box; background: var(--card); color: var(--text); }
.auth-input:focus { outline: none; border-color: var(--secondary); box-shadow: 0 0 0 3px rgba(138,75,255,0.1); }
.auth-btn, .btn-small { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; border: none; border-radius: 12px; cursor: pointer; font-weight: 700; font-family: inherit; padding: 12px; width: 100%; box-sizing: border-box; transition: 0.2s; }
.auth-btn:active, .btn-small:active { transform: scale(0.95); }
.btn-small { padding: 6px 12px; border-radius: 8px; font-size: 12px; width: auto; }

.modal { display: none; position: fixed; inset: 0; background: rgba(36,27,51,0.6); align-items: center; justify-content: center; z-index: 2000; backdrop-filter: blur(4px); padding: 15px; box-sizing: border-box; }
.modal.active { display: flex; }
.modal-content { background: var(--card); padding: 25px; border-radius: var(--radius-lg); width: 100%; max-width: 500px; max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow); }

.task-item, .feed-item, .notification-box { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.feed-header { display: flex; justify-content: space-between; margin-bottom: 5px; }
.feed-time { font-size: 11px; color: var(--muted); }

.btn-like { background: var(--danger-soft); border: none; border-radius: 20px; padding: 6px 14px; color: var(--danger); cursor: pointer; font-size: 13px; font-weight: 700; transition: 0.2s; display: inline-flex; align-items: center; gap: 6px; }
.btn-like:hover { filter: brightness(0.95); }
.btn-like.liked { background: var(--danger); color: white; }

.admin-row { display: flex; flex-direction: column; gap: 8px; background: var(--panel); padding: 12px; border-radius: 12px; border: 1px solid var(--border); margin-bottom: 12px; }
.admin-controls { display: flex; gap: 8px; width: 100%; }
.admin-controls .auth-input { margin: 0; flex: 1; min-width: 0; padding: 10px; }
.admin-controls .btn-small { margin: 0; display: flex; align-items: center; justify-content: center; padding: 0 15px; font-size: 16px; flex-shrink: 0; }

.toggle-container { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: bold; }
.toggle-switch { width: 36px; height: 20px; background: var(--border); border-radius: 20px; cursor: pointer; position: relative; }
.toggle-switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: white; border-radius: 50%; transition: 0.3s; }
.toggle-switch.active { background: var(--success); }
.toggle-switch.active::after { transform: translateX(16px); }

#authScreen { position: fixed; inset: 0; background: var(--bg); z-index: 3000; display: flex; align-items: center; justify-content: center; }
.auth-box { background: var(--card); padding: 30px; border-radius: var(--radius-lg); width: 90%; max-width: 400px; box-shadow: var(--shadow); }

/* Мобильная навигация */
.mobile-nav { display: none; }
.mobile-logo { display: none; font-size: 28px; font-weight: 800; color: white; letter-spacing: 1px; text-shadow: 0 2px 5px rgba(0,0,0,0.1); }

/* АНИМАЦИИ */
@keyframes ringBell { 0% { transform: rotate(0); } 15% { transform: rotate(25deg); } 30% { transform: rotate(-25deg); } 45% { transform: rotate(15deg); } 60% { transform: rotate(-15deg); } 75% { transform: rotate(0); } 100% { transform: rotate(0); } }
.bell-ringing { animation: ringBell 2s infinite; position: relative; color: var(--danger) !important; }
.bell-ringing::after { content: ''; position: absolute; top: 2px; right: 2px; width: 10px; height: 10px; background: var(--danger); border-radius: 50%; border: 2px solid var(--card); }

@keyframes battlePulse { 0% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0.4); } 50% { box-shadow: 0 0 0 10px rgba(229, 72, 77, 0); } 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0); } }
.btn-arena-active { animation: battlePulse 1.5s infinite !important; color: var(--danger) !important; }

/* ОПТИМИЗАЦИЯ ДЛЯ МОБИЛЬНЫХ */
@media (max-width: 980px) {
    .app-wrapper { display: flex !important; flex-direction: column !important; padding: 10px !important; padding-bottom: 80px !important; gap: 15px !important; }
    .sidebar, .right-panel { display: none !important; }
    .dashboards { grid-template-columns: 1fr; gap: 15px; }
    .card { padding: 16px; border-radius: 16px; margin-bottom: 0; }
    
    .mobile-only-btn { display: flex !important; } /* Показываем иконки на мобильных */

    .hero-card { padding: 18px 16px; margin-bottom: 10px !important; }
    .btn-logout-top { top: 12px; right: 12px; width: 30px; height: 30px; font-size: 13px; }
    .mobile-logo { display: inline-block; margin: 0 8px 0 0; text-align: left; font-size: 24px; vertical-align: middle; }
    .hero-top { display: inline; margin: 0; }
    .hero-title { display: inline-block; font-size: 14px; text-align: left; font-weight: 600; opacity: 0.9; margin: 0; vertical-align: middle; }
    
    /* Уплотняем иконки, чтобы влезли в 1 ряд */
    .hero-actions { display: flex; width: 100%; justify-content: center; align-items: center; gap: 6px; margin-top: 12px; }
    .badge { font-size: 11px; padding: 4px 8px; }
    .icon-btn { width: 30px; height: 30px; font-size: 13px; }
    
    .panel-heading { font-size: 15px; margin-bottom: 12px; text-align: center; }
    .stat-header { font-size: 12px; }
    
    .mobile-nav {
        display: flex; position: fixed; bottom: 0; left: 0; right: 0;
        background: var(--card); border-top: 1px solid var(--border);
        padding: 8px 5px; padding-bottom: env(safe-area-inset-bottom, 8px);
        justify-content: space-around; z-index: 1000; height: 65px; box-sizing: border-box;
    }
    .mobile-nav .menu-item {
        flex-direction: column; padding: 4px; font-size: 10px; gap: 4px; border-radius: 10px;
        text-align: center; justify-content: center; background: transparent; color: var(--muted); height: 100%; width: 100%;
    }
    .mobile-nav .menu-item.active { color: var(--primary); font-weight: 800; background: transparent; box-shadow: none;}
}