/**
 * Mobile Native Framework CSS
 * Purpose: Create 100% native app-like mobile experience
 * Version: 2.0.0
 * Mobile-First Design System
 */

/* ===================================
   NATIVE MOBILE BASE RESETS
   =================================== */

/* iOS-style smooth scrolling */
html {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Native app-like viewport */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    overscroll-behavior: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Allow text selection in content areas */
.content-area,
.question-text,
.option-text,
input,
textarea {
    -webkit-user-select: text;
    user-select: text;
}

/* ===================================
   NATIVE TOUCH INTERACTIONS
   =================================== */

/* iOS-style touch feedback */
.touchable {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.15s ease;
}

.touchable:active {
    transform: scale(0.98);
    opacity: 0.8;
}

/* Native button styles */
.native-button {
    background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.15s ease;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.native-button:active {
    background: linear-gradient(180deg, #f3f4f6 0%, #e5e7eb 100%);
    transform: scale(0.98);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.native-button.primary {
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    border-color: #2563eb;
    color: white;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.native-button.primary:active {
    background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
    transform: scale(0.98);
}

/* ===================================
   NATIVE CARD COMPONENTS
   =================================== */

.native-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 16px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.native-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.native-card-header {
    padding: 20px 20px 0 20px;
    border-bottom: 1px solid #f3f4f6;
}

.native-card-body {
    padding: 20px;
}

.native-card-footer {
    padding: 0 20px 20px 20px;
    border-top: 1px solid #f3f4f6;
}

/* ===================================
   NATIVE NAVIGATION SYSTEM
   =================================== */

/* Enhanced mobile bottom navigation */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.mobile-bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    text-decoration: none;
    color: #6b7280;
    transition: all 0.2s ease;
    font-size: 12px;
    font-weight: 500;
    gap: 4px;
    position: relative;
    min-height: 60px;
}

.mobile-bottom-nav .nav-item i {
    font-size: 24px;
    transition: all 0.2s ease;
}

.mobile-bottom-nav .nav-item.active {
    color: #3b82f6;
}

.mobile-bottom-nav .nav-item.active i {
    transform: scale(1.1);
}

.mobile-bottom-nav .nav-item:active {
    transform: scale(0.95);
}

/* Native back button */
.native-back-button {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    left: 16px;
    z-index: 1001;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.native-back-button:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 1);
}

/* ===================================
   NATIVE FORM ELEMENTS
   =================================== */

.native-input {
    width: 100%;
    padding: 16px 20px;
    font-size: 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    background: white;
    transition: all 0.2s ease;
    min-height: 52px;
    -webkit-appearance: none;
    appearance: none;
}

.native-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.native-input::placeholder {
    color: #9ca3af;
}

/* Native select */
.native-select {
    width: 100%;
    padding: 16px 20px;
    font-size: 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    background: white 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 8 4 4 4-4'/%3e%3c/svg%3e") no-repeat right 16px center/16px;
    background-size: 16px;
    padding-right: 48px;
    min-height: 52px;
    -webkit-appearance: none;
    appearance: none;
}

/* ===================================
   NATIVE LIST COMPONENTS
   =================================== */

.native-list {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.native-list-item {
    padding: 20px;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.15s ease;
    cursor: pointer;
}

.native-list-item:last-child {
    border-bottom: none;
}

.native-list-item:active {
    background: #f9fafb;
    transform: scale(0.98);
}

.native-list-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #6b7280;
}

.native-list-item-content {
    flex: 1;
}

.native-list-item-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
}

.native-list-item-subtitle {
    font-size: 14px;
    color: #6b7280;
}

.native-list-item-arrow {
    color: #d1d5db;
    font-size: 16px;
}

/* ===================================
   NATIVE MODAL SYSTEM
   =================================== */

.native-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.native-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.native-modal {
    background: white;
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    transform: translateY(100%);
    transition: all 0.3s ease;
    overflow: hidden;
}

.native-modal-overlay.active .native-modal {
    transform: translateY(0);
}

.native-modal-header {
    padding: 20px 20px 0 20px;
    border-bottom: 1px solid #f3f4f6;
    position: relative;
}

.native-modal-title {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    text-align: center;
    margin-bottom: 16px;
}

.native-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 32px;
    height: 32px;
    border-radius: 16px;
    background: #f3f4f6;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.native-modal-close:active {
    transform: scale(0.9);
    background: #e5e7eb;
}

.native-modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.native-modal-footer {
    padding: 0 20px 20px 20px;
    border-top: 1px solid #f3f4f6;
}

/* ===================================
   NATIVE LOADING STATES
   =================================== */

.native-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.native-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f3f4f6;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: native-spin 1s linear infinite;
}

