/* 
 * MyReclaiming Mobile-First Responsive Design
 * Add this to a new file: frontend/public/css/mobile.css
 * Then include in all your HTML files: <link rel="stylesheet" href="css/mobile.css">
 */

:root {
    --primary: #2563eb;
    --secondary: #0d9488;
    --danger: #dc2626;
    --touch-target-min: 44px;
    --mobile-padding: 16px;
    --tablet-padding: 24px;
    --desktop-padding: 32px;
}

/* ============================================
   BASE MOBILE STYLES (Mobile First!)
   ============================================ */

* {
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

body {
    font-size: 16px; /* Never smaller on mobile */
    line-height: 1.5;
    padding-bottom: env(safe-area-inset-bottom); /* iPhone notch support */
}

/* Larger touch targets for mobile */
button,
a.btn,
input[type="submit"],
input[type="button"] {
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
    padding: 12px 20px;
    font-size: 16px; /* Prevents iOS zoom on focus */
}

/* Form inputs - prevent iOS zoom */
input,
textarea,
select {
    font-size: 16px !important;
    padding: 12px;
    border-radius: 8px;
}

/* Better spacing for thumbs */
.mobile-stack > * + * {
    margin-top: 16px;
}

/* Sticky mobile header */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Mobile navigation */
.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    display: flex;
    justify-content: space-around;
    z-index: 50;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 16px;
    min-height: var(--touch-target-min);
    color: #6b7280;
    text-decoration: none;
    font-size: 12px;
    transition: color 0.2s;
}

.mobile-nav-item.active {
    color: var(--primary);
    font-weight: 600;
}

.mobile-nav-item svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
}

/* Main content area with bottom nav space */
.main-with-nav {
    padding-bottom: calc(60px + env(safe-area-inset-bottom));
}

/* Cards optimized for mobile */
.card-mobile {
    background: white;
    border-radius: 16px;
    padding: var(--mobile-padding);
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Better touch feedback */
.touch-feedback {
    position: relative;
    overflow: hidden;
}

.touch-feedback::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.05);
    opacity: 0;
    transition: opacity 0.2s;
}

.touch-feedback:active::after {
    opacity: 1;
}

/* Swipeable cards */
.swipe-card {
    touch-action: pan-y;
    transition: transform 0.3s ease;
}

/* Modal optimized for mobile */
.mobile-modal {
    position: fixed;
    inset: 0;
    background: white;
    z-index: 200;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

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

/* Bottom sheet style modal */
.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    z-index: 200;
    animation: slideUp 0.3s ease;
}

.bottom-sheet-handle {
    width: 40px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 0 auto 16px;
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: calc(76px + env(safe-area-inset-bottom));
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    border: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 40;
}

.fab:active {
    transform: scale(0.95);
}

/* Mobile-optimized typography */
.text-mobile-h1 {
    font-size: 28px;
    line-height: 1.2;
    font-weight: 700;
    margin-bottom: 16px;
}

.text-mobile-h2 {
    font-size: 22px;
    line-height: 1.3;
    font-weight: 600;
    margin-bottom: 12px;
}

.text-mobile-body {
    font-size: 16px;
    line-height: 1.5;
}

.text-mobile-small {
    font-size: 14px;
    line-height: 1.4;
}

/* Quick capture button (always visible) */
.quick-capture {
    position: fixed;
    bottom: calc(76px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    background: var(--danger);
    color: white;
    padding: 12px 24px;
    border-radius: 999px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
    z-index: 40;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4); }
    50% { box-shadow: 0 4px 20px rgba(220, 38, 38, 0.6); }
}

/* Pull to refresh indicator */
.pull-to-refresh {
    text-align: center;
    padding: 20px;
    color: #6b7280;
    font-size: 14px;
}

/* Skeleton loading for mobile */
.skeleton {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   TABLET STYLES (768px and up)
   ============================================ */

@media (min-width: 768px) {
    .card-mobile {
        padding: var(--tablet-padding);
    }
    
    .mobile-nav {
        display: none; /* Use regular nav on tablet+ */
    }
    
    .main-with-nav {
        padding-bottom: 0;
    }
    
    .fab {
        bottom: 32px;
    }
    
    .quick-capture {
        bottom: 32px;
    }
    
    .text-mobile-h1 {
        font-size: 36px;
    }
    
    .text-mobile-h2 {
        font-size: 28px;
    }
}

/* ============================================
   DESKTOP STYLES (1024px and up)
   ============================================ */

@media (min-width: 1024px) {
    .card-mobile {
        padding: var(--desktop-padding);
    }
    
    .text-mobile-h1 {
        font-size: 42px;
    }
    
    .text-mobile-h2 {
        font-size: 32px;
    }
    
    /* Hover states only on desktop */
    @media (hover: hover) {
        button:hover,
        a.btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        }
    }
}

/* ============================================
   LANDSCAPE MODE ON PHONES
   ============================================ */

@media (max-height: 500px) and (orientation: landscape) {
    .mobile-nav {
        padding: 4px;
    }
    
    .mobile-nav-item {
        padding: 4px 12px;
        min-height: 36px;
    }
    
    .mobile-nav-item svg {
        width: 20px;
        height: 20px;
    }
}

/* ============================================
   DARK MODE SUPPORT
   ============================================ */

@media (prefers-color-scheme: dark) {
    body {
        background: #111827;
        color: #f3f4f6;
    }
    
    .card-mobile {
        background: #1f2937;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    }
    
    .mobile-nav {
        background: #1f2937;
        border-top-color: #374151;
    }
    
    input,
    textarea,
    select {
        background: #374151;
        color: #f3f4f6;
        border-color: #4b5563;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    button,
    .btn {
        border: 2px solid currentColor;
    }
}