/* Mobile-First CSS Optimizations for Project Accountability */

/* ===== Base Mobile Styles (Mobile First Approach) ===== */
:root {
    /* Touch-friendly sizes */
    --min-touch-target: 44px;
    --mobile-padding: 1rem;
    --mobile-margin: 0.75rem;

    /* Optimized font sizes for mobile */
    --font-size-base: 16px; /* Prevents zoom on iOS */
    --font-size-small: 14px;
    --font-size-large: 18px;
    --font-size-h1-mobile: 1.75rem;
    --font-size-h2-mobile: 1.5rem;
    --font-size-h3-mobile: 1.25rem;
    --font-size-h4-mobile: 1.125rem;

    /* Performance optimizations */
    --transition-fast: 0.2s;
    --transition-normal: 0.3s;
}

/* ===== Performance Optimizations ===== */
/* Reduce render blocking for hero section */
.hero-section {
    contain: layout;
    will-change: transform;
}

/* Optimize animations for mobile */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== Typography Optimizations ===== */
html {
    font-size: var(--font-size-base);
    -webkit-text-size-adjust: 100%; /* Prevent font scaling in landscape */
}

/* Mobile-optimized headings */
h1, .h1, .display-4 {
    font-size: var(--font-size-h1-mobile);
    line-height: 1.2;
    margin-bottom: 1rem;
}

h2, .h2, .display-5 {
    font-size: var(--font-size-h2-mobile);
    line-height: 1.3;
}

h3, .h3 {
    font-size: var(--font-size-h3-mobile);
}

h4, .h4 {
    font-size: var(--font-size-h4-mobile);
}

.lead {
    font-size: 1.125rem;
    line-height: 1.5;
}

/* ===== Touch-Friendly Button Styles ===== */
.btn {
    min-height: var(--min-touch-target);
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    touch-action: manipulation; /* Prevents delay on touch devices */
    user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-lg {
    min-height: 52px;
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn-sm {
    min-height: 36px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Ensure all interactive elements meet minimum touch target */
a, button, input, select, textarea, .card {
    min-height: var(--min-touch-target);
}

/* ===== Hero Section Mobile Optimizations ===== */
.hero-section {
    padding: 2rem 0;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
}

.hero-section .container {
    padding: 0 var(--mobile-padding);
}

/* Stack hero content vertically on mobile */
.hero-section .row {
    margin: 0;
}

.hero-section .col-lg-6 {
    padding: 0;
}

/* Mobile-optimized hero visuals */
.hero-visual-main {
    padding: 1.5rem !important;
    margin-bottom: 1.5rem !important;
}

.hero-visual-secondary {
    padding: 1rem !important;
}

/* Hide complex visuals on small screens for performance */
@media (max-width: 576px) {
    .hero-visual-main .mock-interface-elements {
        display: none;
    }

    .position-absolute.translate-middle {
        position: static !important;
        transform: none !important;
        margin-top: 1rem;
    }
}

/* ===== Mobile Navigation Optimization ===== */
.navbar {
    padding: 0.5rem 1rem;
}

.navbar-toggler {
    min-height: var(--min-touch-target);
    min-width: var(--min-touch-target);
    padding: 0.5rem;
}

.navbar-nav .nav-link {
    padding: 0.75rem 1rem;
    font-size: 1rem;
}

/* Mobile menu overlay - Fixed to properly show navigation content */
@media (max-width: 991px) {
    .navbar-collapse {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bs-primary, #0d6efd);
        z-index: 1030;
        padding: 1rem;
        border-radius: 0 0 8px 8px;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
    }

    .navbar-collapse.show {
        display: block !important;
    }

    /* Ensure nav links are visible in mobile menu */
    .navbar-collapse .navbar-nav .nav-link {
        color: rgba(255, 255, 255, 0.9) !important;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        transition: all 0.2s ease;
    }

    .navbar-collapse .navbar-nav .nav-link:hover,
    .navbar-collapse .navbar-nav .nav-link:focus {
        color: white !important;
        background-color: rgba(255, 255, 255, 0.1);
        border-radius: 4px;
    }

    /* Dropdown menus in mobile */
    .navbar-collapse .dropdown-menu {
        background-color: rgba(255, 255, 255, 0.98);
        border: 1px solid rgba(0, 0, 0, 0.1);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        margin-top: 0.5rem;
        position: relative !important;
        transform: none !important;
        z-index: 1035 !important;
        width: 100%;
        border-radius: 8px;
    }

    .navbar-collapse .dropdown-menu .dropdown-item {
        color: #333 !important;
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
        transition: all 0.2s ease;
        border-radius: 4px;
        margin: 2px 4px;
    }

    .navbar-collapse .dropdown-menu .dropdown-item:hover,
    .navbar-collapse .dropdown-menu .dropdown-item:focus,
    .navbar-collapse .dropdown-menu .dropdown-item:active {
        background-color: #f8f9fa;
        color: var(--bs-primary, #0d6efd) !important;
        transform: translateX(2px);
    }

    /* Ensure dropdown dividers are visible */
    .navbar-collapse .dropdown-menu .dropdown-divider {
        border-top: 1px solid rgba(0, 0, 0, 0.1);
        margin: 0.5rem 0;
    }

    /* Fix for dropdown toggle arrow */
    .navbar-collapse .dropdown-toggle::after {
        margin-left: 0.5rem;
        transition: transform 0.2s ease;
    }

    .navbar-collapse .dropdown-toggle[aria-expanded="true"]::after {
        transform: rotate(180deg);
    }

    /* Badge styling in mobile menu */
    .navbar-collapse .badge {
        margin-left: 0.5rem;
    }

    /* Icon styling in mobile menu */
    .navbar-collapse .nav-link i {
        margin-right: 0.5rem;
        font-size: 1.1rem;
    }
}

/* ===== Progressive Disclosure for Mobile ===== */
/* Expandable sections for mobile */
.expandable-section {
    position: relative;
}

.expandable-content {
    max-height: 200px;
    overflow: hidden;
    position: relative;
    transition: max-height var(--transition-normal) ease;
}

.expandable-content.expanded {
    max-height: none;
}

.expandable-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: linear-gradient(to bottom, transparent, white);
    pointer-events: none;
}

.expandable-content.expanded::after {
    display: none;
}

.expand-button {
    width: 100%;
    min-height: var(--min-touch-target);
    margin-top: 1rem;
    background: transparent;
    border: 1px solid var(--bs-primary);
    color: var(--bs-primary);
}

/* ===== Card Optimizations for Mobile ===== */
.card {
    margin-bottom: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.card-body {
    padding: 1rem;
}

.feature-card {
    margin-bottom: 1.5rem;
}

.feature-icon {
    width: 60px !important;
    height: 60px !important;
}

/* ===== Landing Sections Mobile Optimization ===== */
@media (max-width: 768px) {
    /* Feature benefits section */
    #features .col-md-6,
    #features .col-lg-3 {
        margin-bottom: 1.5rem;
    }

    /* Problem/Solution section */
    #problem-solution .card {
        margin-top: 2rem;
    }

    /* Social proof metrics */
    #social-proof .col-6 {
        margin-bottom: 1.5rem;
    }

    #social-proof .h1 {
        font-size: 2rem;
    }

    /* Trust indicators */
    #trust-indicators svg {
        width: 36px;
        height: 36px;
    }

    #trust-indicators h6 {
        font-size: 0.75rem;
    }
}

