/* AR Interface Styles */

/* AR ChatGPT Tab Styles */
#arChatGPTTab {
    display: none; /* Hidden by default */
}

/* Mobile-Optimized AR Testing Panel */
.ar-testing-panel {
    background: rgba(7, 23, 63, 0.1);
    border: 2px solid #2E96F5;
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
}

.ar-testing-panel h3 {
    color: #2E96F5;
    margin-bottom: 15px;
    text-align: center;
}

.test-button-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.ar-test-btn {
    background: linear-gradient(45deg, #2E96F5, #0960E1);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.2s ease;
    min-height: 44px; /* iOS touch target minimum */
    white-space: nowrap;
}

.ar-test-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(9, 96, 225, 0.3);
}

.ar-test-btn:active {
    transform: translateY(0);
}

.ar-test-btn:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
}

.ar-test-results {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 15px;
}

.test-result-header {
    color: #2E96F5;
    font-weight: bold;
    margin-bottom: 10px;
}

.test-output {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.4;
    color: #00ff00;
    background: #000;
    padding: 10px;
    border-radius: 5px;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
}

/* Status indicator colors */
.ar-status-value.success {
    color: #2ecc71 !important;
    font-weight: bold;
}

.ar-status-value.warning {
    color: #f39c12 !important;
    font-weight: bold;
}

.ar-status-value.error {
    color: #e74c3c !important;
    font-weight: bold;
}

.ar-status-value.checking {
    color: #3498db !important;
    font-weight: bold;
}

/* Enhanced mobile touch targets */
.ar-action-btn, .ar-test-btn {
    min-height: 44px; /* iOS minimum touch target */
    min-width: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    user-select: none;
}

.ar-action-btn:active, .ar-test-btn:active {
    background-color: rgba(255,255,255,0.1);
    transform: scale(0.98);
}

