/* public_html/css/style.css - Исправленная для мобильных */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    height: 100dvh; /* Динамическая высота для мобильных */
    overflow: hidden; /* Убираем скролл страницы */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: #f0f2f5;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    width: 100%;
    max-width: 480px;
    height: 100%; /* Наследует высоту от body */
    margin: 0 auto;
}

.chat-wrapper {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* ============================================
   HEADER
   ============================================ */

.chat-header {
    padding: 16px 20px;
    background: #2a5a3a;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    padding: 4px;
}

.chat-header-info {
    flex: 1;
}

.chat-header-info h3 {
    font-size: 18px;
    font-weight: 700;
}

.chat-header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.8;
}

.online-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.header-actions button,
.profile-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.header-actions button:hover,
.profile-btn:hover {
    background: rgba(255,255,255,0.25);
}

/* ============================================
   MESSAGES
   ============================================ */

.chat-messages {
    flex: 1;
    padding: 16px 20px;
    overflow-y: auto;
    background: #f8faf8;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    display: flex;
    gap: 10px;
    max-width: 90%;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.ai {
    align-self: flex-start;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #e8ece8;
    object-fit: cover;
}

.message-content {
    background: white;
    padding: 12px 16px;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: break-word;
}

.message.user .message-content {
    background: #2a5a3a;
    color: white;
}

.message.user .message-content strong {
    color: #ffd700;
}

.message-content div {
    font-size: 14px;
    line-height: 1.6;
}

.message-content h3 {
    font-size: 16px;
    font-weight: 700;
    color: #1a3a2a;
    margin: 12px 0 8px 0;
    border-bottom: 2px solid #c9a84c;
    padding-bottom: 6px;
}

.message-content h4 {
    font-size: 14px;
    font-weight: 700;
    color: #1a3a2a;
    margin: 12px 0 6px 0;
}

.message-content li {
    margin: 4px 0;
    list-style: none;
    padding-left: 4px;
}

.message-content blockquote {
    background: #f0f7f0;
    padding: 10px 14px;
    border-radius: 8px;
    border-left: 3px solid #2a5a3a;
    margin: 8px 0;
}

.message-content hr {
    border: none;
    border-top: 2px dashed #e8ecf1;
    margin: 12px 0;
}

.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
}

.message-content table th {
    background: #2a5a3a;
    color: white;
    padding: 8px 10px;
    text-align: left;
    border: 1px solid #ddd;
}

.message-content table td {
    padding: 8px 10px;
    border: 1px solid #ddd;
}

.message-content table tr:nth-child(even) {
    background: #f9f9f9;
}

.message-content strong {
    color: #0b2a44;
}

.message.user .message-content strong {
    color: #ffd700;
}

.message-time {
    font-size: 10px;
    color: #8a9a8a;
    margin-top: 4px;
    text-align: right;
}

.message.user .message-time {
    color: rgba(255,255,255,0.6);
}

/* ============================================
   WELCOME MESSAGE
   ============================================ */

.welcome-message .message-content {
    background: linear-gradient(135deg, #f0f7f0 0%, #e8f0e8 100%);
    border: 2px solid #2a5a3a;
}

.welcome-message .message-content strong {
    color: #1a5a3a;
}

.welcome-message .message-content li {
    list-style: none;
    padding: 2px 0;
}

.welcome-message .message-content li::before {
    content: "• ";
    color: #2a5a3a;
    font-weight: bold;
}

/* ============================================
   TYPING INDICATOR
   ============================================ */

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #2a5a3a;
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ============================================
   INPUT
   ============================================ */

.chat-input-area {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e8ece8;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

#userInput {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e8ece8;
    border-radius: 20px;
    resize: none;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    max-height: 150px;
    outline: none;
    transition: border-color 0.2s;
}

#userInput:focus {
    border-color: #2a5a3a;
}

.chat-input-area button {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-btn {
    background: #f0f2f5;
    color: #2a5a3a;
}

.voice-btn:hover {
    background: #e0e5e0;
}

.voice-btn.listening {
    background: #dc3545;
    color: white;
    animation: pulse-voice 1s infinite;
}

@keyframes pulse-voice {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.send-btn {
    background: #2a5a3a;
    color: white;
}

.send-btn:hover {
    background: #1a3a2a;
}

/* ============================================
   FOOTER
   ============================================ */

.chat-footer {
    padding: 8px 16px;
    background: #f8faf8;
    border-top: 1px solid #e8ece8;
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #8a9a8a;
    flex-shrink: 0;
}

.footer-info {
    display: flex;
    gap: 12px;
}

.footer-dev a {
    color: #2a5a3a;
    text-decoration: none;
}

.footer-dev a:hover {
    text-decoration: underline;
}

/* ============================================
   BUDGET ADVICE
   ============================================ */

.budget-advice {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 440px;
    width: 90%;
    background: #1a3a2a;
    color: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.25);
    animation: adviceSlide 0.4s ease;
    z-index: 1000;
}

@keyframes adviceSlide {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.advice-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.advice-icon {
    font-size: 20px;
}

.advice-text {
    flex: 1;
    font-size: 13px;
    line-height: 1.4;
}

.advice-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
}

/* ============================================
   REMINDER STATUS
   ============================================ */

.reminder-status {
    position: fixed;
    bottom: 100px;
    right: 20px;
    background: #2a5a3a;
    color: white;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    animation: adviceSlide 0.4s ease;
    z-index: 999;
}

.reminder-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 480px) {
    .app-container {
        max-height: 100dvh; /* Исправлено */
    }
    .chat-wrapper {
        border-radius: 0;
    }
}

@media (max-width: 360px) {
    .message-content {
        font-size: 13px;
    }
    .chat-header-info h3 {
        font-size: 16px;
    }
}