/* ===== Form Optimizations for Mobile ===== */
input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0.75rem;
    min-height: var(--min-touch-target);
}

.form-label {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

/* ===== Mobile-Specific Utilities ===== */
/* One-handed navigation helper */
@media (max-width: 576px) {
    .bottom-nav-actions {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e9ecef;
        padding: 1rem;
        z-index: 1020;
    }

    body.has-bottom-nav {
        padding-bottom: 80px;
    }
}

/* Swipeable cards for mobile */
.swipeable-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.swipeable-container::-webkit-scrollbar {
    display: none;
}

.swipeable-item {
    scroll-snap-align: start;
    flex: 0 0 85%;
    margin-right: 1rem;
}

/* ===== Performance Optimizations ===== */
/* Lazy loading images */
img[loading="lazy"] {
    background: #f0f0f0;
}

/* Reduce motion for better performance */
@media (max-width: 768px) {
    .card {
        transition: none;
    }

    .card:hover {
        transform: none;
    }

    .feature-card:hover {
        transform: none;
    }
}

/* ===== Responsive Spacing ===== */
@media (max-width: 576px) {
    .container {
        padding-left: var(--mobile-padding);
        padding-right: var(--mobile-padding);
    }

    .py-5 {
        padding-top: 3rem !important;
        padding-bottom: 3rem !important;
    }

    .py-4 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }

    .mb-5 {
        margin-bottom: 2rem !important;
    }

    .mb-4 {
        margin-bottom: 1.5rem !important;
    }
}

/* ===== Tablet Optimizations (768px - 991px) ===== */
@media (min-width: 768px) and (max-width: 991px) {
    .hero-section h1 {
        font-size: 2.5rem;
    }

    .btn-lg {
        padding: 0.875rem 1.75rem;
    }

    .card-body {
        padding: 1.5rem;
    }
}

/* ===== Large Mobile / Small Tablet (576px - 768px) ===== */
@media (min-width: 576px) and (max-width: 767px) {
    .hero-section h1 {
        font-size: 2rem;
    }

    .lead {
        font-size: 1.125rem;
    }
}

/* ===== Accessibility Improvements ===== */
/* Focus indicators for mobile */
:focus {
    outline: 3px solid rgba(13, 110, 253, 0.5);
    outline-offset: 2px;
}

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

    .card {
        border: 1px solid currentColor;
    }
}

/* ===== Loading States for Mobile ===== */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

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

/* ===== Dropdown Menu Z-Index Fix ===== */
/* Ensure dropdown menus appear above all content on mobile */
.dropdown-menu {
    z-index: 1055 !important;
}

/* Specific fix for user dropdown menu */
#userDropdown + .dropdown-menu,
#analyticsDropdown + .dropdown-menu {
    z-index: 1055 !important;
    position: absolute !important;
}

/* For all screen sizes, ensure dropdowns appear above other elements */
@media (max-width: 991px) {
    .dropdown-menu.show {
        z-index: 1055 !important;
    }
}

/* ===== Mobile-Specific Features ===== */
/* Pull to refresh indicator */
.pull-to-refresh {
    position: fixed;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    transition: top 0.3s;
    z-index: 1050;
}

.pull-to-refresh.visible {
    top: 10px;
}

/* Bottom sheet for mobile actions */
.mobile-bottom-sheet {
    position: fixed;
    bottom: -100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    padding: 1.5rem;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    transition: bottom 0.3s ease;
    z-index: 1040;
}

.mobile-bottom-sheet.show {
    bottom: 0;
}

/* Mobile-friendly modal adjustments */
@media (max-width: 576px) {
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }

    .modal-content {
        height: 100%;
        border-radius: 0;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}
