/**
 * Mobile Responsiveness CSS for People's Perception
 * Universal mobile styles for all pages
 * Created: 2025-09-22 12:10 PM
 */

/* ===== BASE MOBILE STYLES ===== */

/* Ensure proper viewport behavior */
* {
    box-sizing: border-box;
}

body {
    overflow-x: hidden;
}

/* ===== TABLET STYLES (768px and below) ===== */
@media (max-width: 768px) {
    
    /* Container adjustments */
    .container, .main-container, .content-container {
        padding: 15px !important;
        margin: 0 !important;
        max-width: 100% !important;
    }
    
    /* Header adjustments */
    h1 {
        font-size: 1.8rem !important;
        margin-bottom: 15px !important;
    }
    
    h2 {
        font-size: 1.5rem !important;
        margin-bottom: 12px !important;
    }
    
    h3 {
        font-size: 1.3rem !important;
        margin-bottom: 10px !important;
    }
    
    /* Button adjustments */
    .btn, button, .button {
        padding: 12px 20px !important;
        font-size: 0.9rem !important;
        margin: 5px !important;
        min-height: 44px !important; /* Touch target size */
    }
    
    /* Form elements */
    input[type="text"], input[type="email"], input[type="password"], 
    textarea, select {
        width: 100% !important;
        padding: 12px !important;
        font-size: 1rem !important;
        margin-bottom: 10px !important;
        min-height: 44px !important;
    }
    
    /* Grid layouts */
    .grid, .reports-grid, .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    /* Flex layouts */
    .flex-row {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    /* Cards and panels */
    .card, .panel, .report-card {
        margin-bottom: 15px !important;
        padding: 15px !important;
    }
    
    /* Navigation */
    .nav, .navigation {
        flex-direction: column !important;
    }
    
    .nav-item, .nav-link {
        width: 100% !important;
        text-align: center !important;
        padding: 12px !important;
    }
    
    /* Tables */
    table {
        font-size: 0.8rem !important;
    }
    
    th, td {
        padding: 8px 4px !important;
    }
    
    /* Images */
    img {
        max-width: 100% !important;
        height: auto !important;
    }
    
    /* Modal adjustments */
    .modal, .popup {
        width: 95% !important;
        max-width: 95% !important;
        max-height: 90vh !important;
        margin: 5vh auto !important;
        overflow-y: auto !important;
        position: fixed !important;
        top: 5vh !important;
        left: 2.5% !important;
        right: 2.5% !important;
        bottom: auto !important;
        z-index: 10001 !important;
    }
    
    .modal-content {
        padding: 15px !important;
        max-height: 80vh !important;
        overflow-y: auto !important;
    }
    
    /* Modal backdrop */
    .modal-backdrop, .modal-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background: rgba(0,0,0,0.8) !important;
        z-index: 10000 !important;
    }
}

/* ===== MOBILE STYLES (480px and below) ===== */
@media (max-width: 480px) {
    
    /* Even smaller containers */
    .container, .main-container, .content-container {
        padding: 10px !important;
    }
    
    /* Smaller headers */
    h1 {
        font-size: 1.5rem !important;
    }
    
    h2 {
        font-size: 1.3rem !important;
    }
    
    h3 {
        font-size: 1.1rem !important;
    }
    
    /* Smaller buttons */
    .btn, button, .button {
        padding: 10px 15px !important;
        font-size: 0.85rem !important;
    }
    
    /* Smaller form elements */
    input, textarea, select {
        padding: 10px !important;
        font-size: 0.9rem !important;
    }
    
    /* Smaller cards */
    .card, .panel, .report-card {
        padding: 12px !important;
    }
    
    /* Hide non-essential elements on very small screens */
    .hide-mobile {
        display: none !important;
    }
}

/* ===== PAGE-SPECIFIC MOBILE STYLES ===== */

/* INDEX PAGE */
@media (max-width: 768px) {
    .hero-section {
        padding: 30px 15px !important;
        text-align: center !important;
    }
    
    .hero-title {
        font-size: 2rem !important;
        margin-bottom: 15px !important;
    }
    
    .hero-subtitle {
        font-size: 1rem !important;
        margin-bottom: 20px !important;
    }
    
    .cta-button {
        width: 100% !important;
        max-width: 300px !important;
        margin: 10px auto !important;
        display: block !important;
    }
    
    .features-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    .feature-card {
        text-align: center !important;
        padding: 20px !important;
    }
}

