/* css/mobile.css - Mobile Responsive Styles */

/* Mobile-First Responsive Breakpoints */
/* xs: 0-575px (phones) */
/* sm: 576-767px (phones landscape) */
/* md: 768-991px (tablets) */
/* lg: 992-1199px (desktop) */
/* xl: 1200px+ (large desktop) */

/* Base Mobile Styles */
@media (max-width: 767px) {
    html {
        font-size: 14px;
    }
    
    body {
        font-size: 1rem;
        line-height: 1.5;
    }
    
    /* Typography adjustments */
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
    h4 { font-size: 1.25rem; }
    h5 { font-size: 1.125rem; }
    h6 { font-size: 1rem; }
    
    /* Container adjustments */
    .container {
        padding: 0 0.75rem;
    }
    
    /* Main content area */
    .main-content {
        margin-left: 0;
        padding: 1rem 0.75rem 100px; /* Account for mobile nav */
    }
    
    /* Grid system adjustments */
    .row {
        margin: -0.25rem;
    }
    
    .col {
        padding: 0.25rem;
    }
    
    .col-2,
    .col-3,
    .col-4 {
        flex: 0 0 100%; /* Stack columns on mobile */
    }
    
    /* Card adjustments */
    .card {
        margin-bottom: 1rem;
        border-radius: 8px;
    }
    
    .card-header,
    .card-body,
    .card-footer {
        padding: 1rem;
    }
    
    .card-title {
        font-size: 1.125rem;
    }
    
    /* Button adjustments */
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
        min-height: 48px; /* Better touch target */
        font-size: 1rem;
    }
    
    .btn-group .btn {
        width: auto;
        margin-bottom: 0;
    }
    
    .btn-sm {
        min-height: 40px;
        font-size: 0.9rem;
    }
    
    .btn-lg {
        min-height: 56px;
        font-size: 1.125rem;
    }
    
    /* Form adjustments */
    .form-control {
        font-size: 16px; /* Prevent zoom on iOS */
        min-height: 48px;
        padding: 0.875rem 1rem;
    }
    
    .form-label {
        font-size: 0.95rem;
        margin-bottom: 0.375rem;
    }
    
    .form-group {
        margin-bottom: 1.25rem;
    }
    
    /* Table adjustments */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        font-size: 0.9rem;
    }
    
    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
    }
    
    /* Modal adjustments */
    .modal-content {
        width: 95%;
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        margin-bottom: 0.5rem;
    }
    
    .modal-footer .btn:last-child {
        margin-bottom: 0;
    }
}

/* Small Mobile Phones (320px-480px) */
@media (max-width: 480px) {
    html {
        font-size: 13px;
    }
    
    .container {
        padding: 0 0.5rem;
    }
    
    .main-content {
        padding: 0.75rem 0.5rem 100px;
    }
    
    .card-header,
    .card-body,
    .card-footer {
        padding: 0.75rem;
    }
    
    .btn {
        padding: 0.875rem 1rem;
        font-size: 0.95rem;
    }
    
    .form-control {
        padding: 0.75rem;
        font-size: 16px;
    }
    
    /* Smaller modal on very small screens */
    .modal-content {
        width: 98%;
        margin: 0.5rem;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 0.75rem;
    }
}