@keyframes native-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Skeleton loading */
.native-skeleton {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: native-skeleton-loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes native-skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.native-skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.native-skeleton-text.short {
    width: 60%;
}

.native-skeleton-text.medium {
    width: 80%;
}

.native-skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

/* ===================================
   NATIVE GESTURES & INTERACTIONS
   =================================== */

/* Pull to refresh */
.pull-to-refresh {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #3b82f6;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s ease;
    opacity: 0;
}

.pull-to-refresh.active {
    opacity: 1;
    transform: translateX(-50%) translateY(20px);
}

.pull-to-refresh.refreshing {
    animation: native-pulse 1s infinite;
}

@keyframes native-pulse {
    0%, 100% { transform: translateX(-50%) translateY(20px) scale(1); }
    50% { transform: translateX(-50%) translateY(20px) scale(1.1); }
}

/* Swipe indicators */
.swipe-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    opacity: 0;
    transition: all 0.2s ease;
    pointer-events: none;
}

.swipe-indicator.left {
    left: 20px;
}

.swipe-indicator.right {
    right: 20px;
}

.swipe-indicator.active {
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}

/* ===================================
   RESPONSIVE ADJUSTMENTS
   =================================== */

@media (max-width: 767px) {
    /* Ensure proper spacing on mobile */
    .container,
    .container-fluid {
        padding-left: 16px;
        padding-right: 16px;
    }
    
    /* Mobile-specific typography */
    h1, .h1 { font-size: 28px; line-height: 1.2; }
    h2, .h2 { font-size: 24px; line-height: 1.3; }
    h3, .h3 { font-size: 20px; line-height: 1.3; }
    h4, .h4 { font-size: 18px; line-height: 1.4; }
    h5, .h5 { font-size: 16px; line-height: 1.4; }
    h6, .h6 { font-size: 14px; line-height: 1.4; }
    
    /* Native button adjustments */
    .native-button {
        font-size: 16px;
        padding: 16px 24px;
        min-height: 52px;
    }
    
    /* Native input adjustments */
    .native-input,
    .native-select {
        font-size: 16px;
        padding: 18px 20px;
        min-height: 56px;
    }
    
    /* Native modal adjustments */
    .native-modal {
        border-radius: 24px 24px 0 0;
        max-height: 85vh;
    }
    
    .native-modal-header {
        padding: 24px 24px 0 24px;
    }
    
    .native-modal-body {
        padding: 24px;
        max-height: 65vh;
    }
    
    .native-modal-footer {
        padding: 0 24px 24px 24px;
    }
}

/* ===================================
   DARK MODE SUPPORT
   =================================== */

@media (prefers-color-scheme: dark) {
    .native-card {
        background: #1f2937;
        border-color: #374151;
    }
    
    .native-button {
        background: linear-gradient(180deg, #374151 0%, #1f2937 100%);
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .native-button.primary {
        background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    }
    
    .native-input,
    .native-select {
        background: #1f2937;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .native-input::placeholder {
        color: #6b7280;
    }
    
    .native-list {
        background: #1f2937;
    }
    
    .native-list-item {
        border-bottom-color: #374151;
    }
    
    .native-list-item:active {
        background: #374151;
    }
    
    .native-list-item-icon {
        background: #374151;
        color: #9ca3af;
    }
    
    .native-list-item-title {
        color: #f9fafb;
    }
    
    .native-list-item-subtitle {
        color: #9ca3af;
    }
    
    .native-modal {
        background: #1f2937;
    }
    
    .native-modal-header {
        border-bottom-color: #374151;
    }
    
    .native-modal-title {
        color: #f9fafb;
    }
    
    .native-modal-close {
        background: #374151;
        color: #9ca3af;
    }
    
    .mobile-bottom-nav {
        background: rgba(31, 41, 55, 0.95);
        border-top-color: rgba(255, 255, 255, 0.1);
    }
    
    .mobile-bottom-nav .nav-item {
        color: #9ca3af;
    }
    
    .mobile-bottom-nav .nav-item.active {
        color: #60a5fa;
    }
    
    .native-back-button {
        background: rgba(31, 41, 55, 0.9);
        border-color: rgba(255, 255, 255, 0.1);
        color: #f9fafb;
    }
}

/* ===================================
   ACCESSIBILITY ENHANCEMENTS
   =================================== */

/* Focus indicators */
.native-button:focus-visible,
.native-input:focus-visible,
.native-select:focus-visible,
.native-list-item:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .native-spinner {
        animation: none;
    }
    
    .native-skeleton {
        animation: none;
        background: #f3f4f6;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .native-button {
        border-width: 2px;
    }
    
    .native-input,
    .native-select {
        border-width: 2px;
    }
    
    .native-card {
        border: 2px solid #000;
    }
}

/* ===================================
   PRINT STYLES
   =================================== */

@media print {
    .mobile-bottom-nav,
    .native-back-button,
    .native-modal-overlay,
    .pull-to-refresh,
    .swipe-indicator {
        display: none !important;
    }
    
    .native-card {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .native-button {
        background: #fff !important;
        border: 1px solid #000 !important;
        color: #000 !important;
    }
}
