/* Taxless Mobile Styles - Android Optimized */

/* ============================================
   CSS Variables for Mobile
   ============================================ */
:root {
    --mobile-nav-height: 64px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --touch-target-size: 48px;
    --mobile-spacing: 16px;
}

/* ============================================
   Base Mobile Styles
   ============================================ */
@media (max-width: 768px) {
    /* Prevent zoom on input focus (iOS/Android) */
    input, select, textarea {
        font-size: 16px !important;
    }

    /* Larger touch targets */
    .btn {
        min-height: var(--touch-target-size);
        padding: 12px 20px;
    }

    .btn-sm {
        min-height: 40px;
        padding: 8px 16px;
    }

    /* Better spacing for mobile */
    .container {
        padding-left: var(--mobile-spacing);
        padding-right: var(--mobile-spacing);
    }

    /* Cards on mobile */
    .card {
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        margin-bottom: var(--mobile-spacing);
    }

    /* Full-width buttons on mobile */
    .btn-mobile-full {
        width: 100%;
        margin-bottom: 8px;
    }

    /* Hide desktop nav, show mobile nav */
    .navbar {
        padding: 8px 0;
    }

    .navbar-brand {
        font-size: 1.1rem;
    }

    /* Add padding for bottom nav */
    body {
        padding-bottom: calc(var(--mobile-nav-height) + var(--safe-area-bottom) + 20px);
    }

    /* Main content area */
    main {
        padding-bottom: 80px;
    }

    /* Tables on mobile - horizontal scroll */
    .table-responsive {
        border-radius: 8px;
    }

    /* Stack table cells on very small screens */
    @media (max-width: 480px) {
        .table-mobile-stack td,
        .table-mobile-stack th {
            display: block;
            width: 100%;
            text-align: left !important;
        }

        .table-mobile-stack tr {
            display: block;
            border-bottom: 2px solid #dee2e6;
            padding: 8px 0;
        }
    }
}

/* ============================================
   Bottom Navigation
   ============================================ */
.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-nav-height);
    background: #ffffff;
    border-top: 1px solid #dee2e6;
    display: none;
    justify-content: space-around;
    align-items: center;
    padding-bottom: var(--safe-area-bottom);
    z-index: 1030;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

@media (max-width: 768px) {
    .mobile-nav {
        display: flex;
    }

    /* Hide footer on mobile when nav is shown */
    footer {
        display: none;
    }
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #6c757d;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s ease;
    min-width: 64px;
}

.mobile-nav-item.active {
    color: #0d6efd;
}

.mobile-nav-item:hover,
.mobile-nav-item:active {
    background: #f8f9fa;
    color: #0d6efd;
}

.mobile-nav-item .nav-icon {
    font-size: 24px;
    margin-bottom: 2px;
}

.mobile-nav-item .nav-label {
    font-size: 11px;
    font-weight: 500;
}

/* ============================================
   Floating Action Button (FAB)
   ============================================ */
.fab {
    position: fixed;
    bottom: calc(var(--mobile-nav-height) + var(--safe-area-bottom) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #0d6efd;
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 1020;
    transition: transform 0.2s, box-shadow 0.2s;
}

.fab:hover,
.fab:active {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(13, 110, 253, 0.5);
}

@media (max-width: 768px) {
    .fab {
        display: flex;
    }
}

/* ============================================
   Pull to Refresh Indicator
   ============================================ */
.pull-to-refresh {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background: #0d6efd;
    color: white;
    padding: 8px 16px;
    border-radius: 0 0 8px 8px;
    font-size: 14px;
    transition: transform 0.3s;
    z-index: 1040;
}

.pull-to-refresh.visible {
    transform: translateX(-50%) translateY(0);
}

/* ============================================
   Mobile Dashboard Cards
   ============================================ */
@media (max-width: 768px) {
    .dashboard-stat-card {
        text-align: center;
        padding: 16px 12px;
    }

    .dashboard-stat-card h2 {
        font-size: 1.5rem;
    }

    .dashboard-stat-card h6,
    .dashboard-stat-card small {
        font-size: 0.75rem;
    }

    /* Stack dashboard columns */
    .dashboard-row .col-md-3 {
        margin-bottom: 12px;
    }
}

/* ============================================
   Mobile Form Styles
   ============================================ */
@media (max-width: 768px) {
    .form-control,
    .form-select {
        padding: 12px 16px;
        border-radius: 8px;
    }

    .form-label {
        font-weight: 600;
        margin-bottom: 6px;
    }

    .input-group-text {
        padding: 12px 16px;
    }

    /* Camera button styling */
    .camera-capture-btn {
        width: 100%;
        padding: 20px;
        border: 2px dashed #dee2e6;
        border-radius: 12px;
        background: #f8f9fa;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        cursor: pointer;
        transition: all 0.2s;
    }

    .camera-capture-btn:hover,
    .camera-capture-btn:active {
        border-color: #0d6efd;
        background: #e7f1ff;
    }

    .camera-capture-btn .camera-icon {
        font-size: 32px;
    }
}

/* ============================================
   Mobile Receipt List
   ============================================ */
@media (max-width: 768px) {
    .receipt-list-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px;
        border-bottom: 1px solid #dee2e6;
    }

    .receipt-list-item:last-child {
        border-bottom: none;
    }

    .receipt-info {
        flex: 1;
    }

    .receipt-amount {
        font-weight: 600;
        font-size: 1.1rem;
    }

    .receipt-meta {
        font-size: 0.85rem;
        color: #6c757d;
    }
}

/* ============================================
   Swipe Actions (for future use)
   ============================================ */
.swipe-container {
    overflow: hidden;
    position: relative;
}

.swipe-actions {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    display: flex;
    transform: translateX(100%);
    transition: transform 0.3s;
}

.swipe-action-btn {
    width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    border: none;
}

.swipe-action-btn.delete {
    background: #dc3545;
}

.swipe-action-btn.edit {
    background: #0d6efd;
}

/* ============================================
   Loading States
   ============================================ */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
    position: fixed;
    bottom: calc(var(--mobile-nav-height) + var(--safe-area-bottom) + 80px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 1050;
}

.toast {
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    animation: toast-in 0.3s ease;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   PWA Install Banner Improvements
   ============================================ */
@media (max-width: 768px) {
    #pwa-install-banner {
        padding: 12px !important;
    }

    #pwa-install-banner .container {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }

    #pwa-install-banner button {
        width: 100%;
    }
}

/* ============================================
   Standalone Mode (Installed PWA)
   ============================================ */
@media (display-mode: standalone) {
    /* Hide install prompts when already installed */
    #pwa-install-banner,
    .install-prompt {
        display: none !important;
    }

    /* Adjust for notch on Android */
    .navbar {
        padding-top: env(safe-area-inset-top, 0px);
    }
}