/* Mobile-First AR Experience - Hide all tabs except AR ChatGPT */
@media (max-width: 768px) {
    /* Hide all tabs except AR ChatGPT on mobile */
    .tab:not([data-tab="ar-chatgpt"]) {
        display: none !important;
    }

    /* Hide all tab content except AR ChatGPT on mobile */
    .tab-content:not([data-tab="ar-chatgpt"]) {
        display: none !important;
    }

    /* Force tab container to show only AR tab on mobile always */
    .tab-container {
        display: flex !important;
        justify-content: center !important;
    }

    /* Hide navigation completely on mobile for AR-first experience */
    .navigation {
        display: none !important;
    }

    /* Make AR ChatGPT tab fullscreen on mobile always */
    #arChatGPTTab {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        z-index: 9999 !important;
        background: linear-gradient(135deg, #07173F, #1e3c72) !important;
        overflow-y: auto !important;
    }

    /* Hide main header completely on mobile */
    .app-header {
        display: none !important;
    }

    /* Optimize main container for mobile */
    .main-container {
        padding: 0 !important;
        margin: 0 !important;
        height: 100vh !important;
        height: 100dvh !important;
    }

    /* Adjust AR content for mobile */
    .ar-chatgpt-wrapper {
        padding-top: 15px !important;
        height: 100vh !important;
        height: 100dvh !important;
        overflow-y: auto !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    /* Hide tab navigation completely on mobile AR mode */
    body.mobile-ar-mode .tab-container {
        display: none !important;
    }

    /* Hide tab container on all mobile views */
    .tab-container {
        display: none !important;
        visibility: hidden !important;
    }

    /* Additional mobile-view class support */
    body.mobile-view .tab-container {
        display: none !important;
        visibility: hidden !important;
    }

    /* Hide navigation bar on mobile AR mode */
    body.mobile-ar-mode .navigation {
        display: none !important;
    }

    /* Force AR ChatGPT tab to be active on mobile */
    .tab[data-tab="ar-chatgpt"] {
        background: linear-gradient(135deg, #2E96F5, #0960E1);
        color: white;
        border: 2px solid #0960E1;
        flex: 1;
        justify-content: center;
        min-height: 60px;
        font-size: 18px;
        font-weight: bold;
    }

    /* Make tab container center the AR tab on mobile */
    .tab-container {
        justify-content: center;
        padding: 10px;
    }

    /* AR-specific mobile styling */
    .ar-testing-panel {
        margin: 15px 5px;
        padding: 15px;
    }

    .test-button-group {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .ar-test-btn {
        padding: 15px 10px;
        font-size: 16px;
        min-height: 50px;
    }

    .test-output {
        font-size: 12px;
        max-height: 150px;
    }

    .ar-features-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .ar-feature-card {
        padding: 20px;
    }

    .ar-action-btn {
        padding: 15px 20px;
        font-size: 16px;
        min-height: 50px;
        width: 100%;
    }

    /* Hide main header completely on mobile AR mode */
    body.mobile-ar-mode .app-header {
        display: none !important;
    }

    /* Hide header trigger zone on mobile */
    body.mobile-ar-mode .header-trigger {
        display: none !important;
    }

    /* Simplified Mobile AR header */
    body.mobile-ar-mode::after {
        content: "NASA Farm Navigators AR";
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 35px;
        background: linear-gradient(135deg,
            rgba(7, 23, 63, 0.9) 0%,
            rgba(46, 150, 245, 0.8) 100%);
        backdrop-filter: blur(8px);
        border-bottom: 1px solid rgba(234, 254, 7, 0.2);
        z-index: 10001;
        pointer-events: none;
        color: white;
        font-size: 14px;
        font-weight: 500;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
    }


    /* Make AR ChatGPT tab fullscreen on mobile */
    body.mobile-ar-mode #arChatGPTTab {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        z-index: 1000 !important;
        background: linear-gradient(135deg, #07173F, #1e3c72) !important;
        overflow-y: auto !important;
    }

    /* Optimize main container for mobile AR */
    body.mobile-ar-mode .main-container {
        padding: 0 !important;
        margin: 0 !important;
        height: 100vh !important;
        height: 100dvh !important;
    }

    /* Adjust AR content for mobile header */
    body.mobile-ar-mode .ar-chatgpt-wrapper {
        padding-top: 45px !important;
        height: calc(100vh - 35px) !important;
        height: calc(100dvh - 35px) !important;
        overflow-y: auto !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    /* Mobile AR touch optimizations */
    body.mobile-ar-mode .ar-test-btn {
        min-height: 48px !important;
        font-size: 16px !important;
        touch-action: manipulation !important;
    }

    /* Mobile AR scroll improvements */
    body.mobile-ar-mode #arChatGPTTab {
        -webkit-overflow-scrolling: touch !important;
        scroll-behavior: smooth !important;
    }
}

/* Desktop - Show all tabs normally */
@media (min-width: 769px) {
    .tab {
        display: flex !important;
    }

    .tab-content {
        display: block;
    }

    /* Desktop AR mode toggle button */
    .desktop-ar-toggle {
        position: fixed;
        bottom: 20px;
        right: 20px;
        background: linear-gradient(45deg, #2E96F5, #0960E1);
        color: white;
        border: none;
        padding: 12px 20px;
        border-radius: 50px;
        font-size: 14px;
        font-weight: bold;
        cursor: pointer;
        box-shadow: 0 4px 15px rgba(9, 96, 225, 0.4);
        z-index: 1000;
        transition: all 0.3s ease;
    }

    .desktop-ar-toggle:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(9, 96, 225, 0.6);
    }
}

/* Force mobile AR mode on desktop when toggled */
body.force-mobile-ar .tab:not([data-tab="ar-chatgpt"]) {
    display: none !important;
}

body.force-mobile-ar .tab-content:not([data-tab="ar-chatgpt"]) {
    display: none !important;
}

body.force-mobile-ar .tab[data-tab="ar-chatgpt"] {
    background: linear-gradient(135deg, #2E96F5, #0960E1);
    color: white;
    border: 2px solid #0960E1;
    flex: 1;
    justify-content: center;
    min-height: 60px;
    font-size: 18px;
    font-weight: bold;
}

body.force-mobile-ar::before {
    content: "🚀 NASA Farm Navigators - AR Experience (Desktop Preview)";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #0960E1, #2E96F5);
    color: white;
    text-align: center;
    padding: 15px;
    font-weight: bold;
    font-size: 16px;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

#arChatGPTTab.active {
    display: block !important; /* Force display when active */
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 1 !important;
}

.ar-chatgpt-wrapper {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
    min-height: 400px;
}

.ar-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.ar-feature-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    padding: 25px;
    text-align: center;
    color: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.ar-feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.ar-feature-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.ar-feature-card h3 {
    margin: 15px 0;
    font-size: 20px;
    font-weight: 600;
}

.ar-feature-card p {
    margin-bottom: 20px;
    opacity: 0.9;
    line-height: 1.5;
}

.ar-action-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 25px;
    padding: 12px 24px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.ar-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.ar-action-btn.ar-primary {
    background: rgba(52, 199, 89, 0.8);
    border-color: rgba(52, 199, 89, 1);
    animation: arPulse 2s infinite;
}

@keyframes arPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.7); }
    50% { box-shadow: 0 0 0 10px rgba(52, 199, 89, 0); }
}

.ar-status-panel {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 15px;
    padding: 25px;
    margin: 30px 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.ar-status-panel h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 20px;
}

.ar-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.ar-status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ar-status-label {
    font-weight: 500;
    color: #666;
}

.ar-status-value {
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 12px;
}

.ar-status-value.checking {
    background: rgba(255, 149, 0, 0.2);
    color: #ff9500;
}

.ar-status-value.supported {
    background: rgba(52, 199, 89, 0.2);
    color: #34c759;
}

.ar-status-value.not-supported {
    background: rgba(255, 59, 48, 0.2);
    color: #ff3b30;
}

.ar-chat-preview {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 15px;
    padding: 25px;
    margin: 30px 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.ar-chat-preview h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 20px;
}

.chat-preview-container {
    background: white;
    border-radius: 15px;
    padding: 20px;
    max-height: 400px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 15px;
    max-height: 250px;
}

.chat-message {
    margin-bottom: 12px;
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 80%;
    word-wrap: break-word;
    line-height: 1.4;
}

.chat-message.assistant {
    background: #f0f0f0;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-message.user {
    background: #007AFF;
    color: white;
    align-self: flex-end;
    margin-left: auto;
    text-align: right;
    border-bottom-right-radius: 4px;
}

.chat-input-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

#chat-preview-input {
    flex: 1;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    padding: 12px 20px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s ease;
}