/* ============================================
   SCROLLBAR
   ============================================ */

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f0f2f5;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #2a5a3a;
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #1a3a2a;
}

/* ============================================
   ЦВЕТА ДЛЯ КАТЕГОРИЙ РАСХОДОВ
   ============================================ */

.message-content .category-product {
    border-left: 4px solid #28a745;
    padding-left: 10px;
}

.message-content .category-utility {
    border-left: 4px solid #007bff;
    padding-left: 10px;
}

.message-content .category-medicine {
    border-left: 4px solid #dc3545;
    padding-left: 10px;
}

.message-content .category-transport {
    border-left: 4px solid #ffc107;
    padding-left: 10px;
}

.message-content .category-entertainment {
    border-left: 4px solid #17a2b8;
    padding-left: 10px;
}

.message-content .category-fixed {
    border-left: 4px solid #6c757d;
    padding-left: 10px;
}

.message-content .category-other {
    border-left: 4px solid #6c757d;
    padding-left: 10px;
}

/* ============================================
   ЦВЕТА ДЛЯ ПРОГНОЗА БЮДЖЕТА
   ============================================ */

.budget-warning {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 10px 14px;
    border-radius: 8px;
    margin: 8px 0;
}

.budget-danger {
    background: #f8d7da;
    border-left: 4px solid #dc3545;
    padding: 10px 14px;
    border-radius: 8px;
    margin: 8px 0;
}

.budget-success {
    background: #d4edda;
    border-left: 4px solid #28a745;
    padding: 10px 14px;
    border-radius: 8px;
    margin: 8px 0;
}

.projection-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 12px 16px;
    margin: 8px 0;
}

.projection-card .number {
    font-size: 20px;
    font-weight: 700;
    color: #2a5a3a;
}

.projection-card .label {
    font-size: 12px;
    color: #8a9a8a;
}

/* ============================================
   ВЫПАДАЮЩИЙ СПИСОК МЕСЯЦЕВ
   ============================================ */

.chat-header-month {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.1);
    padding: 4px 12px 4px 16px;
    border-radius: 20px;
    flex-shrink: 0;
}

.month-select {
    background: transparent;
    color: white;
    border: none;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 4px 4px 0;
    cursor: pointer;
    outline: none;
    font-family: inherit;
    max-width: 120px;
}

.month-select option {
    background: #2a5a3a;
    color: white;
    padding: 4px 8px;
}

.month-stats {
    font-size: 10px;
    opacity: 0.7;
    display: flex;
    gap: 10px;
    white-space: nowrap;
    color: rgba(255,255,255,0.8);
}

@media (max-width: 480px) {
    .chat-header-month {
        padding: 4px 8px 4px 12px;
        gap: 4px;
    }
    .month-select {
        font-size: 11px;
        max-width: 90px;
    }
    .month-stats {
        font-size: 9px;
        gap: 6px;
    }
}

/* ============================================
   НОВАЯ СТРУКТУРА ШАПКИ
   ============================================ */

/* Строка 1: Аватар + имя + статус + кнопки */
.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: #2a5a3a;
    color: white;
    flex-shrink: 0;
}

.header-actions-top {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.header-actions-top button,
.header-actions-top a {
    background: rgba(255,255,255,0.12);
    border: none;
    color: white;
    padding: 4px 10px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: inherit;
    text-decoration: none;
    height: 28px;
    white-space: nowrap;
}

.header-actions-top button:hover,
.header-actions-top a:hover {
    background: rgba(255,255,255,0.25);
}

.header-actions-top .btn-label {
    font-size: 10px;
    opacity: 0.8;
}

.header-actions-top .clear-btn:hover {
    background: rgba(220, 53, 69, 0.4);
}

.header-actions-top .push-toggle.active {
    background: rgba(74, 222, 128, 0.3);
}

/* Строка 2: Выбор месяца + статистика */
.chat-header-month-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 16px 8px 16px;
    background: #2a5a3a;
    color: white;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.month-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.month-label {
    font-size: 16px;
}

.month-select {
    background: rgba(255,255,255,0.12);
    color: white;
    border: none;
    font-size: 14px;
    font-weight: 600;
    padding: 4px 12px 4px 8px;
    border-radius: 16px;
    cursor: pointer;
    outline: none;
    font-family: inherit;
    min-width: 120px;
}

.month-select option {
    background: #2a5a3a;
    color: white;
}

.month-stats {
    font-size: 11px;
    opacity: 0.8;
    display: flex;
    gap: 12px;
}

/* Адаптив для телефонов */
@media (max-width: 480px) {
    .chat-header {
        padding: 6px 12px;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .chat-header-info h3 {
        font-size: 15px;
    }
    
    .chat-header-info .chat-header-status {
        font-size: 10px;
    }
    
    .header-actions-top {
        gap: 2px;
    }
    
    .header-actions-top button,
    .header-actions-top a {
        padding: 2px 6px;
        font-size: 10px;
        height: 24px;
        gap: 2px;
    }
    
    .header-actions-top .btn-label {
        font-size: 8px;
    }
    
    .chat-header-month-row {
        padding: 2px 12px 6px 12px;
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .month-select {
        font-size: 12px;
        min-width: 100px;
        padding: 2px 8px 2px 6px;
    }
    
    .month-stats {
        font-size: 10px;
        gap: 8px;
    }
}

@media (max-width: 360px) {
    .month-select {
        min-width: 80px;
        font-size: 11px;
    }
    
    .month-stats {
        font-size: 9px;
        gap: 6px;
    }
    
    .header-actions-top button,
    .header-actions-top a {
        padding: 2px 4px;
        font-size: 9px;
        height: 20px;
    }
    
    .header-actions-top .btn-label {
        font-size: 7px;
    }
}

.real-time-clock {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    margin-left: 8px;
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

