/* AOE II Traveller - Mobile Styles */
/* Responsive design for tablets and mobile devices */

/* Tablet Styles (768px and below) */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }

    /* Header Adjustments */
    .header {
        padding: 1rem 0.75rem;
    }

    .header-content {
        flex-direction: column;
        gap: 12px;
    }

    .logo {
        font-size: 1.3rem;
        gap: 10px;
    }

    .logo-icon {
        width: 32px;
        height: 32px;
    }

    .logo-icon::before {
        font-size: 1.5rem;
        line-height: 32px;
    }

    .logo::before, .logo::after {
        display: none;
    }

    .stats {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        font-size: 0.75rem;
    }

    .stat-item {
        padding: 6px 10px;
        gap: 6px;
        min-width: auto;
        flex-shrink: 1;
    }

    .badge {
        font-size: 0.7rem;
        padding: 2px 6px;
    }

    /* Map Controls - Move to Bottom Right */
    .map-controls {
        position: fixed;
        top: auto;
        bottom: 90px;
        right: 10px;
        left: auto;
    }

    .control-btn {
        padding: 10px 12px;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    /* Admin Controls - Bottom Right */
    .admin-controls {
        position: fixed;
        top: auto;
        bottom: 90px;
        right: 10px;
        left: auto;
        max-width: 180px;
    }

    .admin-controls .btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    /* Auth Panel - Centered */
    .auth-panel {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        right: auto;
        margin: 0;
        width: 90%;
        max-width: 300px;
        padding: 15px;
    }

    /* Campaign Filters - Centered */
    .campaign-filters {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        right: auto;
        width: 90%;
        max-width: 280px;
    }

    /* Filter Indicator - Top Left */
    .filter-indicator {
        position: fixed;
        top: 140px;
        left: 10px;
        right: auto;
        max-width: 250px;
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    /* Secret Access - Responsive */
    .secret-access {
        width: 90%;
        max-width: 300px;
        padding: 15px;
    }

    /* Legend - Bottom Left */
    .legend {
        position: fixed;
        bottom: 90px;
        left: 10px;
        right: auto;
        max-width: 180px;
        padding: 10px;
        font-size: 0.75rem;
    }

    .legend h4 {
        font-size: 0.85rem;
        margin-bottom: 6px;
    }

    .legend-item {
        margin: 3px 0;
        font-size: 0.7rem;
    }

    .legend-marker {
        width: 12px;
        height: 12px;
    }

    /* Map Container */
    .map-container {
        margin-top: 110px;
        height: calc(100vh - 170px);
    }

    #map {
        height: 100%;
        width: 100%;
    }

    /* Footer */
    .footer {
        position: fixed;
        padding: 8px 10px;
        font-size: 0.7rem;
        display: flex;
        flex-direction: column;
        gap: 4px;
        text-align: center;
    }

    .footer span, .footer a {
        display: block;
        margin: 0;
    }

    /* Modal improvements for tablet - RESPONSIVE ABSOLUTE POSITIONING */
    .modal {
        padding: 15px;
    }

    .modal-content {
        width: calc(100% - 30px);
        max-width: 380px;
        padding: 18px;
        max-height: calc(100vh - 60px);
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    /* Wonder Popup Mobile */
    .wonder-popup {
        min-width: 250px;
        max-width: 280px;
    }

    .wonder-header {
        gap: 8px;
        margin-bottom: 8px;
    }

    .civ-flag {
        width: 35px;
        height: 25px;
        font-size: 0.7rem;
    }

    .wonder-info h3 {
        font-size: 1rem;
        line-height: 1.2;
    }

    .wonder-info .civilization {
        font-size: 0.8rem;
    }

    .detail-row {
        margin: 6px 0;
        padding: 3px 0;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .detail-label {
        font-size: 0.8rem;
    }

    .wonder-actions {
        flex-direction: column;
        gap: 8px;
        margin-top: 10px;
    }

    .wonder-actions .btn {
        font-size: 0.8rem;
        padding: 8px 12px;
        justify-content: center;
    }

    /* Multi-wonder popup mobile */
    .multi-wonder-popup {
        min-width: 280px;
        max-width: 320px;
    }

    .wonder-list {
        max-height: 200px;
    }

    .wonder-item-title {
        font-size: 0.85rem;
    }

    .wonder-item-civ {
        font-size: 0.65rem;
        padding: 1px 6px;
    }

    /* Form improvements for tablet */
    .form-group input, .form-group select, .form-group textarea {
        padding: 10px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .coordinate-inputs {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .btn {
        padding: 12px 16px;
        font-size: 0.9rem;
        justify-content: center;
    }

    /* Photo gallery mobile */
    .photo-gallery {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 3px;
    }

    /* Undo button mobile */
    .undo-button {
        bottom: 100px;
        right: 15px;
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    /* Notification mobile */
    .notification {
        width: 90%;
        max-width: 300px;
        padding: 12px 15px;
        font-size: 0.85rem;
    }

    /* Map click mode mobile */
    .map-click-mode {
        width: 90%;
        max-width: 280px;
        padding: 10px 15px;
        font-size: 0.85rem;
    }

    /* Stats grid mobile */
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    /* Card adjustments */
    .card {
        padding: 15px;
    }

    .card-title {
        font-size: 1.1rem;
    }

    /* Upload Zone Mobile */
    .photo-upload-zone {
        padding: 25px 20px;
        min-height: 100px;
    }
    
    .upload-icon {
        font-size: 2.2rem;
    }
    
    .upload-text {
        font-size: 0.95rem;
    }
    
    .upload-subtext {
        font-size: 0.8rem;
        line-height: 1.4;
    }
    
    /* File Preview Mobile */
    .file-preview-container {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
        max-height: 250px;
    }
    
    .file-preview .remove-btn,
    .file-preview .highlight-btn {
        transform: scale(0.9);
    }
    
    .file-info {
        padding: 6px;
        font-size: 0.65rem;
    }
    
    /* Photo Gallery Mobile */
    .photo-gallery-enhanced {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }
    
    .photo-item-enhanced:hover {
        transform: scale(1.02); /* Reduced scale for mobile */
    }
    
    /* Photo Modal Mobile */
    .photo-modal {
        padding: 15px;
    }
    
    .photo-modal-content {
        max-width: 98vw;
        max-height: 98vh;
        margin: 5px auto;
        border-radius: 15px;
    }
    
    .photo-modal-header {
        padding: 15px 20px;
    }
    
    .photo-modal-header h3 {
        font-size: 1rem;
        line-height: 1.3;
    }
    
    .photo-modal-image {
        max-height: 70vh;
    }
    
    .photo-modal-controls {
        flex-direction: column;
        gap: 10px;
        padding: 15px 20px;
    }
    
    .photo-modal-controls .btn {
        font-size: 0.9rem;
        padding: 12px 16px;
        justify-content: center;
        width: 100%;
    }
    
    /* Progress Mobile */
    .upload-progress-container {
        padding: 15px;
        margin-top: 12px;
    }
    
    .progress-text {
        font-size: 0.85rem;
    }
    
    .progress-status {
        font-size: 0.75rem;
    }
    
    /* Form Mobile */
    .wonder-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .wonder-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Large Mobile Phones (480px and below) */
@media (max-width: 480px) {
    .header {
        padding: 0.75rem 0.5rem;
    }

    .logo {
        font-size: 1.1rem;
    }

    .logo-icon {
        width: 28px;
        height: 28px;
    }

    .logo-icon::before {
        font-size: 1.2rem;
        line-height: 28px;
    }

    .stats {
        gap: 6px;
        font-size: 0.7rem;
    }

    .stat-item {
        padding: 4px 8px;
        gap: 4px;
    }

    .legend {
        max-width: 150px;
        padding: 8px;
    }

    .map-controls, .admin-controls {
        max-width: 150px;
    }

    .control-btn, .admin-controls .btn {
        padding: 8px 10px;
        font-size: 0.75rem;
    }

    .footer {
        font-size: 0.65rem;
        padding: 6px 8px;
    }

    .wonder-popup {
        min-width: 200px;
        max-width: 240px;
    }

    .modal {
        padding: 10px;
    }

    .modal-content {
        padding: 15px;
        width: calc(100% - 20px);
        max-width: 300px;
        max-height: calc(100vh - 40px);
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    .undo-button {
        width: 45px;
        height: 45px;
        font-size: 1rem;
    }

    /* Form adjustments for small screens */
    .form-group label {
        font-size: 0.9rem;
    }

    .form-group input, .form-group select, .form-group textarea {
        font-size: 16px;
        padding: 8px;
    }

    .btn {
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    /* Multi-wonder popup adjustments */
    .multi-wonder-popup {
        min-width: 220px;
        max-width: 260px;
    }

    .wonder-item-title {
        font-size: 0.8rem;
    }

    .wonder-item-badges .badge {
        font-size: 0.65rem;
        padding: 1px 4px;
    }

    /* Navigation improvements */
    .auth-panel, .campaign-filters {
        max-width: 260px;
    }

    .filter-indicator {
        max-width: 200px;
        font-size: 0.75rem;
    }

    /* Grid system for small screens */
    .grid-2, .grid-3, .grid-4, .grid-auto {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    /* Card system */
    .card {
        padding: 12px;
    }

    .card-title {
        font-size: 1rem;
    }

    .card-subtitle {
        font-size: 0.8rem;
    }

    /* Wonder actions mobile */
    .wonder-actions {
        gap: 6px;
    }

    .wonder-actions .btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    /* Notification adjustments */
    .notification {
        font-size: 0.8rem;
        padding: 10px 12px;
    }

    /* Medieval confirm dialog */
    .medieval-confirm-content {
        padding: 20px;
    }

    .medieval-confirm h3 {
        font-size: 1.1rem;
    }

    .medieval-confirm-actions {
        flex-direction: column;
        gap: 10px;
    }

    .medieval-confirm-actions .btn {
        width: 100%;
    }

    /* Upload Zone Small Mobile */
    .photo-upload-zone {
        padding: 20px 15px;
        min-height: 90px;
    }
    
    .upload-icon {
        font-size: 2rem;
    }
    
    .upload-text {
        font-size: 0.9rem;
    }
    
    .upload-subtext {
        font-size: 0.75rem;
        line-height: 1.3;
        padding: 0 5px;
    }
    
    /* File Preview Small Mobile */
    .file-preview-container {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 8px;
        max-height: 200px;
    }
    
    .file-preview .remove-btn {
        width: 20px;
        height: 20px;
        font-size: 0.7rem;
        top: 5px;
        right: 5px;
    }
    
    .file-preview .highlight-btn {
        padding: 2px 6px;
        font-size: 0.6rem;
        top: 5px;
        left: 5px;
    }
    
    .file-info {
        padding: 4px;
        font-size: 0.6rem;
    }
    
    .file-size {
        font-size: 0.65rem;
    }
    
    .file-type {
        font-size: 0.55rem;
    }
    
    /* Photo Gallery Small Mobile */
    .photo-gallery-enhanced {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 8px;
    }
    
    .photo-control-btn {
        padding: 2px 6px;
        font-size: 0.65rem;
        margin: 1px;
    }
    
    .highlight-indicator {
        width: 20px;
        height: 20px;
        font-size: 0.7rem;
        top: 5px;
        right: 5px;
    }
    
    .photo-info-overlay {
        padding: 6px;
        font-size: 0.6rem;
    }
    
    .photo-size {
        font-size: 0.65rem;
    }
    
    .photo-date {
        font-size: 0.55rem;
    }
    
    /* Photo Modal Small Mobile */
    .photo-modal {
        padding: 10px;
    }
    
    .photo-modal-content {
        border-radius: 12px;
    }
    
    .photo-modal-header {
        padding: 12px 15px;
    }
    
    .photo-modal-header h3 {
        font-size: 0.9rem;
    }
    
    .modal-close-btn {
        font-size: 1.3rem;
        padding: 2px;
    }
    
    .photo-modal-image {
        max-height: 65vh;
    }
    
    .photo-modal-controls {
        padding: 12px 15px;
        gap: 8px;
    }
    
    .photo-modal-controls .btn {
        font-size: 0.85rem;
        padding: 10px 14px;
    }
    
    /* Progress Small Mobile */
    .upload-progress-container {
        padding: 12px;
        border-radius: 8px;
    }
    
    .progress-bar-container {
        height: 8px;
        margin: 10px 0;
    }
    
    .progress-text {
        font-size: 0.8rem;
    }
    
    .progress-status {
        font-size: 0.7rem;
    }
    
    /* Form Small Mobile */
    .form-group label {
        font-size: 0.9rem;
    }
    
    .wonder-actions .btn {
        font-size: 0.85rem;
        padding: 10px 16px;
    }
    
    /* Empty State Mobile */
    .photo-gallery-empty {
        padding: 15px;
        font-size: 0.85rem;
    }
    
    .photo-gallery-empty i {
        font-size: 1.5rem;
        margin-bottom: 8px;
    }
}

/* Very Small Screens (360px and below) */
@media (max-width: 360px) {
    .header {
        padding: 0.5rem;
    }

    .logo {
        font-size: 1rem;
        gap: 8px;
    }

    .logo-icon {
        width: 24px;
        height: 24px;
    }

    .logo-icon::before {
        font-size: 1rem;
        line-height: 24px;
    }

    .stats {
        gap: 4px;
        font-size: 0.65rem;
    }

    .stat-item {
        padding: 3px 6px;
        gap: 3px;
    }

    .badge {
        font-size: 0.6rem;
        padding: 1px 3px;
    }

    .admin-indicator {
        font-size: 0.6rem;
        padding: 2px 6px;
    }

    .legend {
        max-width: 120px;
        padding: 6px;
        font-size: 0.65rem;
    }

    .legend h4 {
        font-size: 0.75rem;
    }

    .legend-item {
        font-size: 0.6rem;
        margin: 2px 0;
    }

    .legend-marker {
        width: 10px;
        height: 10px;
    }

    .map-controls, .admin-controls {
        max-width: 120px;
    }

    .control-btn, .admin-controls .btn {
        padding: 6px 8px;
        font-size: 0.7rem;
    }

    .footer {
        font-size: 0.6rem;
        padding: 4px 6px;
    }

    .wonder-popup {
        min-width: 180px;
        max-width: 200px;
    }

    .civ-flag {
        width: 28px;
        height: 20px;
        font-size: 0.6rem;
    }

    .wonder-info h3 {
        font-size: 0.9rem;
    }

    .detail-label {
        font-size: 0.7rem;
    }

    .modal {
        padding: 8px;
    }

    .modal-content {
        padding: 12px;
        width: calc(100% - 16px);
        max-width: 260px;
        max-height: calc(100vh - 32px);
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    .modal-content h2 {
        font-size: 1.1rem;
    }

    .form-group input, .form-group select, .form-group textarea {
        padding: 6px;
        font-size: 16px;
    }

    .btn {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .undo-button {
        width: 40px;
        height: 40px;
        font-size: 0.9rem;
        bottom: 95px;
    }

    .notification {
        font-size: 0.75rem;
        padding: 8px 10px;
    }

    .map-click-mode {
        font-size: 0.75rem;
        padding: 8px 12px;
    }

    /* Multi-wonder popup very small */
    .multi-wonder-popup {
        min-width: 180px;
        max-width: 200px;
    }

    .wonder-list {
        max-height: 150px;
    }

    .wonder-item-title {
        font-size: 0.75rem;
    }

    .wonder-item-civ {
        font-size: 0.6rem;
        padding: 1px 4px;
    }

    .wonder-item-badges .badge {
        font-size: 0.6rem;
        padding: 0px 3px;
    }

    .photo-upload-zone {
        padding: 15px 10px;
        min-height: 80px;
    }
    
    .upload-icon {
        font-size: 1.8rem;
    }
    
    .upload-text {
        font-size: 0.85rem;
    }
    
    .upload-subtext {
        font-size: 0.7rem;
    }
    
    .file-preview-container {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 6px;
    }
    
    .photo-gallery-enhanced {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 6px;
    }
    
    .photo-modal-controls .btn {
        font-size: 0.8rem;
        padding: 8px 12px;
    }
}

/* Landscape Mobile Optimization */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        padding: 0.5rem;
    }

    .header-content {
        flex-direction: row;
        gap: 15px;
    }

    .stats {
        gap: 8px;
        font-size: 0.7rem;
    }

    .map-container {
        margin-top: 70px;
        height: calc(100vh - 120px);
    }

    .legend {
        bottom: 60px;
        padding: 8px;
        font-size: 0.7rem;
    }

    .map-controls, .admin-controls {
        bottom: 60px;
    }

    .footer {
        padding: 4px 8px;
        font-size: 0.6rem;
    }

    .modal-content {
        max-height: 90vh;
        padding: 15px;
    }

    .wonder-popup {
        min-width: 220px;
        max-width: 250px;
    }

    .multi-wonder-popup {
        max-height: 300px;
    }

    .wonder-list {
        max-height: 180px;
    }

    .photo-modal-image {
        max-height: 85vh;
    }
    
    .photo-modal-header {
        padding: 10px 20px;
    }
    
    .photo-modal-controls {
        padding: 10px 20px;
        flex-direction: row;
    }
    
    .photo-modal-controls .btn {
        width: auto;
        flex: 1;
    }
}

/* High DPI Display Adjustments */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo-icon::before {
        text-rendering: optimizeLegibility;
        -webkit-font-smoothing: antialiased;
    }

    .btn, .control-btn {
        -webkit-font-smoothing: antialiased;
    }

    .legend-marker {
        border-width: 1px;
    }

    .civ-flag {
        -webkit-font-smoothing: antialiased;
    }
}

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

    .pulse, .mumbai-marker {
        animation: none !important;
    }

    .btn::before {
        transition: none !important;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .modal-content {
        background: var(--dark-background);
        color: var(--cream);
        border-color: var(--primary-gold);
    }

/* Touch Device Optimizations */
@media (pointer: coarse) {
    .btn, .control-btn {
        min-height: 44px;
        padding: 12px 16px;
    }

    .form-group input, .form-group select, .form-group textarea {
        min-height: 44px;
        padding: 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .undo-button {
        min-width: 54px;
        min-height: 54px;
    }
}

/* Touch Optimizations */
@media (hover: none) {
    /* Remove hover effects on touch devices */
    .photo-item-enhanced:hover {
        transform: none;
        box-shadow: var(--photo-shadow);
    }
    
    .file-preview:hover {
        transform: none;
        border-color: #e5e7eb;
    }
    
    /* Always show controls on touch devices */
    .photo-item-enhanced .photo-controls,
    .photo-item-enhanced .photo-info-overlay {
        opacity: 1;
    }
    
    /* Larger touch targets */
    .photo-control-btn {
        min-width: 32px;
        min-height: 32px;
        padding: 6px 10px;
    }
    
    .file-preview .remove-btn,
    .file-preview .highlight-btn {
        min-width: 28px;
        min-height: 28px;
    }
    
    .modal-close-btn {
        min-width: 44px;
        min-height: 44px;
    }
}

/* iOS Safe Area Support */
@supports (padding: max(0px)) {
    .header {
        padding-top: max(1.5rem, env(safe-area-inset-top));
        padding-left: max(1.5rem, env(safe-area-inset-left));
        padding-right: max(1.5rem, env(safe-area-inset-right));
    }

    .footer {
        padding-bottom: max(15px, env(safe-area-inset-bottom));
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }

    .map-controls, .admin-controls {
        right: max(10px, env(safe-area-inset-right));
    }

    .legend, .filter-indicator {
        left: max(10px, env(safe-area-inset-left));
    }

    .undo-button {
        right: max(15px, env(safe-area-inset-right));
    }
}