#chat-preview-input:focus {
    border-color: #007AFF;
}

.chat-send-btn {
    background: #007AFF;
    border: none;
    border-radius: 20px;
    padding: 12px 20px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chat-send-btn:hover {
    background: #0056d6;
    transform: scale(1.05);
}

/* Mobile Responsive for AR Tab */
@media (max-width: 768px) {
    .ar-chatgpt-wrapper {
        padding: 15px;
    }

    .ar-features-grid {
        grid-template-columns: 1fr;
        gap: 15px;
        margin: 20px 0;
    }

    .ar-feature-card {
        padding: 20px;
    }

    .ar-feature-icon {
        font-size: 40px;
    }

    .ar-status-grid {
        grid-template-columns: 1fr;
    }

    .ar-status-panel,
    .ar-chat-preview {
        padding: 20px;
        margin: 20px 0;
    }
}

/* AR Overlay Container */
.ar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: transparent;
    overflow: hidden;
}

/* Allow interaction with AR controls */
.ar-overlay * {
    pointer-events: auto;
}

/* AR Controls Container */
.ar-controls {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
}

/* Top Bar */
.ar-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    backdrop-filter: blur(10px);
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    padding: 10px 20px;
}

/* Mode Indicator */
.ar-mode-indicator {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    padding: 8px 16px;
    border-radius: 15px;
    font-weight: 600;
    font-size: 14px;
    text-align: center;
    min-width: 100px;
}

/* AR Buttons */
.ar-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 25px;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    color: #333;
    min-width: 50px;
    text-align: center;
}

.ar-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.ar-btn:active {
    transform: translateY(0);
}

/* Specialized Button Styles */
.ar-exit {
    background: rgba(255, 59, 48, 0.95);
    color: white;
    font-weight: bold;
    font-size: 16px;
    padding: 12px 20px;
    min-width: 80px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(255, 59, 48, 0.4);
    z-index: 9999;
}

