/* Mobile Optimization CSS */

/* Viewport optimization */
@viewport {
    width: device-width;
    zoom: 1;
}

/* Touch-friendly tap targets */
button, a, input, select, textarea {
    min-height: 44px;
    min-width: 44px;
}

/* Optimize touch interactions */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* Mobile-first typography */
@media (max-width: 768px) {
    html {
        font-size: 16px;
    }
    
    body {
        font-size: 1rem;
        line-height: 1.5;
    }
    
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.1rem; }
    h5 { font-size: 1rem; }
    h6 { font-size: 0.875rem; }
}

/* Mobile navigation optimization */
@media (max-width: 768px) {
    .navbar {
        padding: 0.5rem 1rem;
    }
    
    .navbar-brand {
        font-size: 1.25rem;
    }
    
    .nav-link {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
    
    .dropdown-menu {
        font-size: 1rem;
        max-height: 80vh;
        overflow-y: auto;
    }
}

/* Mobile card optimization */
@media (max-width: 768px) {
    .card {
        margin-bottom: 1rem;
        border-radius: 0.5rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-title {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    .card-text {
        font-size: 0.95rem;
    }
}

/* Mobile image optimization */
@media (max-width: 768px) {
    img {
        max-width: 100%;
        height: auto;
    }
    
    .img-fluid {
        border-radius: 0.5rem;
    }
}

/* Mobile form optimization */
@media (max-width: 768px) {
    .form-control {
        font-size: 16px; /* Prevent iOS zoom */
        padding: 0.75rem;
    }
    
    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .btn-group .btn {
        width: auto;
    }
}

/* Mobile table optimization */
@media (max-width: 768px) {
    .table-responsive {
        border: none;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .table thead {
        display: none;
    }
    
    .table tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #dee2e6;
        border-radius: 0.5rem;
        padding: 0.75rem;
    }
    
    .table tbody td {
        display: block;
        text-align: right;
        padding: 0.25rem 0;
        border: none;
    }
    
    .table tbody td::before {
        content: attr(data-label);
        float: left;
        font-weight: bold;
        text-align: left;
    }
}

/* Mobile pagination optimization */
@media (max-width: 768px) {
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .page-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
}

/* Mobile modal optimization */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: 100%;
    }
    
    .modal-content {
        border-radius: 0.5rem;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-footer {
        padding: 1rem;
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
}

/* Mobile alert optimization */
@media (max-width: 768px) {
    .alert {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
        border-radius: 0.5rem;
    }
}

/* Mobile badge optimization */
@media (max-width: 768px) {
    .badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
}

/* Mobile skeleton loading */
@media (max-width: 768px) {
    .skeleton {
        background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
        background-size: 200% 100%;
        animation: skeleton-loading 1.5s infinite;
    }
    
    @keyframes skeleton-loading {
        0% { background-position: 200% 0; }
        100% { background-position: -200% 0; }
    }
}

/* Mobile pull-to-refresh */
@media (max-width: 768px) {
    body {
        overscroll-behavior-y: contain;
    }
}

/* Mobile safe area support */
@supports (padding: max(0px)) {
    .safe-area-top {
        padding-top: max(1rem, env(safe-area-inset-top));
    }
    
    .safe-area-bottom {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    
    .safe-area-left {
        padding-left: max(1rem, env(safe-area-inset-left));
    }
    
    .safe-area-right {
        padding-right: max(1rem, env(safe-area-inset-right));
    }
}

/* Mobile horizontal scroll optimization */
@media (max-width: 768px) {
    .horizontal-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
    }
    
    .horizontal-scroll > * {
        scroll-snap-align: start;
    }
}

/* Mobile video optimization */
@media (max-width: 768px) {
    video, iframe {
        max-width: 100%;
        height: auto;
        aspect-ratio: 16 / 9;
    }
}

/* Mobile text selection */
@media (max-width: 768px) {
    ::selection {
        background: #dc3545;
        color: white;
    }
}

/* Mobile focus states */
@media (max-width: 768px) {
    :focus {
        outline: 2px solid #dc3545;
        outline-offset: 2px;
    }
    
    :focus:not(:focus-visible) {
        outline: none;
    }
}

/* Mobile loading states */
@media (max-width: 768px) {
    .loading {
        position: relative;
        opacity: 0.6;
        pointer-events: none;
    }
    
    .loading::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 20px;
        height: 20px;
        margin: -10px 0 0 -10px;
        border: 2px solid #dc3545;
        border-radius: 50%;
        border-top-color: transparent;
        animation: spin 0.8s linear infinite;
    }
    
    @keyframes spin {
        to { transform: rotate(360deg); }
    }
}

/* Mobile sticky elements */
@media (max-width: 768px) {
    .sticky-top {
        position: sticky;
        top: 0;
        z-index: 1000;
    }
    
    .sticky-bottom {
        position: sticky;
        bottom: 0;
        z-index: 1000;
    }
}

/* Mobile grid optimization */
@media (max-width: 768px) {
    .row {
        margin: -0.5rem;
    }
    
    .col, .col-1, .col-2, .col-3, .col-4, .col-5, .col-6, 
    .col-7, .col-8, .col-9, .col-10, .col-11, .col-12 {
        padding: 0.5rem;
    }
}

/* Mobile utility classes */
@media (max-width: 768px) {
    .d-mobile-none {
        display: none !important;
    }
    
    .d-mobile-block {
        display: block !important;
    }
    
    .d-mobile-flex {
        display: flex !important;
    }
    
    .text-mobile-center {
        text-align: center !important;
    }
    
    .w-mobile-100 {
        width: 100% !important;
    }
}
