/* Tablet-Optimized Styles */
/* Specific optimizations for tablet devices */

/* Tablet Breakpoints */
/* Small tablets: 768px - 991px */
/* Large tablets: 992px - 1199px */

/* Touch Target Sizes */
/* Minimum: 44x44px (iOS), 48x48px (Android) */
/* Recommended: 56x56px for primary actions */

@media (min-width: 768px) {
    /* Larger Typography for Tablets */
    body {
        font-size: 18px;
    }

    h1 {
        font-size: 2.5rem;
    }

    h2 {
        font-size: 2rem;
    }

    h3 {
        font-size: 1.75rem;
    }

    /* Grid Adjustments */
    .job-card {
        width: calc(50% - 1rem);
        display: inline-block;
        vertical-align: top;
    }

    /* Increased Spacing */
    .container-fluid {
        padding: 2rem;
    }

    /* Larger Icons */
    .bi {
        font-size: 1.5rem;
    }
}

/* Landscape Orientation Optimizations */
@media (orientation: landscape) and (min-width: 768px) {
    /* Use horizontal space efficiently */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        background: white;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
        overflow-y: auto;
    }

    .main-content {
        margin-left: 280px;
        padding: 2rem;
    }

    /* Two-column layouts */
    .detail-view {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }
}

/* Portrait Orientation Optimizations */
@media (orientation: portrait) and (min-width: 768px) {
    /* Stack vertically with larger touch targets */
    .btn-lg-tablet {
        width: 100%;
        margin-bottom: 1rem;
    }

    /* Full-width cards */
    .job-card {
        width: 100%;
    }
}

/* Touch-Specific Styles */
@media (pointer: coarse) {
    /* Larger touch targets */
    .btn, button {
        min-height: 56px;
        padding: 1rem 2rem;
        font-size: 1.125rem;
    }

    /* Larger form inputs */
    .form-control, input, select, textarea {
        min-height: 56px;
        padding: 1rem;
        font-size: 1.125rem;
    }

    /* Larger checkboxes and radio buttons */
    input[type="checkbox"], input[type="radio"] {
        width: 24px;
        height: 24px;
    }

    /* Increase spacing between interactive elements */
    .btn + .btn {
        margin-left: 1rem;
    }

    /* Remove hover effects on touch devices */
    .hover-lift:hover {
        transform: none;
    }

    /* Add active state instead */
    .hover-lift:active {
        transform: scale(0.98);
    }
}

/* iPad Specific (1024x768) */
@media only screen 
    and (min-device-width: 768px) 
    and (max-device-width: 1024px) {
    
    /* Optimize for iPad resolution */
    .container {
        max-width: 960px;
    }

    /* Three-column layout for lists */
    .parts-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }

    /* Larger camera preview */
    .camera-preview {
        max-width: 800px;
    }

    /* Scanner size */
    .scanner-container {
        max-width: 600px;
    }
}

/* Surface Tablets (1366x768) */
@media only screen 
    and (min-device-width: 1280px) {
    
    /* Utilize wider screen */
    .container {
        max-width: 1200px;
    }

    /* Four-column layout */
    .parts-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 2rem;
    }

    /* Side-by-side views */
    .split-view {
        display: grid;
        grid-template-columns: 400px 1fr;
        gap: 2rem;
    }
}

/* Prevent Text Selection on UI Elements */
.btn, button, .card, .nav-item {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

/* Allow Text Selection in Content Areas */
.content-area, p, .text-selectable {
    -webkit-user-select: text;
    -moz-user-select: text;
    user-select: text;
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Optimize Scrolling Performance */
.scroll-container {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    will-change: scroll-position;
}

/* Hide Scrollbars for Cleaner Look (Optional) */
.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Tablet-Optimized Navbar */
.navbar-tablet {
    height: 72px;
    padding: 0.75rem 2rem;
}

.navbar-tablet .nav-link {
    padding: 1rem 1.5rem;
    font-size: 1.125rem;
}

/* Bottom Navigation for Tablets */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    min-height: 72px;
    color: #64748b;
    text-decoration: none;
    transition: all 0.2s ease;
}

.bottom-nav-item:active {
    transform: scale(0.95);
}

.bottom-nav-item.active {
    color: #fbbf24;
}

.bottom-nav-item i {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.bottom-nav-item span {
    font-size: 0.875rem;
}

/* Full-Screen Modal for Tablets */
.modal-fullscreen-tablet {
    max-width: 100%;
    margin: 0;
    height: 100vh;
}

.modal-fullscreen-tablet .modal-content {
    height: 100vh;
    border-radius: 0;
}

/* Swipe Gestures Helper */
.swipeable {
    touch-action: pan-y;
    -webkit-user-select: none;
    user-select: none;
}

/* Loading Skeleton for Better Perceived Performance */
.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
}

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

/* Optimized Card Grid */
.card-grid {
    display: grid;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Safe Area Insets for Notched Devices */
@supports (padding: max(0px)) {
    .safe-area-inset-top {
        padding-top: max(1rem, env(safe-area-inset-top));
    }

    .safe-area-inset-bottom {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .safe-area-inset-left {
        padding-left: max(1rem, env(safe-area-inset-left));
    }

    .safe-area-inset-right {
        padding-right: max(1rem, env(safe-area-inset-right));
    }
}

/* Accessibility - Focus Visible */
*:focus-visible {
    outline: 3px solid #fbbf24;
    outline-offset: 2px;
}

/* Reduce Motion for Users Who Prefer It */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark Mode Support (Optional) */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #60a5fa;
        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --light-bg: #0f172a;
        --border-color: #334155;
    }

    body {
        background-color: var(--dark-bg);
        color: var(--text-primary);
    }

    .card, .job-card, .part-item {
        background-color: #1e293b;
        border-color: var(--border-color);
    }
}