.ar-exit:hover {
    background: rgba(255, 59, 48, 1);
}

.ar-voice {
    font-size: 20px;
    padding: 10px;
    min-width: 50px;
    border-radius: 50%;
}

.ar-voice.recording {
    background: rgba(255, 59, 48, 0.9);
    color: white;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Chat Interface */
.ar-chat-interface {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-height: 60vh;
    margin-bottom: 20px;
    backdrop-filter: blur(10px);
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    padding: 20px;
    overflow: hidden;
}

.ar-chat-messages {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 15px;
    padding-right: 10px;
}

.ar-chat-message {
    margin-bottom: 12px;
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 80%;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 15px;
}

.ar-chat-user {
    background: rgba(0, 122, 255, 0.9);
    color: white;
    align-self: flex-end;
    margin-left: auto;
    text-align: right;
}

.ar-chat-assistant {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    align-self: flex-start;
}

/* Chat Input Container */
.ar-chat-input-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

#ar-chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 20px;
    padding: 12px 20px;
    font-size: 16px;
    outline: none;
}

#ar-chat-input::placeholder {
    color: #666;
}

/* Bottom Controls */
.ar-bottom-controls {
    display: flex;
    justify-content: space-around;
    gap: 15px;
    backdrop-filter: blur(10px);
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    padding: 15px;
}

.ar-scan {
    background: rgba(52, 199, 89, 0.9);
    color: white;
}

.ar-scan:hover {
    background: rgba(52, 199, 89, 1);
}

.ar-scan.active {
    animation: scanPulse 2s infinite;
}

@keyframes scanPulse {
    0%, 100% { background: rgba(52, 199, 89, 0.9); }
    50% { background: rgba(52, 199, 89, 1); box-shadow: 0 0 20px rgba(52, 199, 89, 0.5); }
}

.ar-data {
    background: rgba(88, 86, 214, 0.9);
    color: white;
}

.ar-data:hover {
    background: rgba(88, 86, 214, 1);
}

.ar-help {
    background: rgba(255, 149, 0, 0.9);
    color: white;
}

.ar-help:hover {
    background: rgba(255, 149, 0, 1);
}

/* Plant Information Display */
.ar-plant-info {
    position: absolute;
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 20px;
    max-width: 350px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    color: #333;
}

#plant-name {
    margin: 0 0 10px 0;
    font-size: 20px;
    font-weight: bold;
    color: #2d5016;
}

#plant-details {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #666;
}

#plant-recommendations {
    font-size: 14px;
    text-align: left;
}

#plant-recommendations ul {
    margin: 10px 0;
    padding-left: 20px;
}

#plant-recommendations li {
    margin: 8px 0;
    line-height: 1.3;
}

/* NASA Data Overlay */
.ar-nasa-overlay {
    position: absolute;
    top: 120px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 15px;
    padding: 15px;
    max-width: 250px;
    font-size: 14px;
}

.ar-nasa-overlay h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #4CAF50;
}

.ar-nasa-data-item {
    display: flex;
    justify-content: space-between;
    margin: 8px 0;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.ar-nasa-data-item:last-child {
    border-bottom: none;
}

/* Loading States */
.ar-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    min-width: 200px;
}

.ar-loading-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error States */
.ar-error {
    background: rgba(255, 59, 48, 0.9);
    color: white;
    padding: 15px;
    border-radius: 15px;
    text-align: center;
    margin: 10px 0;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .ar-controls {
        padding: 15px;
    }

    .ar-top-bar {
        padding: 8px 15px;
        margin-bottom: 15px;
    }

    .ar-btn {
        padding: 10px 15px;
        font-size: 14px;
        min-width: 40px;
    }

    .ar-exit {
        padding: 15px 25px !important;
        font-size: 16px !important;
        font-weight: bold !important;
        min-width: 100px !important;
        box-shadow: 0 6px 20px rgba(255, 59, 48, 0.6) !important;
        border: 3px solid rgba(255, 255, 255, 0.5) !important;
    }

    .ar-chat-interface {
        max-height: 50vh;
        padding: 15px;
    }

    .ar-chat-message {
        font-size: 14px;
        padding: 10px 14px;
        max-width: 90%;
    }

    .ar-bottom-controls {
        gap: 10px;
        padding: 12px;
    }

    .ar-plant-info {
        max-width: 300px;
        padding: 15px;
        bottom: 130px;
    }

    #plant-name {
        font-size: 18px;
    }

    #plant-details {
        font-size: 14px;
    }

    #plant-recommendations {
        font-size: 13px;
    }
}

