/* MileMinder Mobile-First CSS */

/* Base Mobile Styles */
:root {
    --primary-color: #6c757d;
    --secondary-color: #5a6268;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #6c757d;
    --light-gray: #f8f9fa;
    --border-radius: 8px;
    --box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Mobile-First Layout */
body {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
}

/* Prevent iOS zoom on input focus */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
input[type="time"],
textarea,
select {
    font-size: 16px !important;
}

/* Touch-friendly buttons */
.btn {
    min-height: 44px;
    padding: 10px 20px;
    touch-action: manipulation;
}

/* Mobile Navigation */
@media (max-width: 768px) {
    .navbar {
        padding: 0.5rem;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .dropdown-menu {
        position: static !important;
        float: none;
        width: 100%;
        margin-top: 0.125rem;
        /* Mobile-specific dropdown adjustments */
        max-height: 50vh;
        overflow-y: auto;
        border-radius: var(--border-radius);
        /* Improve touch scrolling */
        -webkit-overflow-scrolling: touch;
        /* Show scrollbar on mobile when needed */
        scrollbar-width: thin;
    }
    
    /* Mobile dropdown items - larger touch targets */
    .dropdown-item {
        padding: 12px 16px !important;
        font-size: 16px !important; /* Prevent zoom on iOS */
        line-height: 1.4;
    }
    
    /* Mobile dropdown headers */
    .dropdown-header {
        padding: 8px 16px !important;
        font-size: 12px !important;
        font-weight: 600;
    }
}

/* Cards for Mobile */
.card {
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .card {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .card-body {
        padding: 1rem;
    }
}

/* Mobile Tables */
@media (max-width: 768px) {
    /* Convert tables to cards on mobile */
    table.mobile-responsive {
        display: block;
        border: 0;
    }
    
    table.mobile-responsive thead {
        display: none;
    }
    
    table.mobile-responsive tbody,
    table.mobile-responsive tr,
    table.mobile-responsive td {
        display: block;
        width: 100%;
    }
    
    table.mobile-responsive tr {
        margin-bottom: 1rem;
        border: 1px solid #dee2e6;
        border-radius: var(--border-radius);
        padding: 0.5rem;
        background: white;
        box-shadow: var(--box-shadow);
    }
    
    table.mobile-responsive td {
        text-align: right;
        padding-left: 50%;
        position: relative;
        border: none;
    }
    
    table.mobile-responsive td:before {
        content: attr(data-label);
        position: absolute;
        left: 6px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
    }
}

/* Mobile Forms */
.form-floating {
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .form-group {
        margin-bottom: 1rem;
    }
    
    /* Stack form columns on mobile */
    .row > [class*='col-'] {
        margin-bottom: 1rem;
    }
}

/* Mobile Dashboard */
.dashboard-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--box-shadow);
    transition: transform 0.2s;
}

.dashboard-card:active {
    transform: scale(0.98);
}

.stat-card {
    text-align: center;
    padding: 1.5rem;
    background: var(--light-gray);
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-card .stat-label {
    color: #6c757d;
    font-size: 0.875rem;
}

/* Mobile Modals */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
    }
    
    .modal-content {
        height: 100%;
        border-radius: 0;
    }
    
    .modal-body {
        overflow-y: auto;
    }
}

/* Touch-friendly Lists */
.list-group-item {
    padding: 1rem;
    border-left: none;
    border-right: none;
}

.list-group-item:active {
    background-color: var(--light-gray);
}

/* Swipeable Actions */
.swipe-actions {
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.list-item-touch:active .swipe-actions {
    opacity: 1;
}

/* Bottom Navigation for Mobile */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #dee2e6;
    display: none;
    z-index: 1000;
}

@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
        justify-content: space-around;
        padding: 0.5rem 0;
    }
    
    .bottom-nav-item {
        flex: 1;
        text-align: center;
        padding: 0.5rem;
        color: #6c757d;
        text-decoration: none;
        font-size: 0.75rem;
    }
    
    .bottom-nav-item.active {
        color: var(--primary-color);
    }
    
    .bottom-nav-item i {
        display: block;
        font-size: 1.25rem;
        margin-bottom: 0.25rem;
    }
    
    /* Adjust main content for bottom nav */
    main {
        padding-bottom: 80px !important;
    }
}

/* Pull to Refresh */
.pull-to-refresh {
    position: fixed;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    transition: top 0.3s;
    z-index: 1000;
}

.pull-to-refresh.show {
    top: 60px;
}

/* Offline Indicator */
.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #dc3545;
    color: white;
    text-align: center;
    padding: 0.5rem;
    display: none;
    z-index: 9999;
}

body.offline .offline-indicator {
    display: block;
}

/* Loading States */
.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;
    }
}

/* Touch Feedback */
.touchable {
    transition: background-color 0.2s;
    cursor: pointer;
}

.touchable:active {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    z-index: 900;
}

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

@media (min-width: 769px) {
    .fab {
        bottom: 20px;
    }
}

/* Mobile Time Entry */
.time-entry-mobile {
    background: white;
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--box-shadow);
}

.time-entry-mobile .time-display {
    font-size: 2rem;
    text-align: center;
    margin: 1rem 0;
    font-weight: bold;
    color: var(--primary-color);
}

/* Quick Actions Grid */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.quick-action-btn {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--light-gray);
    border: none;
    border-radius: var(--border-radius);
    padding: 1rem;
    text-decoration: none;
    color: inherit;
}

.quick-action-btn i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.quick-action-btn span {
    font-size: 0.875rem;
}

/* Mobile Select2 Adjustments */
@media (max-width: 768px) {
    .select2-container--bootstrap-5 .select2-selection {
        min-height: 44px;
        padding: 8px 12px;
    }
    
    .select2-dropdown {
        border-radius: 0;
    }
    
    .select2-results__option {
        padding: 12px;
    }
}

/* iOS Safe Areas */
@supports (padding: max(0px)) {
    .bottom-nav {
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }
    
    main {
        padding-bottom: max(80px, calc(80px + env(safe-area-inset-bottom))) !important;
    }
}

/* Light Theme Enforcement */
/* Removed dark mode CSS to ensure consistent light theme regardless of system preference */