/* SEARCH PAGE */
@media (max-width: 768px) {
    .search-container {
        padding: 15px !important;
    }
    
    .search-box {
        width: 100% !important;
        margin-bottom: 15px !important;
    }
    
    .search-results {
        grid-template-columns: 1fr !important;
    }
    
    .person-card {
        padding: 15px !important;
        margin-bottom: 15px !important;
    }
    
    .person-photo {
        width: 80px !important;
        height: 80px !important;
    }
    
    .person-info {
        margin-left: 15px !important;
    }
    
    .person-name {
        font-size: 1.1rem !important;
    }
    
    .person-stats {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    
    .view-report-btn {
        width: 100% !important;
        margin-top: 10px !important;
    }
}

/* DASHBOARD PAGE */
@media (max-width: 768px) {
    .dashboard-header {
        padding: 15px !important;
        text-align: center !important;
    }
    
    .profile-section {
        flex-direction: column !important;
        text-align: center !important;
    }
    
    .profile-photo {
        width: 120px !important;
        height: 120px !important;
        margin: 0 auto 15px auto !important;
    }
    
    .profile-info {
        width: 100% !important;
    }
    
    .stats-row {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .stat-card {
        width: 100% !important;
        text-align: center !important;
    }
    
    .action-buttons {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .action-button {
        width: 100% !important;
    }
}

/* EVALUATION INTERFACE */
@media (max-width: 768px) {
    .evaluation-container {
        padding: 10px !important;
    }
    
    .question-card {
        padding: 15px !important;
        margin-bottom: 15px !important;
    }
    
    .question-text {
        font-size: 1.1rem !important;
        margin-bottom: 15px !important;
    }
    
    .answer-options {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .answer-option {
        width: 100% !important;
        padding: 12px !important;
        text-align: center !important;
    }
    
    .progress-bar {
        margin: 15px 0 !important;
    }
    
    .navigation-buttons {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .nav-button {
        width: 100% !important;
    }
    
    .receipt-section {
        padding: 15px !important;
    }
    
    .upload-buttons {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .upload-button {
        width: 100% !important;
    }
}

/* REPORTS DASHBOARD */
@media (max-width: 768px) {
    .reports-container {
        padding: 10px !important;
    }
    
    .reports-header {
        padding: 15px !important;
        text-align: center !important;
    }
    
    .nav-tabs {
        flex-direction: column !important;
        gap: 5px !important;
    }
    
    .nav-tab {
        width: 100% !important;
        text-align: center !important;
    }
    
    .reports-grid {
        grid-template-columns: 1fr !important;
    }
    
    .gauge-container {
        width: 150px !important;
        height: 150px !important;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .rating-item {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
    
    .rating-bar {
        width: 100% !important;
        margin: 5px 0 !important;
    }
}

/* ===== UTILITY CLASSES ===== */

/* Show/hide on mobile */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
    
    .mobile-only {
        display: block !important;
    }
}

@media (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }
    
    .desktop-only {
        display: block !important;
    }
}

/* Mobile text alignment */
@media (max-width: 768px) {
    .mobile-center {
        text-align: center !important;
    }
    
    .mobile-left {
        text-align: left !important;
    }
    
    .mobile-right {
        text-align: right !important;
    }
}

/* Mobile spacing */
@media (max-width: 768px) {
    .mobile-mt-10 { margin-top: 10px !important; }
    .mobile-mb-10 { margin-bottom: 10px !important; }
    .mobile-p-10 { padding: 10px !important; }
    .mobile-p-15 { padding: 15px !important; }
}

/* Touch-friendly elements */
@media (max-width: 768px) {
    .touch-target {
        min-height: 44px !important;
        min-width: 44px !important;
    }
    
    .clickable {
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    }
}

/* Prevent horizontal scroll */
body, html {
    overflow-x: hidden;
    max-width: 100%;
}

/* Ensure images don't break layout */
img, video, iframe {
    max-width: 100%;
    height: auto;
}

/* ===== IPHONE AND IOS SPECIFIC FIXES ===== */

/* Fix iOS viewport issues */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific styles */
    .modal, .popup {
        position: fixed !important;
        top: 10px !important;
        left: 10px !important;
        right: 10px !important;
        bottom: 10px !important;
        width: auto !important;
        height: auto !important;
        max-height: calc(100vh - 20px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* Prevent zoom on input focus */
    input, textarea, select {
        font-size: 16px !important;
    }
    
    /* Fix iOS Safari bottom padding */
    body {
        padding-bottom: env(safe-area-inset-bottom) !important;
    }
    
    /* Fix modal content scrolling on iOS */
    .modal-content {
        max-height: calc(100vh - 100px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}

/* iPhone specific modal fixes */
@media screen and (max-device-width: 480px) and (-webkit-min-device-pixel-ratio: 2) {
    .modal, .popup {
        position: fixed !important;
        top: 5% !important;
        left: 5% !important;
        right: 5% !important;
        bottom: 5% !important;
        width: 90% !important;
        height: 90% !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
        border-radius: 12px !important;
        box-shadow: 0 4px 20px rgba(0,0,0,0.3) !important;
    }
    
    .modal-content {
        padding: 10px !important;
        height: 100% !important;
        overflow-y: auto !important;
        box-sizing: border-box !important;
    }
    
    /* Close button positioning for iPhone */
    .modal .close, .popup .close, .modal button[onclick*="remove"], .popup button[onclick*="remove"] {
        position: sticky !important;
        top: 0 !important;
        right: 0 !important;
        z-index: 1000 !important;
        background: white !important;
        border: none !important;
        font-size: 1.5rem !important;
        padding: 10px !important;
        margin: 0 !important;
        border-radius: 50% !important;
        width: 40px !important;
        height: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
}

/* Fix for fixed positioned elements on mobile */
@media (max-width: 768px) {
    .fixed-element {
        position: relative !important;
    }
    
    .back-button {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        margin: 10px !important;
        display: block !important;
        width: fit-content !important;
    }
    
    /* Prevent body scroll when modal is open */
    body.modal-open {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
    }
}

/* ===== PHOTO GALLERY MOBILE FIXES ===== */
@media (max-width: 768px) {
    /* Photo gallery modal specific */
    .photo-gallery-modal {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background: rgba(0,0,0,0.9) !important;
        z-index: 10000 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .photo-gallery-content {
        padding: 20px 10px !important;
        max-width: 100% !important;
    }
    
    .photo-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    
    .photo-item {
        aspect-ratio: 1 !important;
        border-radius: 8px !important;
        overflow: hidden !important;
    }
    
    .photo-item img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
}

/* ===== RECEIPT MODAL MOBILE FIXES ===== */
@media (max-width: 768px) {
    .receipt-modal {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .receipt-modal-content {
        margin: 10px !important;
        max-height: calc(100vh - 20px) !important;
        overflow-y: auto !important;
        border-radius: 12px !important;
    }
    
    .upload-section {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .upload-button {
        width: 100% !important;
        padding: 12px !important;
        font-size: 0.9rem !important;
    }
}

/* ===== THANK YOU POPUP MOBILE FIXES ===== */
@media (max-width: 768px) {
    /* Thank you popup overlay */
    #thankYouOverlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 20px !important;
        box-sizing: border-box !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* Thank you popup content */
    #thankYouOverlay > div {
        width: 95% !important;
        max-width: 95% !important;
        max-height: 90vh !important;
        padding: 20px !important;
        margin: auto !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        box-sizing: border-box !important;
    }
    
    /* Thank you popup heading */
    #thankYouOverlay h2 {
        font-size: 1.5rem !important;
        margin-bottom: 12px !important;
    }
    
    /* Thank you popup text */
    #thankYouOverlay p {
        font-size: 1rem !important;
        line-height: 1.5 !important;
        margin-bottom: 15px !important;
    }
    
    /* Thank you popup button */
    #thankYouOverlay button, #continueBtn {
        width: 100% !important;
        padding: 15px 20px !important;
        font-size: 1rem !important;
        margin-top: 10px !important;
        box-sizing: border-box !important;
        min-height: 50px !important;
    }
    
    /* Thank you popup logo */
    #thankYouOverlay img {
        height: 40px !important;
        margin-bottom: 15px !important;
    }
    
    /* Thank you popup status box */
    #thankYouOverlay div[style*="background: #f8f9fa"] {
        padding: 12px !important;
        margin-bottom: 20px !important;
        border-radius: 8px !important;
    }
}

/* iPhone specific thank you popup fixes */
@media screen and (max-device-width: 480px) and (-webkit-min-device-pixel-ratio: 2) {
    #thankYouOverlay {
        padding: 10px !important;
    }
    
    #thankYouOverlay > div {
        width: 98% !important;
        max-height: 95vh !important;
        padding: 15px !important;
        border-radius: 12px !important;
    }
    
    #thankYouOverlay h2 {
        font-size: 1.3rem !important;
    }
    
    #thankYouOverlay p {
        font-size: 0.9rem !important;
    }
    
    #thankYouOverlay button {
        padding: 12px 15px !important;
        font-size: 0.9rem !important;
        min-height: 44px !important;
    }
}

/* iOS Safari specific fixes for thank you popup */
@supports (-webkit-touch-callout: none) {
    #thankYouOverlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        height: 100vh !important;
        height: -webkit-fill-available !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    #thankYouOverlay > div {
        margin: 20px auto !important;
        max-height: calc(100vh - 40px) !important;
        max-height: calc(-webkit-fill-available - 40px) !important;
    }
}
