/* Unified Footer Styles - Guaranteed Consistency */

/* Footer Container - FIXED POSITIONING MATCHING HEADER */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background-color: var(--background);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0 16px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    -webkit-backface-visibility: hidden;  /* Chrome iOS fix */
    backface-visibility: hidden;
    transform: translate3d(0, 0, 0);  /* Better hardware acceleration for iOS Chrome */
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    will-change: transform; /* Optimize for animations */
}

/* Footer Tab - CONSISTENT STRUCTURE */
.footer-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    padding: 6px 8px;
    border-radius: 8px;
    min-width: 64px;
    position: relative;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Footer Tab Hover States */
.footer-tab:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.footer-tab:active {
    transform: scale(0.95);
}

/* Footer Icon Container */
.footer-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2px;
    transition: all 0.2s ease;
}

/* Footer Icon SVG */
.footer-icon svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: all 0.2s ease;
}

/* Footer Label */
.footer-label {
    font-size: 12px;
    font-weight: 400;
    line-height: 1;
    transition: all 0.2s ease;
}

/* ACTIVE STATE - ORANGE ACCENT HIGHLIGHTING */
.footer-tab.active {
    color: var(--orange-accent);
    background-color: var(--orange-bg);
}

.footer-tab.active .footer-icon svg {
    stroke: var(--orange-accent);
    transform: scale(1.1);
}

.footer-tab.active .footer-label {
    font-weight: 500;
    color: var(--orange-accent);
}

/* CRITICAL: Ensure footer doesn't interfere with content - REMOVED duplicate rule (now in base.css) */

/* iOS Safe Area Support - Enhanced for Chrome */
@supports (-webkit-touch-callout: none) {
    /* iOS only */
    .app-footer {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(56px + env(safe-area-inset-bottom));
        /* iOS Chrome specific fixes */
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
}

/* Responsive Adjustments - MATCHING HEADER BEHAVIOR */
/* Mobile: Full width */
@media (max-width: 900px) {
    .app-footer {
        max-width: 100%;
        margin: 0;
    }
}

/* Tablet: Slight padding for comfort */
@media (min-width: 481px) and (max-width: 900px) {
    .app-footer {
        padding: 0 20px;
    }
}

@media (max-width: 480px) {
    .app-footer {
        padding: 0 12px;
    }
    
    .footer-tab {
        min-width: 56px;
        padding: 4px 6px;
    }
    
    .footer-icon svg {
        width: 18px;
        height: 18px;
    }
    
    .footer-label {
        font-size: 11px;
    }
}

/* Ensure footer stays at bottom during keyboard open */
@media screen and (max-height: 400px) {
    .app-footer {
        position: absolute;
    }
}

/* Touch optimization for mobile */
@media (hover: none) and (pointer: coarse) {
    .footer-tab {
        min-height: 44px; /* Apple's recommended touch target size */
        min-width: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .footer-tab:hover {
        background-color: transparent;
        color: var(--text-secondary);
    }
    
    .footer-tab.active:hover {
        background-color: var(--orange-bg);
        color: var(--orange-accent);
    }
}

/* Accessibility */
.footer-tab:focus {
    outline: 2px solid var(--orange-accent);
    outline-offset: 2px;
    background-color: rgba(255, 255, 255, 0.05);
}

.footer-tab.active:focus {
    outline-color: var(--orange-accent);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .footer-tab.active {
        background-color: var(--orange-accent);
        color: var(--background);
    }
    
    .footer-tab.active .footer-icon svg {
        stroke: var(--background);
    }
    
    .footer-tab.active .footer-label {
        color: var(--background);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .footer-tab,
    .footer-icon,
    .footer-icon svg,
    .footer-label {
        transition: none;
    }
    
    .footer-tab:active {
        transform: none;
    }
    
    .footer-tab.active .footer-icon svg {
        transform: none;
    }
}

/* iOS-specific fixes */
.footer-navigation {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    /* Support for iPhone X and newer with notches */
    padding-bottom: env(safe-area-inset-bottom);
}

/* Fix for iOS momentum scrolling */
html, body {
    -webkit-overflow-scrolling: touch;
    overflow-x: hidden;
}

/* iOS Chrome Enhanced Support */
@supports (-webkit-touch-callout: none) {
    /* Prevent scrolling beyond the footer */
    body {
        overscroll-behavior-y: none;
        height: 100%;
        position: relative;
    }
    
    /* Enhanced iOS Chrome fix for .app-footer specifically */
    .app-footer {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        /* Use 3d transform for better Chrome iOS performance */
        -webkit-transform: translate3d(0, 0, 0) !important;
        transform: translate3d(0, 0, 0) !important;
        /* Prevent disappearing on scroll */
        will-change: transform;
        /* iOS Chrome viewport fix */
        -webkit-overflow-scrolling: touch;
    }
}