/* Landscape Orientation */
@media (orientation: landscape) and (max-height: 600px) {
    .ar-chat-interface {
        max-height: 40vh;
    }

    .ar-plant-info {
        bottom: 100px;
        max-width: 280px;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2) {
    .ar-overlay {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* AR Active State */
body.ar-active {
    overflow: hidden;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .ar-btn,
    .ar-loading-spinner {
        animation: none;
    }

    .ar-btn:hover {
        transform: none;
    }
}

/* Focus States for Keyboard Navigation */
.ar-btn:focus {
    outline: 2px solid #007AFF;
    outline-offset: 2px;
}

#ar-chat-input:focus {
    outline: 2px solid #007AFF;
    outline-offset: 2px;
}

/* Screen Reader Support */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Reticle/Crosshair for AR targeting */
.ar-reticle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    pointer-events: none;
    z-index: 10001;
}

.ar-reticle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
}

/* AR Button Animations */
.ar-btn-animate {
    animation: buttonPop 0.3s ease-out;
}

@keyframes buttonPop {
    0% { transform: scale(0.95); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Voice Recognition Visual Feedback */
.ar-voice-wave {
    position: absolute;
    bottom: 200px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 40px;
}

.ar-voice-bar {
    width: 4px;
    background: rgba(52, 199, 89, 0.8);
    border-radius: 2px;
    animation: voiceWave 1.5s ease-in-out infinite;
}

.ar-voice-bar:nth-child(1) { animation-delay: 0s; }
.ar-voice-bar:nth-child(2) { animation-delay: 0.1s; }
.ar-voice-bar:nth-child(3) { animation-delay: 0.2s; }
.ar-voice-bar:nth-child(4) { animation-delay: 0.3s; }
.ar-voice-bar:nth-child(5) { animation-delay: 0.4s; }

@keyframes voiceWave {
    0%, 100% { height: 10px; }
    50% { height: 30px; }
}

/* Connection Status Indicator */
.ar-connection-status {
    position: absolute;
    top: 80px;
    right: 20px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 8px 12px;
    border-radius: 15px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ar-connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #52C954;
}

.ar-connection-dot.disconnected {
    background: #FF453A;
}

.ar-connection-dot.connecting {
    background: #FF9F0A;
    animation: pulse 1s infinite;
}

/* AR Overlay Base Styles - Mobile Optimized */
.ar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    pointer-events: none;
    display: none;
    -webkit-overflow-scrolling: touch;
    overflow: hidden;
}

.ar-overlay.active {
    pointer-events: auto;
    display: block;
}

/* Mobile Safe Area Support */
@supports (padding: max(0px)) {
    .ar-overlay {
        padding-top: max(env(safe-area-inset-top), 20px);
        padding-bottom: max(env(safe-area-inset-bottom), 20px);
        padding-left: max(env(safe-area-inset-left), 0px);
        padding-right: max(env(safe-area-inset-right), 0px);
    }
}

/* Android-specific optimizations */
@media (max-width: 768px) and (pointer: coarse) {
    /* AR Controls Android optimization */
    #ar-controls {
        top: 10px !important;
        left: 10px !important;
        right: 10px !important;
        border-radius: 16px !important;
        background: linear-gradient(135deg, rgba(7, 23, 63, 0.98), rgba(9, 96, 225, 0.95)) !important;
        backdrop-filter: none !important; /* Remove backdrop-filter for Android compatibility */
        -webkit-backdrop-filter: none !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
        border: 1px solid rgba(46, 150, 245, 0.6) !important;
        transform: none !important;
        -webkit-transform: none !important;
        will-change: auto !important;
    }

    /* AR Controls header for Android */
    #ar-controls > div:first-child {
        padding: 10px 15px !important;
        min-height: 44px !important; /* Android touch target */
    }

    #ar-controls > div:first-child span {
        font-size: 14px !important;
        line-height: 24px !important;
    }

    /* AR Controls buttons for Android */
    #ar-controls button {
        min-height: 48px !important; /* Android touch target */
        min-width: 48px !important;
        padding: 12px 16px !important;
        font-size: 16px !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
        border-radius: 12px !important;
        margin: 4px !important;
    }

    /* AR Controls cards for Android touch */
    #ar-controls > div:last-child > div {
        min-height: 48px !important;
        padding: 12px !important;
        border-radius: 8px !important;
        touch-action: manipulation !important;
    }

    /* Improve Android scrolling in AR panels */
    #panel-content {
        -webkit-overflow-scrolling: touch !important;
        overflow-y: auto !important;
    }

    .ar-status-panel {
        max-height: 40vh !important;
        overflow-y: auto !important;
        padding: 15px !important;
        margin: 10px !important;
    }

    .ar-status-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .ar-status-item {
        padding: 8px 12px !important;
        font-size: 14px !important;
    }

    .ar-status-label {
        font-size: 12px !important;
    }

    .ar-status-value {
        font-size: 11px !important;
        padding: 3px 8px !important;
    }

    /* Compact AR UI controls */
    .ar-ui-controls {
        max-height: 30vh !important;
        overflow-y: auto !important;
    }

    /* Hide non-essential elements on small screens */
    .ar-status-panel h3 {
        font-size: 16px !important;
        margin-bottom: 10px !important;
    }
}

