/**
 * HARMONIIE BANKING - MOBILE ADAPTATION
 * Мобильная адаптация для приложения онлайн-банкинга
 * Дизайн: современный, чистый, как нативное приложение
 */

/* ===================================
   GLOBAL MOBILE FIX - NO HORIZONTAL SCROLL
   =================================== */

@media (max-width: 768px) {
    /* Убираем горизонтальную прокрутку */
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        position: relative !important;
    }
    
    * {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Контейнеры */
    #loginPage,
    #dashboardPage,
    .main-content,
    .container {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        width: 100% !important;
    }
}

/* ===================================
   MOBILE LOGIN PAGE
   =================================== */

@media (max-width: 768px) {
    /* Скрыть левую панель на мобильных */
    #login-left {
        display: none !important;
    }
    
    /* Правая часть на всю ширину */
    #login-right {
        width: 100% !important;
        padding: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        min-height: 100vh !important;
    }
    
    /* Мобильный хедер логина */
    /* Убираем старый логотип и переключатель */
    .mobile-login-logo,
    .language-switcher {
        display: none !important;
    }
    
    /* Новый переключатель языков внутри формы - стильный дизайн */
    .language-switcher-inline {
        display: flex;
        justify-content: flex-end;
        gap: 0.5rem;
        margin-bottom: 2rem;
        padding: 0;
    }
    
    .lang-btn-inline {
        position: relative;
        padding: 0.625rem 1.25rem;
        border: none;
        border-radius: 12px;
        background: linear-gradient(135deg, #e0f2fe 0%, #f0f9ff 100%);
        color: #0284c7;
        font-size: 0.875rem;
        font-weight: 700;
        cursor: pointer;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        letter-spacing: 0.5px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        overflow: hidden;
    }
    
    /* Красивый эффект при наведении */
    .lang-btn-inline::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
        transition: left 0.5s;
    }
    
    .lang-btn-inline:hover::before {
        left: 100%;
    }
    
    .lang-btn-inline:hover:not(.active) {
        background: linear-gradient(135deg, #bfdbfe 0%, #dbeafe 100%);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(14, 165, 233, 0.2);
    }
    
    /* Активная кнопка - синий градиент банка */
    .lang-btn-inline.active {
        background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
        color: white;
        box-shadow: 0 4px 16px rgba(14, 165, 233, 0.4);
        transform: translateY(-1px);
    }
    
    .lang-btn-inline.active::after {
        content: '';
        position: absolute;
        bottom: -2px;
        left: 50%;
        transform: translateX(-50%);
        width: 80%;
        height: 3px;
        background: rgba(255, 255, 255, 0.5);
        border-radius: 2px;
    }
    
    /* Пульсация активной кнопки */
    @keyframes pulse-glow {
        0%, 100% {
            box-shadow: 0 4px 16px rgba(14, 165, 233, 0.4);
        }
        50% {
            box-shadow: 0 6px 24px rgba(14, 165, 233, 0.6);
        }
    }
    
    .lang-btn-inline.active {
        animation: pulse-glow 2s ease-in-out infinite;
    }
    
    /* Контейнер формы логина */
    .mobile-login-form-container {
        padding: 2rem 1.5rem 2.5rem;
        flex: 1;
        display: flex;
        flex-direction: column;
        background: white;
    }
    
    .mobile-login-form-container h2 {
        font-size: 1.75rem;
        font-weight: 700;
        color: #1f2937;
        margin-bottom: 0.75rem;
    }
    
    .mobile-login-form-container .subtitle {
        color: #6b7280;
        font-size: 1rem;
        margin-bottom: 2.5rem;
        line-height: 1.5;
    }
    
    /* Поля ввода */
    .mobile-login-form-container .form-group {
        margin-bottom: 1.5rem;
    }
    
    .mobile-login-form-container .form-label {
        display: flex;
        align-items: center;
        font-weight: 600;
        color: #374151;
        margin-bottom: 0.5rem;
        font-size: 0.95rem;
    }
    
    .mobile-login-form-container .form-label i {
        margin-right: 8px;
        color: #0ea5e9;
    }
    
    .mobile-login-form-container .form-input {
        width: 100%;
        padding: 16px 18px;
        font-size: 1rem;
        border: 2px solid #e5e7eb;
        border-radius: 14px;
        transition: all 0.3s ease;
        background: white;
    }
    
    .mobile-login-form-container .form-input:focus {
        outline: none;
        border-color: #0ea5e9;
        background: white;
        box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.1);
    }
    
    /* Кнопки */
    .mobile-login-btn {
        width: 100%;
        padding: 18px;
        font-size: 1.1rem;
        font-weight: 700;
        border-radius: 14px;
        border: none;
        cursor: pointer;
        transition: all 0.3s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        margin-bottom: 1rem;
    }
    
    .mobile-login-btn-primary {
        background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
        color: white;
        box-shadow: 0 6px 20px rgba(14, 165, 233, 0.4);
    }
    
    .mobile-login-btn-primary:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 24px rgba(14, 165, 233, 0.5);
    }
    
    .mobile-login-btn-secondary {
        background: white;
        color: #0ea5e9;
        border: 2px solid #0ea5e9;
    }
    
    .mobile-login-btn-secondary:hover {
        background: #f0fdf4;
    }
    
    /* Текст "Нет аккаунта?" */
    .mobile-login-footer {
        text-align: center;
        color: #6b7280;
        font-size: 0.9rem;
        margin-top: auto;
        padding-top: 2rem;
    }
    

}

