/* =============================================================================
   PayTable Kiosk Mode Styles
   Optimized for Samsung Galaxy Tab A9+ in landscape orientation
   Used with Fully Kiosk Browser
   ============================================================================= */

/* =============================================================================
   Kiosk Mode Base Styles
   Applied when body has .kiosk-mode class (set by JS in index.html)
   ============================================================================= */

.kiosk-mode {
    /* Prevent pull-to-refresh and overscroll */
    overscroll-behavior: none;
    
    /* Disable touch callout (iOS) */
    -webkit-touch-callout: none;
    
    /* Disable text selection globally */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    
    /* Prevent elastic scrolling */
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Allow text selection in form inputs */
.kiosk-mode input,
.kiosk-mode textarea,
.kiosk-mode [contenteditable="true"] {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Disable image dragging */
.kiosk-mode img {
    -webkit-user-drag: none;
    user-drag: none;
    pointer-events: none;
}

/* Re-enable pointer events for clickable images */
.kiosk-mode img.clickable,
.kiosk-mode button img,
.kiosk-mode a img {
    pointer-events: auto;
}

/* =============================================================================
   Landscape Orientation Layout
   Samsung Galaxy Tab A9+ resolution: 1920x1200 (landscape)
   ============================================================================= */

@media screen and (orientation: landscape) {
    .kiosk-mode .main-layout {
        display: grid;
        grid-template-columns: 280px 1fr;
        grid-template-rows: 100vh;
        height: 100vh;
        overflow: hidden;
    }
    
    .kiosk-mode .sidebar {
        background: var(--surface-color, #ffffff);
        border-right: 2px solid var(--border-color, #e2e8f0);
        overflow-y: auto;
        padding: 1rem;
    }
    
    .kiosk-mode .main-content {
        overflow-y: auto;
        padding: 1rem;
        height: 100vh;
    }
}

/* =============================================================================
   Touch-Friendly Targets
   Minimum touch target: 48x48px (WCAG 2.1 recommendation)
   ============================================================================= */

.kiosk-mode .btn,
.kiosk-mode button,
.kiosk-mode [role="button"],
.kiosk-mode .nav-link,
.kiosk-mode .menu-item,
.kiosk-mode .clickable {
    min-height: 48px;
    min-width: 48px;
    padding: 12px 16px;
    
    /* Improve touch feedback */
    -webkit-tap-highlight-color: rgba(0, 0, 117, 0.3);
    touch-action: manipulation;
}

/* Large touch targets for primary actions */
.kiosk-mode .btn-lg,
.kiosk-mode .btn-primary-action {
    min-height: 56px;
    min-width: 56px;
    padding: 16px 24px;
    font-size: 1.125rem;
}

/* Form controls */
.kiosk-mode .form-control,
.kiosk-mode .form-select,
.kiosk-mode input,
.kiosk-mode select,
.kiosk-mode textarea {
    min-height: 48px;
    font-size: 16px; /* Prevents iOS zoom on focus */
    padding: 12px 16px;
}

/* Checkboxes and radio buttons */
.kiosk-mode .form-check-input {
    width: 24px;
    height: 24px;
    margin-top: 0;
}

.kiosk-mode .form-check-label {
    padding-left: 8px;
    line-height: 24px;
}

/* =============================================================================
   Admin Access Gesture Area
   Hidden touch zone in corner for admin access
   ============================================================================= */

.admin-gesture-zone {
    position: fixed;
    top: 0;
    right: 0;
    width: 60px;
    height: 60px;
    z-index: 9999;
    background: transparent;
    cursor: default;
    
    /* Visual feedback on tap (subtle) */
    transition: background-color 0.1s ease;
}

.admin-gesture-zone:active {
    background: rgba(255, 255, 255, 0.1);
}

/* Visual indicator when gesture is in progress */
.admin-gesture-zone.gesture-active {
    background: rgba(59, 130, 246, 0.2);
}

.admin-gesture-zone.gesture-active::after {
    content: attr(data-tap-count);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    font-weight: bold;
    color: var(--primary-color, #3b82f6);
    opacity: 0.8;
}

/* =============================================================================
   Offline Mode Indicator
   ============================================================================= */

.kiosk-mode.offline-mode::before {
    content: '⚠️ Sin conexión';
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 8px 24px;
    font-size: 14px;
    font-weight: 600;
    z-index: 10000;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    animation: pulse-offline 2s ease-in-out infinite;
}

@keyframes pulse-offline {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

/* =============================================================================
   Standalone/PWA Mode Adjustments
   ============================================================================= */

.standalone-mode {
    /* Remove safe area insets for fullscreen */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Hide scrollbars in kiosk mode (cleaner look) */
.kiosk-mode ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.kiosk-mode ::-webkit-scrollbar-track {
    background: transparent;
}

.kiosk-mode ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.kiosk-mode ::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* =============================================================================
   Fully Kiosk Browser Specific
   ============================================================================= */

/* Hide status bar area if visible */
.fully-kiosk-mode {
    padding-top: 0 !important;
}

/* Disable long-press context menu */
.kiosk-mode * {
    -webkit-touch-callout: none;
}

/* =============================================================================
   Loading States for Kiosk
   Larger, more visible loading indicators
   ============================================================================= */

.kiosk-mode .spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.35em;
}

.kiosk-mode .loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.kiosk-mode .loading-overlay .loading-content {
    text-align: center;
}

.kiosk-mode .loading-overlay .loading-text {
    margin-top: 1rem;
    font-size: 1.25rem;
    color: var(--text-primary, #1e293b);
    font-weight: 500;
}

/* =============================================================================
   Error States for Kiosk
   Clear, actionable error messages
   ============================================================================= */

.kiosk-mode .error-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 400px;
    z-index: 9999;
}

.kiosk-mode .error-icon {
    font-size: 4rem;
    color: var(--danger-color, #ef4444);
    margin-bottom: 1rem;
}

.kiosk-mode .error-message {
    font-size: 1.25rem;
    color: var(--text-primary, #1e293b);
    margin-bottom: 1.5rem;
}

.kiosk-mode .error-retry-btn {
    min-width: 200px;
}

/* =============================================================================
   Print Preview Adjustments
   Hide kiosk-specific elements when printing
   ============================================================================= */

@media print {
    .admin-gesture-zone,
    .offline-mode::before,
    .loading-overlay {
        display: none !important;
    }
}

/* =============================================================================
   High Contrast Mode Support
   ============================================================================= */

@media (prefers-contrast: more) {
    .kiosk-mode .btn,
    .kiosk-mode button {
        border-width: 3px;
    }
    
    .kiosk-mode .form-control,
    .kiosk-mode .form-select {
        border-width: 3px;
    }
    
    .admin-gesture-zone.gesture-active {
        background: rgba(59, 130, 246, 0.4);
    }
}

/* =============================================================================
   Dark Mode Support
   ============================================================================= */

@media (prefers-color-scheme: dark) {
    .kiosk-mode.offline-mode::before {
        background: linear-gradient(135deg, #b45309 0%, #92400e 100%);
    }
    
    .kiosk-mode ::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.2);
    }
    
    .kiosk-mode ::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.3);
    }
    
    .kiosk-mode .loading-overlay {
        background: rgba(15, 23, 42, 0.95);
    }
    
    .kiosk-mode .error-container {
        background: var(--surface-color, #1e293b);
    }
}
