/* ===== COMPLETE PWA BASE STYLES - UPDATED VERSION ===== */

/* Root Variables */
:root {
    --primary-color: #22c55e;
    --dark-bg: #0f0f0f;
    --card-bg: #1a1a1a;
    --border-color: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #888888;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Reset and Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-family) !important;
}

html, body {
    font-family: var(--font-family) !important;
    height: 100%;
    width: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* Hide Odoo elements when PWA is active */
body.pwa-active .o_main_navbar,
body.pwa-active .o_action_manager,
body.pwa-active .o_cp_top,
body.pwa-active .o_cp_bottom,
body.pwa-active footer,
body.pwa-active .o_loading,
body.pwa-active header:not(.pwa-header) {
    display: none !important;
}

/* Container - Fixed for proper standalone mode */
.pwa-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100vh !important;
    height: -webkit-fill-available !important;
    background: var(--dark-bg) !important;
    color: var(--text-primary) !important;
    z-index: 10000 !important;
    overflow: hidden !important;
    font-family: var(--font-family) !important;
    display: none;
    flex-direction: column;
}

.pwa-container.visible {
    display: flex !important;
}

/* Login Screen */
.pwa-login-screen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100vh !important;
    height: -webkit-fill-available !important;
    background: var(--dark-bg) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 10001 !important;
    padding: 20px;
    font-family: var(--font-family) !important;
}

.pwa-login-screen.hidden {
    display: none !important;
}

.pwa-login-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border-color);
    font-family: var(--font-family) !important;
    position: relative;
}

.pwa-login-header {
    text-align: center;
    margin-bottom: 30px;
    font-family: var(--font-family) !important;
}

.pwa-login-header h1 {
    color: var(--primary-color);
    font-size: 26px;
    margin-bottom: 6px;
    font-weight: 600;
    font-family: var(--font-family) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.pwa-login-header p {
    color: var(--text-secondary);
    font-size: 14px;
    font-family: var(--font-family) !important;
}

/* Install Banner - Inside Login Card */
.pwa-install-banner {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-radius: 12px;
    padding: 16px;
    margin-top: 20px;
    animation: slideUp 0.3s ease;
}

.pwa-install-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.pwa-install-content i {
    font-size: 20px;
}

.pwa-install-content span {
    flex: 1;
}

.pwa-install-btn {
    background: white;
    color: #22c55e;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pwa-install-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.pwa-install-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.pwa-install-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Install Guide Modal */
.pwa-install-guide-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10003;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.pwa-install-guide-content {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 30px;
    max-width: 400px;
    width: 100%;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.pwa-install-guide-content h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.pwa-install-guide-content ol {
    color: #ccc;
    line-height: 1.8;
}

.pwa-install-guide-content p {
    color: #aaa;
    margin: 10px 0;
}

/* Pull to Refresh Indicator */
.pwa-pull-indicator {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    z-index: 9999;
    box-shadow: 0 2px 10px rgba(34, 197, 94, 0.3);
    animation: slideDown 0.3s ease;
}

/* Form Elements */
.pwa-form-group {
    margin-bottom: 20px;
}

.pwa-form-label {
    display: block;
    color: #aaa;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-family) !important;
}

.pwa-form-label i {
    margin-right: 5px;
    width: 16px;
    display: inline-block;
}

.pwa-form-control {
    width: 100%;
    padding: 12px 15px;
    background: #222;
    border: 1px solid #333;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-family: var(--font-family) !important;
    transition: all 0.3s ease;
}

.pwa-form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    background: #1a1a1a;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.pwa-form-control::placeholder {
    color: #666;
    font-family: var(--font-family) !important;
}

/* Buttons */
.pwa-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family) !important;
    text-decoration: none;
}

.pwa-btn-primary {
    background: var(--primary-color);
    color: white;
}

.pwa-btn-primary:hover {
    background: #16a34a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.pwa-btn-full {
    width: 100%;
}

/* Header */
.pwa-header {
    background: var(--card-bg);
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 50px;
    font-family: var(--font-family) !important;
    flex-shrink: 0;
}

.pwa-logo {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-family) !important;
}

.pwa-user-info {
    color: var(--text-secondary);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-family) !important;
}

/* Content */
.pwa-content {
    flex: 1;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    background: var(--dark-bg);
    padding: 12px;
    padding-bottom: 65px;
    font-family: var(--font-family) !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: thin;
    overscroll-behavior-y: contain !important;
    scroll-behavior: smooth;
    position: relative;
}

/* Hide horizontal scrollbar but keep vertical */
.pwa-content::-webkit-scrollbar {
    width: 6px;
    height: 0;
}

.pwa-jobs-list {
    width: 100%;
    overflow-x: hidden;
}

/* Job Cards */
.pwa-job-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family) !important;
    width: 100%;
    box-sizing: border-box;
}

.pwa-job-card:hover {
    border-color: var(--primary-color);
    background: #1e1e1e;
    transform: translateY(-2px);
}

.pwa-job-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-family: var(--font-family) !important;
}

.pwa-job-reference {
    font-weight: 600;
    color: #fff;
    font-size: 15px;
    font-family: var(--font-family) !important;
}

.pwa-job-state {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: var(--font-family) !important;
}

.state-scheduled {
    background: #3b82f6;
    color: white;
}

.state-progress,
.state-in_progress {
    background: #f59e0b;
    color: #000;
}

.state-done {
    background: var(--primary-color);
    color: white;
}