/* AR Fallback Interface Styles */
.ar-fallback-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    border-radius: 16px;
    padding: 24px;
    width: 90vw;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 10000;
}

.ar-fallback-header {
    text-align: center;
    margin-bottom: 24px;
    color: white;
}

.ar-fallback-header h3 {
    margin: 0 0 8px 0;
    font-size: 1.5em;
    font-weight: 600;
}

.ar-fallback-header p {
    margin: 0;
    opacity: 0.7;
    font-size: 0.9em;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.feature-card {
    background: rgba(46, 150, 245, 0.1);
    border: 1px solid rgba(46, 150, 245, 0.3);
    border-radius: 12px;
    padding: 20px 16px;
    text-align: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.feature-card:hover {
    background: rgba(46, 150, 245, 0.2);
    border-color: rgba(46, 150, 245, 0.5);
    transform: translateY(-2px);
}

.feature-icon {
    display: block;
    font-size: 2em;
    margin-bottom: 8px;
}

.feature-card h4 {
    margin: 8px 0 4px 0;
    font-size: 1em;
    font-weight: 600;
}

.feature-card p {
    margin: 0;
    font-size: 0.8em;
    opacity: 0.8;
    line-height: 1.3;
}

.ar-close-btn {
    width: 100%;
    padding: 12px 20px;
    background: #FF453A;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.ar-close-btn:hover {
    background: #d1404a;
}

/* Plant Result Card */
.plant-result-card {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid rgba(46, 150, 245, 0.3);
    backdrop-filter: blur(10px);
    min-width: 250px;
    z-index: 10001;
}

.plant-result-card h4 {
    margin: 0 0 12px 0;
    color: #2E96F5;
}

.plant-result-card p {
    margin: 6px 0;
    font-size: 0.9em;
}

.plant-result-card button {
    margin-top: 12px;
    padding: 8px 16px;
    background: #2E96F5;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
}

/* Message Card */
.message-card {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 16px 20px;
    border-radius: 8px;
    border: 1px solid rgba(46, 150, 245, 0.3);
    backdrop-filter: blur(10px);
    max-width: 80vw;
    z-index: 10001;
}

.message-card p {
    margin: 0 0 8px 0;
    font-size: 0.9em;
    line-height: 1.4;
}

.message-card button {
    padding: 6px 12px;
    background: #2E96F5;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .ar-fallback-container {
        width: 95vw;
        padding: 20px;
    }

    .feature-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .feature-card {
        padding: 16px 12px;
    }

    .feature-icon {
        font-size: 1.5em;
    }

    .plant-result-card {
        right: 10px;
        top: 10px;
        min-width: 200px;
        padding: 16px;
    }
}