/* Mobile-specific styles for Kośa Expense Tracker */

/* ===== PULL TO REFRESH ===== */
.ptr-indicator {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%) translateY(-60px);
    width: 40px;
    height: 40px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s ease;
    z-index: 90;
    opacity: 0;
}

.ptr-indicator.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(10px);
}

.ptr-indicator.refreshing {
    animation: spin 1s linear infinite;
}

.ptr-indicator i {
    width: 20px;
    height: 20px;
    color: var(--primary);
}

@keyframes spin {
    from {
        transform: translateX(-50%) translateY(10px) rotate(0deg);
    }

    to {
        transform: translateX(-50%) translateY(10px) rotate(360deg);
    }
}

/* ===== SIDEBAR OVERLAY ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

/* ===== SWIPE ACTIONS ===== */
.transaction-item {
    position: relative;
    overflow: hidden;
    touch-action: pan-y;
}

.swipe-actions {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    transform: translateX(100%);
    transition: transform 0.2s ease;
}

.swipe-action {
    width: 70px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.swipe-action.edit {
    background: var(--primary);
}

.swipe-action.delete {
    background: var(--danger);
}

.swipe-action i {
    width: 24px;
    height: 24px;
}

.transaction-item.swiped .swipe-actions {
    transform: translateX(0);
}

.transaction-item.swiping {
    transition: none;
}

/* ===== TOUCH FEEDBACK ===== */
.touch-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0);
    animation: ripple 0.6s ease-out;
    pointer-events: none;
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ===== MOBILE MODAL STYLES ===== */
@media (max-width: 480px) {
    .modal {
        padding: 0;
        align-items: flex-end;
    }

    .modal-content {
        max-width: 100%;
        width: 100%;
        max-height: 90vh;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        padding-bottom: calc(var(--spacing-xl) + env(safe-area-inset-bottom, 0));
        animation: slideUp 0.3s ease;
    }

    .modal.hidden .modal-content {
        transform: translateY(100%);
    }

    /* Modal drag handle */
    .modal-content::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: var(--border);
        border-radius: var(--radius-full);
        margin: 0 auto var(--spacing-md);
    }

    .modal-header {
        padding-top: 0;
    }

    .close-modal {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

/* ===== IMPROVED TOUCH TARGETS ===== */
@media (max-width: 768px) {

    /* Navigation Items */
    .mobile-nav-item {
        min-width: 48px;
        min-height: 48px;
        padding: var(--spacing-sm);
    }

    .mobile-nav-item i {
        width: 24px;
        height: 24px;
    }

    /* Mobile Header */
    .mobile-header .icon-btn {
        width: 44px;
        height: 44px;
    }

    /* Transaction Items */
    .transaction-item {
        padding: var(--spacing-md) var(--spacing-sm);
        min-height: 64px;
    }

    .t-icon {
        width: 44px;
        height: 44px;
    }

    /* Always show action buttons on mobile */
    .transaction-item .edit-btn,
    .transaction-item .delete-btn {
        opacity: 1;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Form Inputs */
    input[type="text"],
    input[type="number"],
    input[type="date"],
    input[type="month"],
    textarea,
    .select-input {
        min-height: 48px;
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    /* Type Toggle */
    .type-btn {
        min-height: 48px;
        padding: var(--spacing-md);
    }

    /* Category Picker - 3 columns on mobile */
    .category-picker {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--spacing-md);
    }

    .category-option {
        padding: var(--spacing-md);
        min-height: 70px;
    }

    .category-option .cat-icon {
        width: 36px;
        height: 36px;
    }

    /* Buttons */
    .btn {
        min-height: 48px;
        padding: var(--spacing-md) var(--spacing-lg);
    }

    .btn-sm {
        min-height: 40px;
    }

    /* Goals and Budget Items */
    .goal-item,
    .budget-item {
        padding: var(--spacing-md);
    }

    .goal-actions .btn {
        flex: 1;
    }

    /* Stat Cards */
    .stat-card {
        padding: var(--spacing-md);
    }

    .stat-icon {
        width: 44px;
        height: 44px;
    }

    .stat-info .amount {
        font-size: 1.5rem;
    }

    /* Charts */
    .chart-container {
        height: 200px;
    }

    .chart-container.large {
        height: 280px;
    }

    /* Insights Grid */
    .insights-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }

    .insight-card {
        padding: var(--spacing-md);
        flex-direction: column;
        text-align: center;
    }

    .insight-card i {
        width: 32px;
        height: 32px;
    }

    .insight-value {
        font-size: 1.1rem;
    }

    /* Toast positioning above bottom nav */
    .toast-container {
        bottom: calc(80px + env(safe-area-inset-bottom, 0));
    }

    /* Bottom nav safe area */
    .mobile-nav {
        height: calc(70px + env(safe-area-inset-bottom, 0));
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .main-content {
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0));
    }

    /* Content area adjustments */
    .content-area {
        gap: var(--spacing-md);
    }

    /* Cards */
    .card {
        padding: var(--spacing-md);
    }

    .card-title {
        font-size: 1rem;
    }

    /* Filter bar */
    .filters-bar {
        gap: var(--spacing-sm);
    }

    .filters-bar .select-input {
        flex: 1;
        min-width: 0;
    }

    /* Onboarding */
    .modal-content.onboarding {
        max-width: 100%;
    }

    .onboarding-icon {
        width: 64px;
        height: 64px;
    }

    .onboarding-icon i {
        width: 32px;
        height: 32px;
    }

    .onboarding-step h2 {
        font-size: 1.25rem;
    }
}

/* ===== EXTRA SMALL SCREENS ===== */
@media (max-width: 360px) {
    .category-picker {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-info .amount {
        font-size: 1.25rem;
    }

    .insights-grid {
        grid-template-columns: 1fr;
    }

    .mobile-nav-item span {
        display: none;
    }

    .mobile-nav-item.add-btn {
        width: 50px;
        height: 50px;
    }
}

/* ===== LANDSCAPE MOBILE ===== */
@media (max-height: 500px) and (orientation: landscape) {
    .mobile-nav {
        height: 56px;
    }

    .mobile-nav-item {
        min-height: 40px;
    }

    .mobile-nav-item span {
        display: none;
    }

    .mobile-nav-item.add-btn {
        margin-top: -10px;
        width: 48px;
        height: 48px;
    }

    .modal-content {
        max-height: 100vh;
        border-radius: var(--radius-xl);
    }
}