/* ===================================
   MOBILE DASHBOARD & NAVIGATION
   =================================== */

@media (max-width: 768px) {
    /* Мобильный хедер (ПОВЕРХ ВСЕГО) */
    .mobile-header {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        background: transparent !important;
        padding: 1rem 1.25rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        z-index: 9997 !important; /* Ниже sidebar, но выше контента */
        pointer-events: none !important; /* Не блокирует клики на странице */
    }
    
    /* Бургер кнопка (АКТИВНАЯ ЗОНА) */
    .mobile-burger {
        width: 54px !important;
        height: 54px !important;
        background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%) !important;
        border: none !important;
        border-radius: 16px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        box-shadow: 0 6px 20px rgba(14, 165, 233, 0.5) !important;
        transition: all 0.3s ease !important;
        pointer-events: auto !important; /* Кнопка кликабельна */
    }
    
    .mobile-burger:hover {
        transform: scale(1.05) !important;
        box-shadow: 0 8px 24px rgba(14, 165, 233, 0.6) !important;
    }
    
    .mobile-burger:active {
        transform: scale(0.95) !important;
        background: linear-gradient(135deg, #0284c7 0%, #0891b2 100%) !important;
    }
    
    .mobile-burger i {
        color: white !important;
        font-size: 1.5rem !important;
    }
    
    /* Боковое меню (ПОВЕРХ ВСЕГО!) */
    .mobile-sidebar {
        position: fixed !important;
        top: 0 !important;
        left: -100% !important;
        width: 85% !important;
        max-width: 350px !important;
        height: 100vh !important;
        height: 100dvh !important; /* Dynamic viewport height для мобильных */
        background: white !important;
        z-index: 9999 !important; /* МАКСИМАЛЬНЫЙ приоритет */
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        box-shadow: 8px 0 24px rgba(0, 0, 0, 0.2) !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }
    
    .mobile-sidebar.open {
        left: 0 !important;
    }
    
    /* Оверлей (затемнение фона) */
    .mobile-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        background: rgba(0, 0, 0, 0.6) !important;
        z-index: 9998 !important; /* Чуть ниже sidebar */
        display: none !important;
        opacity: 0 !important;
        transition: opacity 0.3s ease !important;
        backdrop-filter: blur(2px) !important;
    }
    
    .mobile-overlay.active {
        display: block !important;
        opacity: 1 !important;
    }
    
    /* Профиль в меню (ФИКСИРОВАН ВВЕРХУ - НЕ ПРОКРУЧИВАЕТСЯ) */
    .mobile-sidebar-profile {
        background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
        padding: 1.5rem;
        color: white;
        display: flex;
        flex-direction: column;
        gap: 1rem;
        box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
        flex-shrink: 0; /* НЕ сжимается */
    }
    
    .mobile-sidebar-profile-header {
        display: flex;
        align-items: center;
        gap: 1rem;
    }
    
    .mobile-sidebar-profile-avatar {
        width: 56px;
        height: 56px;
        background: rgba(255, 255, 255, 0.2);
        border: 3px solid rgba(255, 255, 255, 0.3);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.75rem;
        color: white;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        flex-shrink: 0;
    }
    
    .mobile-sidebar-profile-info {
        flex: 1;
        min-width: 0;
    }
    
    .mobile-sidebar-profile-info h3 {
        font-size: 1rem;
        font-weight: 700;
        margin: 0 0 0.25rem;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .mobile-sidebar-profile-info p {
        font-size: 0.8rem;
        margin: 0;
        opacity: 0.9;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Кнопка смены пароля В ПРОФИЛЕ */
    .mobile-sidebar-change-password-btn {
        width: 100%;
        padding: 0.875rem 1.25rem;
        margin-top: 0.75rem;
        background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
        color: white;
        border: none;
        border-radius: 12px;
        font-weight: 600;
        font-size: 0.9375rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.625rem;
        transition: all 0.3s ease;
        box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
    }
    
    .mobile-sidebar-change-password-btn:hover {
        background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(14, 165, 233, 0.4);
    }
    
    .mobile-sidebar-change-password-btn:active {
        transform: translateY(0) scale(0.98);
    }
    
    .mobile-sidebar-change-password-btn i {
        font-size: 1.1rem;
    }
    
    /* Кнопка выхода В ПРОФИЛЕ */
    .mobile-sidebar-logout-btn {
        width: 100%;
        padding: 0.75rem 1rem;
        background: rgba(239, 68, 68, 0.9);
        color: white;
        border: none;
        border-radius: 10px;
        font-weight: 600;
        font-size: 0.95rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        transition: all 0.3s ease;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }
    
    .mobile-sidebar-logout-btn:hover {
        background: rgba(220, 38, 38, 0.9);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
    
    .mobile-sidebar-logout-btn:active {
        transform: translateY(0) scale(0.98);
    }
    
    .mobile-sidebar-logout-btn i {
        font-size: 1.1rem;
    }
    
    /* Навигация в меню */
    .mobile-sidebar-nav {
        flex: 1;
        overflow-y: auto;
        padding: 1rem 0;
    }
    
    .mobile-sidebar-nav-item {
        display: flex;
        align-items: center;
        gap: 1rem;
        padding: 1rem 1.5rem;
        color: #1f2937;
        text-decoration: none;
        transition: all 0.3s ease;
        font-weight: 500;
        border-left: 4px solid transparent;
        font-size: 1rem;
    }
    
    .mobile-sidebar-nav-item:hover,
    .mobile-sidebar-nav-item:active,
    .mobile-sidebar-nav-item.active {
        background: linear-gradient(90deg, rgba(14, 165, 233, 0.1) 0%, rgba(6, 182, 212, 0.05) 100%);
        border-left-color: #0ea5e9;
        color: #0284c7;
        transform: translateX(4px);
    }
    
    .mobile-sidebar-nav-item i {
        font-size: 1.25rem;
        width: 28px;
        text-align: center;
        color: #0ea5e9;
    }
    
    /* Контент дашборда */
    #dashboardPage .mobile-dashboard-content {
        margin-top: 70px;
        padding: 1.25rem;
        padding-bottom: 5rem;
    }
    
    /* Скрыть десктопную навигацию */
    /* Скрыть десктопную навигацию и дублирующиеся кнопки */
    .sidebar,
    .desktop-nav,
    .nav-tabs,
    .main-nav,
    .section-nav,
    .dashboard-nav,
    .top-nav {
        display: none !important;
    }
    
    /* Компактные карточки счетов */
    .mobile-account-card {
        background: white;
        border-radius: 16px;
        padding: 1.25rem;
        margin-bottom: 1rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        border-left: 4px solid #0ea5e9;
        transition: all 0.3s ease;
    }
    
    .mobile-account-card:active {
        transform: scale(0.98);
    }
    
    .mobile-account-card-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 1rem;
    }
    
    .mobile-account-card-type {
        font-size: 0.85rem;
        font-weight: 600;
        color: #6b7280;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .mobile-account-card-status {
        font-size: 0.75rem;
        padding: 0.25rem 0.75rem;
        border-radius: 12px;
        background: #d1fae5;
        color: #0ea5e9;
        font-weight: 600;
    }
    
    .mobile-account-card-balance {
        font-size: 2rem;
        font-weight: 800;
        color: #1f2937;
        margin-bottom: 0.5rem;
    }
    
    .mobile-account-card-number {
        font-size: 0.9rem;
        color: #6b7280;
        font-family: 'Courier New', monospace;
        letter-spacing: 1px;
    }
    
    /* Кнопки действий */
    .mobile-action-buttons {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        margin-top: 1.5rem;
    }
    
    .mobile-action-btn {
        padding: 1rem;
        border-radius: 12px;
        border: 2px solid #e5e7eb;
        background: white;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    
    .mobile-action-btn:active {
        background: #f9fafb;
        transform: scale(0.96);
    }
    
    .mobile-action-btn i {
        font-size: 1.5rem;
        color: #0ea5e9;
    }
    
    .mobile-action-btn span {
        font-size: 0.875rem;
        font-weight: 600;
        color: #374151;
    }
    
    /* Список транзакций - компактный */
    .mobile-transactions {
        background: white;
        border-radius: 16px;
        padding: 1.25rem;
        margin-top: 1.5rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }
    
    .mobile-transactions h3 {
        font-size: 1.25rem;
        font-weight: 700;
        margin-bottom: 1rem;
        color: #1f2937;
    }
    
    .mobile-transaction-item {
        display: flex;
        align-items: center;
        gap: 1rem;
        padding: 0.875rem 0;
        border-bottom: 1px solid #f3f4f6;
    }
    
    .mobile-transaction-item:last-child {
        border-bottom: none;
    }
    
    .mobile-transaction-icon {
        width: 50px;
        height: 50px;
        border-radius: 14px;
        background: #f0fdf4;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #0ea5e9;
        font-size: 1.1rem;
    }
    
    .mobile-transaction-details {
        flex: 1;
    }
    
    .mobile-transaction-title {
        font-weight: 600;
        color: #1f2937;
        font-size: 0.95rem;
        margin-bottom: 0.15rem;
    }
    
    .mobile-transaction-date {
        font-size: 0.8rem;
        color: #9ca3af;
    }
    
    .mobile-transaction-amount {
        font-weight: 700;
        font-size: 1.05rem;
    }
    
    .mobile-transaction-amount.positive {
        color: #0ea5e9;
    }
    
    .mobile-transaction-amount.negative {
        color: #ef4444;
    }
}

/* ===================================
   MOBILE UTILITIES
   =================================== */

@media (max-width: 768px) {
    /* Скрыть элементы для desktop */
    .hide-on-mobile {
        display: none !important;
    }
    
    /* Отступы для мобильных */
    .mobile-mt-1 { margin-top: 0.5rem; }
    .mobile-mt-2 { margin-top: 1rem; }
    .mobile-mt-3 { margin-top: 1.5rem; }
    .mobile-mt-4 { margin-top: 2rem; }
    
    .mobile-mb-1 { margin-bottom: 0.5rem; }
    .mobile-mb-2 { margin-bottom: 1rem; }
    .mobile-mb-3 { margin-bottom: 1.5rem; }
    .mobile-mb-4 { margin-bottom: 2rem; }
    
    /* Текст для мобильных */
    .mobile-text-sm { font-size: 0.875rem; }
    .mobile-text-base { font-size: 1rem; }
    .mobile-text-lg { font-size: 1.125rem; }
    .mobile-text-xl { font-size: 1.25rem; }
    
    /* Адаптивная сетка */
    .mobile-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Тени для мобильных */
    .mobile-shadow {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }
    
    /* Безопасная зона для iPhone */
    .mobile-safe-area-top {
        padding-top: env(safe-area-inset-top);
    }
    
    .mobile-safe-area-bottom {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ===================================
   ANIMATIONS
   =================================== */

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Плавное появление элементов */
.mobile-fade-in {
    animation: fadeIn 0.3s ease;
}

.mobile-slide-in {
    animation: slideInRight 0.3s ease;
}
