/**
 * Cordova-specific styles
 *
 * Handles safe areas, native-like interactions, and mobile optimizations.
 */

/* Safe areas for notched devices */
.app-layout.cordova {
    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);
}

.app-layout.cordova .sidebar {
    padding-top: env(safe-area-inset-top);
}

.app-layout.cordova .main-content {
    padding-bottom: env(safe-area-inset-bottom);
}

/* Disable text selection for native feel */
.app-layout.cordova {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Allow text selection in input fields */
.app-layout.cordova input,
.app-layout.cordova textarea,
.app-layout.cordova [contenteditable="true"] {
    -webkit-user-select: text;
    user-select: text;
}

/* Disable tap highlight */
.app-layout.cordova * {
    -webkit-tap-highlight-color: transparent;
}

/* Smooth scrolling with momentum */
.app-layout.cordova .main-content,
.app-layout.cordova .sidebar-nav,
.app-layout.cordova .table-container {
    -webkit-overflow-scrolling: touch;
}

/* Active state for buttons (native feel) */
.app-layout.cordova .btn:active,
.app-layout.cordova .sidebar-link:active {
    opacity: 0.7;
    transform: scale(0.98);
}

/* Larger touch targets on mobile */
@media (max-width: 768px) {
    .app-layout.cordova .btn {
        min-height: 44px;
        min-width: 44px;
    }

    .app-layout.cordova .sidebar-link {
        min-height: 48px;
        padding: 12px 16px;
    }

    .app-layout.cordova .form-input,
    .app-layout.cordova .form-select {
        min-height: 44px;
        font-size: 16px; /* Prevent iOS zoom on focus */
    }

    .app-layout.cordova .form-checkbox {
        min-height: 44px;
    }

    /* Table rows more tappable */
    .app-layout.cordova .data-table tbody tr {
        min-height: 48px;
    }

    .app-layout.cordova .data-table td {
        padding: 12px 8px;
    }
}

/* Pull-to-refresh indicator (placeholder - implement with JS) */
.pull-to-refresh {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    opacity: 0;
    transition: opacity 0.2s, top 0.2s;
}

.pull-to-refresh.active {
    top: 10px;
    opacity: 1;
}

.pull-to-refresh .spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Offline indicator */
.offline-indicator {
    position: fixed;
    top: env(safe-area-inset-top);
    left: 0;
    right: 0;
    background: var(--warning-500);
    color: white;
    text-align: center;
    padding: 8px;
    font-size: 14px;
    z-index: 9999;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.offline-indicator.show {
    transform: translateY(0);
}

/* Splash screen fade out */
.splash-screen {
    position: fixed;
    inset: 0;
    background: var(--primary-500);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.3s ease;
}

.splash-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.splash-screen .logo {
    width: 120px;
    height: 120px;
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* Bottom navigation for mobile (alternative to sidebar) */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 100;
}

.bottom-nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 56px;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--gray-500);
    text-decoration: none;
    font-size: 11px;
    padding: 8px 12px;
    transition: color 0.2s;
}

.bottom-nav-item.active {
    color: var(--primary-500);
}

.bottom-nav-item svg {
    width: 24px;
    height: 24px;
}

/* Show bottom nav on mobile in Cordova mode */
@media (max-width: 768px) {
    .app-layout.cordova .bottom-nav {
        display: block;
    }

    .app-layout.cordova .sidebar {
        display: none;
    }

    .app-layout.cordova .main-content {
        margin-left: 0;
        padding-bottom: calc(56px + env(safe-area-inset-bottom));
    }
}

/* Keyboard handling */
.keyboard-open .bottom-nav {
    display: none;
}

.keyboard-open .main-content {
    padding-bottom: 0 !important;
}

/* Status bar overlay for iOS */
.ios-status-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-top);
    background: var(--primary-500);
    z-index: 9998;
}
