/* Time App Custom Styles */

/* Mobile-first responsive design with WebView optimizations */
html, body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif, system-ui, -apple-system;
    background-color: #f8f9fa;
    /* Fix height issues in WebView - CRITICAL */
    height: auto !important;
    min-height: 100vh !important;
    margin: 0;
    padding: 0;
    /* WebView optimizations */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Force content to have minimum height in WebView */
.container, main.container {
    min-height: calc(100vh - 120px) !important;
    height: auto !important;
}

/* Ensure all major containers have proper height */
.row, .col-md-4, .col-md-6, .col-lg-8, .card {
    height: auto !important;
    min-height: fit-content !important;
}

/* WebView-specific fixes */
.webview-optimized {
    /* Ensure content is visible immediately */
    opacity: 1 !important;
    visibility: visible !important;

    /* Fix potential rendering issues */
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Force hardware acceleration for smooth scrolling in WebView */
.container, .card, .btn {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Prevent text selection on sensitive elements */
.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Hide scrollbars in screenshot-protected areas */
.protected-content {
    overflow: hidden;
}

/* Navigation customization */
.navbar {
    min-height: 56px !important;
    max-height: 60px !important;
    height: auto !important;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
}

.navbar-collapse {
    height: auto !important;
    max-height: none !important;
}

.navbar-nav {
    height: auto !important;
}

/* Card hover effects */
.card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
}

/* Review cards */
.review-card {
    border-left: 4px solid #dee2e6;
    background: white;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.review-card.green-flag {
    border-left-color: #28a745;
}

.review-card.red-flag {
    border-left-color: #dc3545;
}

/* Flag indicators */
.flag-indicator {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.green-flag-indicator {
    background-color: #d4edda;
    color: #155724;
}

.red-flag-indicator {
    background-color: #f8d7da;
    color: #721c24;
}

/* Rating stars */
.rating-stars {
    color: #ffc107;
    font-size: 1.2rem;
}

/* Search filters */
.filter-section {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Enhanced Mobile Optimizations */
.container {
    --container-padding: 1rem;
    padding-left: var(--container-padding);
    padding-right: var(--container-padding);
}

@media (max-width: 576px) {
    .container {
        --container-padding: 0.75rem;
        max-width: 100%;
    }

    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

@media (max-width: 768px) {

    /* Reduce excessive spacing on mobile */
    .my-4, .my-5 {
        margin-top: 1.5rem !important;
        margin-bottom: 1.5rem !important;
    }

    .py-4, .py-5 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }

    /* Better card spacing */
    .card-body {
        padding: 1rem;
    }

    .card {
        margin-bottom: 1rem;
    }

    /* Responsive typography */
    .display-4 {
        font-size: 2rem;
        line-height: 1.2;
    }

    .display-5 {
        font-size: 1.75rem;
        line-height: 1.2;
    }

    .lead {
        font-size: 1.1rem;
        line-height: 1.4;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    /* Mobile-friendly buttons - all touch targets 44px minimum */
    .btn {
        min-height: 44px;
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }

    .btn-lg {
        min-height: 48px;
        padding: 0.875rem 1.5rem;
        font-size: 1.1rem;
    }

    .btn-sm {
        min-height: 40px;
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    /* Form controls touch-friendly */
    .form-control, .form-select {
        min-height: 44px;
        padding: 0.75rem;
        font-size: 1rem;
        /* Prevents zoom on iOS */
    }

    .form-control-lg {
        min-height: 48px;
        padding: 0.875rem 1rem;
        font-size: 1.1rem;
    }

    /* Stack pricing cards on mobile */
    .pricing-card {
        margin-bottom: 1rem;
    }

    /* Better spacing for mobile cards */
    .row>[class*="col-"] {
        margin-bottom: 1rem;
    }

    /* Reduce navbar padding */
    .navbar {
        padding: 0.5rem 0;
    }

    .navbar-brand {
        font-size: 1.25rem;
    }

    /* Better mobile modal */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    /* Improve table responsiveness */
    .table-responsive {
        border: none;
    }

    /* Better list spacing */
    .list-group-item {
        padding: 1rem 0.75rem;
    }
}

/* Form styling */
.form-control:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.form-floating>.form-control:focus~label {
    color: #0d6efd;
}

/* File upload styling */
.file-upload-area {
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    transition: border-color 0.3s ease;
    cursor: pointer;
}

.file-upload-area:hover {
    border-color: #0d6efd;
}

.file-upload-area.drag-over {
    border-color: #0d6efd;
    background-color: rgba(13, 110, 253, 0.05);
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, .3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Alert styling */
.alert {
    border-radius: 8px;
    border: none;
}

/* Photo gallery */
.photo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 1rem;
}

.photo-item {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 8px;
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Search results */
.search-result {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s ease;
}

.search-result:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Profile section */
.profile-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.profile-photo {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Stats section */
.stats-card {
    text-align: center;
    padding: 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.stats-number {
    font-size: 2rem;
    font-weight: bold;
    display: block;
}

/* Premium features */
.premium-feature {
    position: relative;
    overflow: hidden;
}

.premium-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    border-radius: 8px;
}

/* Security - Disable context menu and selection on sensitive areas */
.protected-area {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* Hide content when trying to screenshot */
@media print {
    .no-print {
        display: none !important;
    }
}

/* Responsive text sizes */
@media (max-width: 576px) {
    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    h4 {
        font-size: 1.1rem;
    }

    h5 {
        font-size: 1rem;
    }

    h6 {
        font-size: 0.9rem;
    }
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1020;
    height: 60px !important;
    min-height: 60px !important;
    max-height: 60px !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.mobile-nav-item {
    color: #6c757d;
    transition: all 0.2s ease;
    padding: 0.5rem;
    border-radius: 8px;
    min-width: 60px;
}

.mobile-nav-item:hover {
    color: #0d6efd !important;
    background-color: rgba(13, 110, 253, 0.1);
}

.mobile-nav-item.active {
    color: #0d6efd !important;
}

.mobile-nav-text {
    font-size: 0.7rem;
    font-weight: 500;
    line-height: 1;
}

/* Add padding to main content on mobile to account for bottom nav */
@media (max-width: 767.98px) {
    main.container {
        padding-bottom: 80px;
        /* Space for mobile bottom nav */
    }

    body {
        padding-bottom: 60px;
    }
}

/* Mobile Menu Offcanvas Enhancements */
.offcanvas-body {
    padding: 1rem;
}

.user-avatar {
    transition: all 0.2s ease;
}

.user-avatar:hover {
    transform: scale(1.05);
}

.mobile-menu-items a,
.mobile-menu-items button {
    color: inherit;
    transition: all 0.2s ease;
}

.mobile-menu-items a:hover,
.mobile-menu-items button:hover {
    background-color: rgba(13, 110, 253, 0.1);
    color: #0d6efd;
}

.user-stats .bg-light {
    transition: all 0.2s ease;
}

.user-stats .bg-light:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Touch-friendly interactions */
@media (max-width: 768px) {

    /* Larger touch targets */
    .btn, .form-control, .form-select {
        min-height: 44px;
    }

    .mobile-nav-item {
        min-height: 50px;
        min-width: 50px;
    }

    /* Better spacing for touch */
    .card-body {
        padding: 1rem;
    }

    /* Improved button spacing */
    .btn-group .btn,
    .btn+.btn {
        margin-left: 0.25rem;
    }

    /* Mobile-friendly form controls */
    .form-floating>.form-control {
        padding-top: 1.625rem;
        padding-bottom: 0.625rem;
    }

    /* Better modal sizing on mobile */
    .modal-dialog {
        margin: 0.5rem;
    }

    .offcanvas {
        width: 85% !important;
        max-width: 320px;
    }
}

/* Pull-to-refresh visual feedback */
.ptr-pulldown {
    background: linear-gradient(to bottom, #f8f9fa, #e9ecef);
    text-align: center;
    padding: 1rem;
    color: #6c757d;
    border-bottom: 1px solid #dee2e6;
    transform: translateY(-100%);
    transition: transform 0.2s ease;
}

.ptr-pulldown.ptr-pulling {
    transform: translateY(0);
}

.ptr-pulldown .ptr-icon {
    display: inline-block;
    transition: transform 0.2s ease;
}

.ptr-pulldown.ptr-ready .ptr-icon {
    transform: rotate(180deg);
}

/* Swipe gesture indicators */
.swipe-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

.swipe-indicator.left {
    left: 20px;
}

.swipe-indicator.right {
    right: 20px;
}

.swipe-indicator.show {
    opacity: 1;
}

/* Enhanced touch feedback */
.touch-feedback {
    position: relative;
    overflow: hidden;
}

.touch-feedback::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
    pointer-events: none;
}

.touch-feedback.active::after {
    width: 100px;
    height: 100px;
}

/* Improved accessibility for mobile */
@media (max-width: 768px) {

    /* Ensure text is readable */
    body {
        font-size: 16px;
        /* Prevents iOS zoom on focus */
    }

    /* Better focus indicators */
    .form-control:focus,
    .btn:focus {
        box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
        outline: 2px solid transparent;
    }

    /* Improved contrast for better readability */
    .text-muted {
        color: #6c757d !important;
    }

    /* Better spacing for readability */
    p, .card-text {
        line-height: 1.6;
    }

    /* Improved list spacing */
    .list-group-item {
        padding: 0.75rem 1rem;
    }
}

/* Progressive Web App enhancements */
.pwa-install-banner {
    position: fixed;
    bottom: 80px;
    /* Above mobile nav */
    left: 1rem;
    right: 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 1019;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.pwa-install-banner.show {
    transform: translateY(0);
}

.pwa-install-banner .btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    transition: all 0.2s ease;
}

.pwa-install-banner .btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* Loading states optimized for mobile */
.mobile-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.mobile-loading .spinner-border {
    width: 3rem;
    height: 3rem;
    margin-bottom: 1rem;
}

/* Enhanced Dark Mode Support */
:root {
    /* Light theme variables */
    --color-primary: #667eea;
    --color-primary-dark: #5a6fd8;
    --color-secondary: #6c757d;
    --color-success: #28a745;
    --color-warning: #ffc107;
    --color-danger: #dc3545;
    --color-info: #17a2b8;

    /* Light theme background colors */
    --bg-body: #f8f9fa;
    --bg-surface: #ffffff;
    --bg-surface-secondary: #f8f9fa;
    --bg-surface-tertiary: #e9ecef;

    /* Light theme text colors */
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #868e96;
    --text-inverse: #ffffff;

    /* Border and shadow */
    --border-color: #dee2e6;
    --border-color-dark: #adb5bd;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --shadow-color-strong: rgba(0, 0, 0, 0.15);
}

/* Dark theme variables */
[data-bs-theme="dark"],
body.dark-mode {
    --bg-body: #1a1d23;
    --bg-surface: #252933;
    --bg-surface-secondary: #2f3349;
    --bg-surface-tertiary: #3a3f5c;

    --text-primary: #ffffff;
    --text-secondary: #b8bcc8;
    --text-muted: #9ca3af;
    --text-inverse: #212529;

    --border-color: #404759;
    --border-color-dark: #4a5568;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --shadow-color-strong: rgba(0, 0, 0, 0.4);
}

/* Apply theme variables */
body {
    background-color: var(--bg-body) !important;
    color: var(--text-primary) !important;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.card {
    background-color: var(--bg-surface) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

.bg-light {
    background-color: var(--bg-surface-secondary) !important;
}

.bg-dark {
    background-color: var(--bg-surface-tertiary) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.filter-section,
.search-result,
.profile-section {
    background-color: var(--bg-surface) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

.mobile-bottom-nav {
    background-color: var(--bg-surface) !important;
    border-color: var(--border-color) !important;
    box-shadow: 0 -2px 10px var(--shadow-color) !important;
}

.navbar-dark {
    background-color: var(--bg-surface-tertiary) !important;
}

.offcanvas {
    background-color: var(--bg-body) !important;
    color: var(--text-primary) !important;
}

.offcanvas-header {
    background-color: var(--bg-surface-tertiary) !important;
    color: var(--text-primary) !important;
}

.btn:focus,
.form-control:focus {
    box-shadow: 0 0 0 0.25rem rgba(102, 126, 234, 0.25) !important;
}

/* Form controls in dark mode */
[data-bs-theme="dark"] .form-control,
body.dark-mode .form-control {
    background-color: var(--bg-surface-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-bs-theme="dark"] .form-control:focus,
body.dark-mode .form-control:focus {
    background-color: var(--bg-surface-secondary);
    border-color: var(--color-primary);
    color: var(--text-primary);
}

/* Better contrast for links */
[data-bs-theme="dark"] a,
body.dark-mode a {
    color: #8db4f0;
}

[data-bs-theme="dark"] a:hover,
body.dark-mode a:hover {
    color: #a8c5f2;
}

/* Enhanced mobile nav in dark mode */
[data-bs-theme="dark"] .mobile-nav-item,
body.dark-mode .mobile-nav-item {
    color: var(--text-secondary);
}

[data-bs-theme="dark"] .mobile-nav-item:hover,
[data-bs-theme="dark"] .mobile-nav-item.active,
body.dark-mode .mobile-nav-item:hover,
body.dark-mode .mobile-nav-item.active {
    color: var(--color-primary) !important;
    background-color: rgba(102, 126, 234, 0.1);
}

/* Dropdown menus in dark mode */
[data-bs-theme="dark"] .dropdown-menu,
body.dark-mode .dropdown-menu {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
}

[data-bs-theme="dark"] .dropdown-item,
body.dark-mode .dropdown-item {
    color: var(--text-primary);
}

[data-bs-theme="dark"] .dropdown-item:hover,
body.dark-mode .dropdown-item:hover {
    background-color: var(--bg-surface-secondary);
    color: var(--text-primary);
}

/* Auto dark mode based on system preference */
@media (prefers-color-scheme: dark) {
    :root:not([data-bs-theme="light"]) {
        --bg-body: #1a1d23;
        --bg-surface: #252933;
        --bg-surface-secondary: #2f3349;
        --bg-surface-tertiary: #3a3f5c;

        --text-primary: #ffffff;
        --text-secondary: #b8bcc8;
        --text-muted: #9ca3af;
        --text-inverse: #212529;

        --border-color: #404759;
        --border-color-dark: #4a5568;
        --shadow-color: rgba(0, 0, 0, 0.3);
        --shadow-color-strong: rgba(0, 0, 0, 0.4);
    }
}