.pwa-job-customer,
.pwa-job-location,
.pwa-job-time {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    font-size: 13px;
    font-family: var(--font-family) !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.pwa-job-customer {
    color: #ccc;
}

.pwa-job-location {
    color: var(--text-secondary);
    font-size: 12px;
}

.pwa-job-time {
    color: var(--text-secondary);
    font-size: 12px;
}

.pwa-job-customer i,
.pwa-job-location i,
.pwa-job-time i {
    color: #555;
    width: 12px;
    font-size: 11px;
}

/* Progress Bar */
.pwa-job-progress {
    margin-top: 8px;
}

.pwa-progress-container {
    height: 3px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 4px;
}

.pwa-progress-bar {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

.pwa-progress-text {
    font-size: 10px;
    color: #666;
    font-family: var(--font-family) !important;
}

.pwa-job-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    margin-top: 8px;
}

/* Button Sizes */
.pwa-btn-sm {
    padding: 5px 10px;
    font-size: 11px;
}

.pwa-btn-secondary {
    background: #6b7280;
    color: white;
}

.pwa-btn-secondary:hover {
    background: #4b5563;
}

.pwa-btn-success {
    background: #10b981;
    color: white;
}

.pwa-btn-success:hover {
    background: #059669;
}

.pwa-btn-danger {
    background: #ef4444;
    color: white;
}

.pwa-btn-danger:hover {
    background: #dc2626;
}

/* Bottom Navigation */
.pwa-tab-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    height: 56px;
    z-index: 1000;
    font-family: var(--font-family) !important;
}

.pwa-tab-nav button {
    flex: 1;
    padding: 0;
    background: transparent;
    border: none;
    color: #555;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: all 0.2s ease;
    font-family: var(--font-family) !important;
}

.pwa-tab-nav button.active {
    color: var(--primary-color);
}

.pwa-tab-nav button i {
    font-size: 18px;
}

.pwa-tab-nav button span {
    font-size: 10px;
    font-weight: 500;
    font-family: var(--font-family) !important;
}

/* Tab Content */
.pwa-tab-content {
    display: none;
    font-family: var(--font-family) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: none !important;
    height: 100%;
}

.pwa-tab-content.active {
    display: block;
}

/* Loading States */
.pwa-loading {
    text-align: center;
    padding: 40px;
    color: #666;
    font-family: var(--font-family) !important;
}

.pwa-loading i {
    font-size: 24px;
    margin-bottom: 10px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.pwa-empty {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-family: var(--font-family) !important;
}

.pwa-empty h3 {
    color: var(--text-secondary);
    margin: 10px 0;
    font-family: var(--font-family) !important;
}

.pwa-empty p {
    color: #555;
    font-family: var(--font-family) !important;
}

/* Messages */
.pwa-message {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    z-index: 10002;
    animation: slideDown 0.3s ease;
    font-family: var(--font-family) !important;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.pwa-message.success {
    background: var(--primary-color);
    color: white;
}

.pwa-message.error {
    background: #ef4444;
    color: white;
}

.pwa-message.warning {
    background: #f59e0b;
    color: white;
}

.pwa-message.info {
    background: #3b82f6;
    color: white;
}

/* Animations */
@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--dark-bg);
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* Ensure all text uses the correct font */
.pwa-container *,
.pwa-login-screen *,
.pwa-modal * {
    font-family: var(--font-family) !important;
}

/* Standalone Mode Specific Styles */
@media (display-mode: standalone) {
    body {
        overscroll-behavior: none;
        -webkit-user-select: none;
        -webkit-touch-callout: none;
        margin: 0 !important;
        padding: 0 !important;
    }

    .pwa-container {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        height: -webkit-fill-available !important;
    }

    .pwa-login-screen {
        position: fixed !important;
        width: 100vw !important;
        height: 100vh !important;
        height: -webkit-fill-available !important;
    }
}

/* PWA Standalone Class */
body.pwa-standalone {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
}

body.pwa-standalone .pwa-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    height: 100vh !important;
    height: -webkit-fill-available !important;
}

/* Fullscreen mode adjustments */
@media (display-mode: fullscreen) {
    .pwa-header {
        padding-top: env(safe-area-inset-top);
    }

    .pwa-tab-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* iOS specific fixes for standalone */
@supports (-webkit-touch-callout: none) {
    .pwa-container {
        height: 100vh;
        height: -webkit-fill-available;
    }

    .pwa-login-screen {
        height: 100vh;
        height: -webkit-fill-available;
    }

    /* Account for iOS safe areas */
    .pwa-tab-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .pwa-content {
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
        position: relative;
        -webkit-overflow-scrolling: touch;
        overflow-y: scroll;
    }
}

/* iOS Standalone specific */
body.ios-standalone {
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .pwa-job-card {
        border-width: 2px;
    }

    .pwa-btn {
        border: 2px solid currentColor;
    }

    .pwa-form-control:focus {
        outline: 2px solid #22c55e;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }

    .pwa-loading i {
        animation: none;
    }
}

/* Print styles */
@media print {
    .pwa-header,
    .pwa-tab-nav,
    .pwa-btn,
    .pwa-modal {
        display: none !important;
    }

    .pwa-container {
        position: static;
        height: auto;
        background: white;
        color: black;
    }

    .pwa-job-card {
        background: white;
        border: 1px solid black;
        page-break-inside: avoid;
    }
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
}