/* Webview Mode Optimizations */

/* Base webview styles */
.webview-mode {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* Prevent text selection in webview */
.webview-mode * {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Allow text selection for input fields */
.webview-mode input,
.webview-mode textarea,
.webview-mode [contenteditable] {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Hide browser-specific elements in webview */
.webview-mode .browser-only {
    display: none !important;
}

/* Show webview-specific elements */
.webview-only {
    display: none;
}

.webview-mode .webview-only {
    display: block !important;
}

/* Fullscreen button styles */
#fullscreenButton {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    background: rgba(0, 123, 255, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#fullscreenButton:hover {
    background: rgba(0, 123, 255, 1);
    transform: scale(1.1);
}

/* Connection status indicator */
.connection-status {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1001;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.connection-status.online {
    background: rgba(40, 167, 69, 0.9);
    color: white;
}

.connection-status.offline {
    background: rgba(220, 53, 69, 0.9);
    color: white;
}

/* PWA Install button */
#installButton {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 1000;
    background: rgba(40, 167, 69, 0.9);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: none;
}

#installButton:hover {
    background: rgba(40, 167, 69, 1);
    transform: translateY(-2px);
}

/* Push notification button */
#pushNotificationButton {
    transition: all 0.3s ease;
}

#pushNotificationButton:hover {
    transform: translateY(-1px);
}

/* Webview-specific navigation */
.webview-mode .navbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Smooth scrolling for webview */
.webview-mode {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Touch-friendly buttons */
.webview-mode .btn {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}

/* Improved form controls for touch */
.webview-mode .form-control,
.webview-mode .form-select {
    min-height: 44px;
    font-size: 16px; /* Prevent zoom on iOS */
}

/* Loading spinner for webview */
.webview-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.webview-loading .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Safe area insets for devices with notches */
.webview-mode {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Responsive adjustments for webview */
@media (max-width: 768px) {
    .webview-mode .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    .webview-mode .card {
        border-radius: 15px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    }
    
    .webview-mode .btn {
        border-radius: 10px;
    }
}

/* Dark mode support for webview */
@media (prefers-color-scheme: dark) {
    .webview-mode {
        background-color: #121212;
        color: #ffffff;
    }
    
    .webview-mode .card {
        background-color: #1e1e1e;
        border-color: #333;
    }
    
    .webview-mode .navbar {
        background-color: rgba(30, 30, 30, 0.9) !important;
    }
    
    .connection-status.online {
        background: rgba(76, 175, 80, 0.9);
    }
    
    .connection-status.offline {
        background: rgba(244, 67, 54, 0.9);
    }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 500px) {
    .webview-mode .navbar {
        min-height: 40px;
    }
    
    .webview-mode .navbar .navbar-brand {
        font-size: 1rem;
    }
    
    #fullscreenButton {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
}

/* Print styles for webview */
@media print {
    .webview-mode #fullscreenButton,
    .webview-mode #installButton,
    .webview-mode .connection-status {
        display: none !important;
    }
}