/* Tablet Portrait (768px-991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .main-content {
        margin-left: 180px;
        padding: 1.5rem;
    }
    
    .col-2 { flex: 0 0 50%; }
    .col-3 { flex: 0 0 50%; }
    .col-4 { flex: 0 0 50%; }
    
    .btn {
        width: auto;
        margin-bottom: 0;
    }
}

/* Touch-Friendly Enhancements */
@media (hover: none) and (pointer: coarse) {
    /* Improve touch targets */
    .btn,
    .form-control,
    .nav-link,
    .mobile-nav-item {
        min-height: 44px;
    }
    
    /* Remove hover states on touch devices */
    .btn:hover,
    .card:hover,
    .nav-link:hover {
        transform: none;
    }
    
    /* Improve tap targets */
    a,
    button,
    .clickable {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* iOS Specific Styles */
@supports (-webkit-touch-callout: none) {
    .form-control {
        font-size: 16px; /* Prevent zoom */
        border-radius: 8px; /* Override iOS default */
    }
    
    input[type="date"],
    input[type="time"],
    input[type="datetime-local"] {
        min-height: 44px;
    }
    
    /* Fix for iOS Safari input shadows */
    .form-control,
    input,
    textarea,
    select {
        -webkit-appearance: none;
        -webkit-border-radius: 8px;
    }
    
    /* Safe area adjustments for iPhone X+ */
    .mobile-bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .main-content {
        padding-bottom: calc(100px + env(safe-area-inset-bottom));
    }
}

/* Android Specific Styles */
@media screen and (-webkit-min-device-pixel-ratio: 1) {
    select.form-control {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    }
}

/* High DPI / Retina Display Adjustments */
@media (-webkit-min-device-pixel-ratio: 2),
       (min-resolution: 192dpi) {
    .avatar,
    .card img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Landscape Orientation */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .main-content {
        padding-top: 0.5rem;
    }
    
    .card {
        margin-bottom: 0.75rem;
    }
    
    .modal-content {
        max-height: calc(100vh - 1rem);
    }
    
    /* Reduce header height in landscape */
    .header-content {
        padding: 0.5rem 1rem;
    }
    
    .avatar {
        width: 32px;
        height: 32px;
    }
}

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

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid #000;
    }
    
    .btn-outline {
        border-width: 2px;
    }
    
    .form-control {
        border-width: 2px;
        border-color: #000;
    }
}

/* Dark Mode Preparations */
@media (prefers-color-scheme: dark) {
    /* Will be overridden by themes.css */
}

/* Mobile Navigation Specific Styles */
.mobile-nav-slide {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.mobile-nav-slide.active {
    transform: translateX(0);
}

/* Mobile Form Enhancements */
.mobile-form-floating {
    position: relative;
    margin-bottom: 1.5rem;
}

.mobile-form-floating input,
.mobile-form-floating textarea {
    width: 100%;
    padding: 1rem 1rem 0.5rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    background: white;
    transition: all 0.3s ease;
}

.mobile-form-floating input:focus,
.mobile-form-floating textarea:focus {
    border-color: #ff6b6b;
    outline: none;
}

.mobile-form-floating label {
    position: absolute;
    top: 1rem;
    left: 1rem;
    font-size: 1rem;
    color: #6c757d;
    pointer-events: none;
    transition: all 0.3s ease;
}

.mobile-form-floating input:focus + label,
.mobile-form-floating input:not(:placeholder-shown) + label,
.mobile-form-floating textarea:focus + label,
.mobile-form-floating textarea:not(:placeholder-shown) + label {
    top: 0.25rem;
    font-size: 0.75rem;
    color: #ff6b6b;
}

/* Mobile Image Gallery */
.mobile-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
    padding: 0.5rem;
}

@media (max-width: 480px) {
    .mobile-image-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 0.25rem;
        padding: 0.25rem;
    }
}

/* Mobile Chat Interface */
.mobile-chat-container {
    height: calc(100vh - 160px); /* Account for header and input */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem 0.5rem;
}

.mobile-chat-input {
    position: fixed;
    bottom: 80px; /* Above mobile nav */
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #eee;
    padding: 0.75rem;
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.mobile-chat-input input {
    flex: 1;
    border: 2px solid #e9ecef;
    border-radius: 20px;
    padding: 0.75rem 1rem;
    font-size: 16px;
    resize: none;
    max-height: 120px;
}

.mobile-chat-input button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #ff6b6b;
    color: white;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mobile Specific Utilities */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

@media (max-width: 767px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none;
    }
}

/* Mobile Scrollable Areas */
.mobile-scroll-container {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
}

/* Mobile Pull-to-Refresh */
.mobile-pull-refresh {
    position: relative;
    overflow: hidden;
}

.mobile-pull-refresh-indicator {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.mobile-pull-refresh.refreshing .mobile-pull-refresh-indicator {
    top: 10px;
}

/* Performance Optimizations */
.mobile-performance-layer {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

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