/* Maybe Lite Finance - ПОЛНАЯ МОБИЛЬНАЯ АДАПТАЦИЯ */

/* ==================== ДО 768px ==================== */
@media (max-width: 768px) {
    :root {
        --radius: 12px;
        --radius-sm: 10px;
    }
    
    body {
        font-size: 14px;
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }
    
    .app {
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    /* Сайдбар */
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
        width: 85%;
        max-width: 300px;
        z-index: 1000;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-header {
        padding: 20px 16px;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 12px !important;
        padding-top: 70px !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
    
    .menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 12px;
        left: 12px;
        z-index: 200;
        background: white;
        border: 1px solid var(--gray-200);
        border-radius: 12px;
        width: 48px;
        height: 48px;
        font-size: 24px;
        cursor: pointer;
        box-shadow: var(--shadow);
    }
    
    /* Заголовки */
    .page-header {
        margin-bottom: 20px;
        padding-left: 48px;
        width: 100%;
    }
    
    .page-header h1 {
        font-size: 22px;
        word-break: break-word;
    }
    
    .page-subtitle {
        font-size: 13px;
    }
    
    /* Статистика */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
        margin-bottom: 20px;
        width: 100%;
    }
    
    .stat-card {
        padding: 18px;
    }
    
    .stat-value {
        font-size: 28px;
    }
    
    /* Дашборд */
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 16px;
        width: 100%;
    }
    
    /* Карточки */
    .card {
        border-radius: var(--radius);
        width: 100%;
        max-width: 100%;
    }
    
    .card-header {
        padding: 16px;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .card-header h3 {
        font-size: 16px;
    }
    
    .card-body {
        padding: 16px;
        width: 100%;
        overflow-x: visible;
    }
    
    /* ==================== ТАБЛИЦЫ -> КАРТОЧКИ ==================== */
    .table-wrapper {
        overflow-x: visible;
    }
    
    /* Скрываем обычную таблицу */
    .table {
        display: none !important;
    }
    
    /* Показываем карточки */
    .mobile-cards {
        display: block !important;
        width: 100%;
    }
    
    .transaction-cards {
        display: flex !important;
        flex-direction: column;
        gap: 12px;
        width: 100%;
    }
    
    .transaction-card {
        background: white;
        border-radius: 16px;
        padding: 16px;
        border: 1px solid var(--gray-200);
        box-shadow: var(--shadow-sm);
        width: 100%;
    }
    
    .transaction-card.income {
        border-left: 4px solid var(--success);
    }
    
    .transaction-card.expense {
        border-left: 4px solid var(--danger);
    }
    
    .transaction-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 12px;
    }
    
    .transaction-date {
        font-size: 13px;
        color: var(--gray-600);
        font-weight: 500;
    }
    
    .transaction-amount {
        font-size: 20px;
        font-weight: 700;
    }
    
    .transaction-amount.income {
        color: var(--success);
    }
    
    .transaction-amount.expense {
        color: var(--danger);
    }
    
    .transaction-details {
        display: flex;
        flex-direction: column;
        gap: 8px;
        margin-bottom: 12px;
    }
    
    .transaction-detail-row {
        display: flex;
        align-items: center;
        gap: 12px;
    }
    
    .transaction-detail-label {
        width: 80px;
        font-size: 12px;
        color: var(--gray-600);
        text-transform: uppercase;
        letter-spacing: 0.3px;
        flex-shrink: 0;
    }
    
    .transaction-detail-value {
        flex: 1;
        font-size: 14px;
        font-weight: 500;
        word-break: break-word;
    }
    
    .transaction-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-top: 12px;
        border-top: 1px solid var(--gray-100);
    }
    
    .transaction-user {
        font-size: 12px;
        color: var(--gray-600);
    }
    
    .transaction-delete {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    /* Карточки для счетов */
    .account-cards {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    
    .account-card {
        background: white;
        border-radius: 16px;
        padding: 16px;
        border: 1px solid var(--gray-200);
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .account-info h4 {
        font-size: 16px;
        margin-bottom: 4px;
    }
    
    .account-type {
        font-size: 12px;
        color: var(--gray-600);
    }
    
    .account-balance {
        font-size: 20px;
        font-weight: 700;
        text-align: right;
    }
    
    /* ==================== ФОРМЫ ==================== */
    .form-grid {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    
    .form-stack {
        gap: 10px;
        width: 100%;
    }
    
    .form-control {
        padding: 14px 16px;
        font-size: 16px;
        border-radius: var(--radius-sm);
        width: 100%;
    }
    
    /* Кнопки */
    .btn {
        padding: 14px 20px;
        font-size: 15px;
        width: 100%;
        justify-content: center;
        border-radius: var(--radius-sm);
        white-space: normal;
        word-break: break-word;
    }
    
    .card-header .btn {
        width: auto;
        padding: 10px 16px;
    }
    
    /* ==================== ЦЕЛИ ==================== */
    .goals-grid {
        grid-template-columns: 1fr !important;
        gap: 16px;
        margin-top: 16px;
        width: 100%;
    }
    
    .goal-card {
        padding: 20px;
        width: 100%;
    }
    
    .goal-header {
        flex-direction: column;
        gap: 12px;
    }
    
    .goal-title {
        width: 100%;
    }
    
    .goal-actions {
        align-self: flex-end;
    }
    
    .goal-add {
        flex-direction: column;
        gap: 10px;
    }
    
    .goal-add .form-control {
        width: 100%;
    }
    
    /* ==================== БЮДЖЕТЫ ==================== */
    .budgets-grid {
        grid-template-columns: 1fr !important;
        gap: 16px;
        width: 100%;
    }
    
    .budget-card {
        padding: 20px;
        width: 100%;
    }
    
    /* ==================== СЕМЬЯ ==================== */
    .family-grid {
        grid-template-columns: 1fr !important;
        gap: 20px;
        width: 100%;
    }
    
    /* Карточки участников */
    .member-cards {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    
    .member-card {
        background: white;
        border-radius: 16px;
        padding: 16px;
        border: 1px solid var(--gray-200);
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .member-info h4 {
        font-size: 16px;
        margin-bottom: 4px;
    }
    
    .member-email {
        font-size: 12px;
        color: var(--gray-600);
    }
    
    /* ==================== МОДАЛЬНЫЕ ОКНА ==================== */
    .modal {
        align-items: flex-end;
    }
    
    .modal.active {
        display: flex;
    }
    
    .modal-content {
        margin: 0;
        padding: 24px 20px;
        width: 100%;
        max-width: 100%;
        border-radius: 24px 24px 0 0;
        max-height: 90vh;
        animation: slideUp 0.3s ease-out;
    }
    
    @keyframes slideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
    
    .modal-header {
        margin-bottom: 20px;
    }
    
    .modal-header h2 {
        font-size: 20px;
    }
    
    .modal-close {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }
    
    /* ==================== АВТОРИЗАЦИЯ ==================== */
    .auth-container {
        padding: 16px;
        align-items: flex-start;
        padding-top: 40px;
    }
    
    .auth-card {
        padding: 28px 20px;
        border-radius: 28px;
        width: 100%;
    }
    
    .auth-header .logo {
        font-size: 40px;
    }
    
    .auth-header h1 {
        font-size: 24px;
    }
    
    /* ==================== ЭКРАН ПРИВЕТСТВИЯ ==================== */
    .welcome-card {
        padding: 32px 20px;
        width: 100%;
    }
    
    .welcome-options {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }
    
    /* ==================== УТИЛИТЫ ==================== */
    .hide-on-mobile {
        display: none !important;
    }
    
    /* Предотвращение горизонтального скролла */
    html, body {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }
    
    * {
        max-width: 100%;
    }
}

/* ==================== ДО 480px ==================== */
@media (max-width: 480px) {
    .main-content {
        padding: 8px !important;
        padding-top: 65px !important;
    }
    
    .menu-toggle {
        width: 44px;
        height: 44px;
        top: 10px;
        left: 10px;
    }
    
    .page-header {
        padding-left: 44px;
    }
    
    .page-header h1 {
        font-size: 20px;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .stat-label {
        font-size: 12px;
    }
    
    .stat-value {
        font-size: 24px;
    }
    
    .card-header {
        padding: 14px;
    }
    
    .card-body {
        padding: 14px;
    }
    
    .transaction-card {
        padding: 14px;
    }
    
    .transaction-amount {
        font-size: 18px;
    }
    
    .transaction-detail-label {
        width: 70px;
        font-size: 11px;
    }
    
    .transaction-detail-value {
        font-size: 13px;
    }
    
    .btn {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .form-control {
        padding: 12px 14px;
    }
    
    .goal-card {
        padding: 16px;
    }
    
    .goal-icon {
        font-size: 24px;
    }
    
    .goal-name {
        font-size: 16px;
    }
    
    .progress-bar {
        height: 6px;
    }
    
    .modal-content {
        padding: 20px 16px;
    }
}

/* ==================== ПЛАНШЕТЫ (769px - 1024px) ==================== */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
    
    .main-content {
        margin-left: 240px !important;
        padding: 24px !important;
        width: calc(100% - 240px) !important;
    }
    
    .stats-grid {
        gap: 16px;
    }
    
    .stat-value {
        font-size: 28px;
    }
    
    .goals-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .budgets-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .form-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* На планшетах показываем таблицы */
    .table {
        display: table !important;
    }
    
    .mobile-cards {
        display: none !important;
    }
    
    .transaction-cards {
        display: none !important;
    }
}

/* ==================== ДЕСКТОП (> 1024px) ==================== */
@media (min-width: 1025px) {
    /* На десктопе показываем таблицы */
    .table {
        display: table !important;
    }
    
    .mobile-cards {
        display: none !important;
    }
    
    .transaction-cards {
        display: none !important;
    }
}

/* ==================== ФИКС ДЛЯ iOS ==================== */
@supports (-webkit-touch-callout: none) {
    input, select, textarea, button {
        font-size: 16px !important;
    }
    
    .form-control {
        font-size: 16px !important;
    }
}

/* ==================== ГЛОБАЛЬНЫЙ СБРОС ПЕРЕПОЛНЕНИЯ ==================== */
* {
    box-sizing: border-box;
}

img, svg, video, canvas, audio, iframe, embed, object {
    max-width: 100%;
    height: auto;
}

table, .table-wrapper {
    max-width: 100%;
}