/* ========================================
   GrLavaJato - Login Page Styles (PWA Optimized)
   ======================================== */

:root {
    --primary-color: #053978;
    --primary-dark: #042a5a;
    --primary-light: #0d4fa3;
    --secondary-color: #17a2b8;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --light-bg: #f8f9fa;
    --white: #ffffff;
    --dark-text: #212529;
    --gray-text: #6c757d;
    --border-color: #dee2e6;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 20px rgba(0,0,0,0.15);
}

* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: auto;
    overscroll-behavior: auto;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    background-attachment: fixed;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow: auto;
    overscroll-behavior-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ========================================
   Navbar Styles
   ======================================== */

.app-navbar {
    background-color: var(--primary-color) !important;
    box-shadow: var(--shadow-md);
    padding: 0.75rem 0;
    position: relative;
}

/* Botão Voltar PWA */
.btn-voltar-pwa {
    position: absolute;
    left: 15px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000;
    padding: 0;
}

.btn-voltar-pwa:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.1);
}

.btn-voltar-pwa:active {
    transform: scale(0.95);
}

.btn-voltar-pwa:focus {
    outline: none;
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--white) !important;
    transition: opacity 0.3s ease;
}

.navbar-brand:hover {
    opacity: 0.9;
}

.navbar-brand img {
    border-radius: 6px;
}

.nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    transition: all 0.3s ease;
}

.nav-link:hover {
    color: var(--white) !important;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
}

/* ========================================
   Main Container
   ======================================== */

.login-container {
    min-height: calc(100vh - 120px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1rem 0.5rem 0.5rem;
}

/* ========================================
   Login Card
   ======================================== */

.login-card {
    background: var(--white);
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    margin: auto;
    overflow-y: auto;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   Login Header
   ======================================== */

.logo-circle {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.5rem;
    box-shadow: var(--shadow-md);
    animation: pulse 2s ease-in-out infinite;
}

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

.login-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.login-title {
    color: var(--primary-color);
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.login-subtitle {
    color: var(--gray-text);
    font-size: 0.875rem;
    margin-bottom: 0;
}

/* ========================================
   Google User Info
   ======================================== */

.user-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid var(--primary-color);
    box-shadow: var(--shadow-sm);
}

/* ========================================
   Form Styles
   ======================================== */

.form-label {
    color: var(--dark-text);
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
}

.form-group {
    margin-bottom: 0.6rem;
}

.form-label i {
    color: var(--primary-color);
    margin-right: 0.25rem;
}

.form-control {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 0.55rem 0.85rem;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(5, 57, 120, 0.15);
}

.form-control-lg {
    padding: 0.75rem 1rem;
    font-size: 1rem;
}

.form-control.is-invalid {
    border-color: var(--danger-color);
}

.invalid-feedback {
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* ========================================
   Toggle Password Button
   ======================================== */

.toggle-password {
    border: 2px solid var(--border-color);
    border-left: none;
    border-radius: 0 8px 8px 0;
    background: white !important;
    transition: all 0.3s ease;
    min-width: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
}

.toggle-password i {
    font-size: 1.2rem;
    color: var(--primary-color);
    pointer-events: none;
}

.toggle-password:hover {
    background: var(--border-color) !important;
}

.toggle-password:hover i {
    color: var(--secondary-color);
}

.toggle-password:focus {
    box-shadow: none;
    border-color: var(--primary-color);
    outline: none;
}

/* Ajuste do input de senha para integrar com o botão */
.input-group > .form-control:not(:last-child) {
    border-right: none;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group-append .btn {
    border-left: 2px solid var(--border-color);
}

/* ========================================
   Links
   ======================================== */

.forgot-password {
    color: var(--primary-color);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
}

.forgot-password:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.create-account-link {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
}

.create-account-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ========================================
   Buttons
   ======================================== */

.btn-login {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--white);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login:focus {
    box-shadow: 0 0 0 0.2rem rgba(5, 57, 120, 0.3);
}

/* ========================================
   Divider
   ======================================== */

.login-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.5rem 0;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.login-divider span {
    padding: 0 1rem;
    color: var(--gray-text);
    font-size: 0.875rem;
    font-weight: 500;
}

/* ========================================
   Google Sign-In
   ======================================== */

.google-signin-wrapper {
    text-align: center;
}

.google-signin-wrapper .g-signin2 {
    display: inline-block;
    width: 100% !important;
}

.google-signin-wrapper .g-signin2 > div {
    width: 100% !important;
}

/* ========================================
   Modal Styles
   ======================================== */

.modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: var(--white);
    border-radius: 12px 12px 0 0;
    padding: 1.25rem 1.5rem;
    border-bottom: none;
}

.modal-title {
    font-weight: 600;
}

.modal-title i {
    margin-right: 0.5rem;
}

.modal-header .close {
    color: var(--white);
    opacity: 0.9;
    text-shadow: none;
}

.modal-header .close:hover {
    opacity: 1;
}

.modal-body {
    padding: 2rem 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
}

/* ========================================
   Footer
   ======================================== */

.login-footer {
    background: #053978;
    color: var(--white);
    padding: 0.75rem 0;
    margin-top: 0.5rem;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.login-footer p {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.95);
}

.login-footer img {
    opacity: 0.95;
}

/* ========================================
   PWA Splash Screen / Loading
   ======================================== */

#pwa-splash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease;
}

#pwa-splash.hidden {
    opacity: 0;
    pointer-events: none;
}

.splash-logo {
    width: 120px;
    height: 120px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    margin-bottom: 2rem;
    animation: splashPulse 1.5s ease-in-out infinite;
    /* Force hardware acceleration for better PWA performance */
    transform: translateZ(0);
    will-change: transform;
    animation-play-state: running !important;
}

@keyframes splashPulse {
    0%, 100% {
        transform: translateZ(0) scale(1);
    }
    50% {
        transform: translateZ(0) scale(1.1);
    }
}

.splash-logo img {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.splash-title {
    color: white;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.splash-subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

/* Spinner de Loading Animado */
.splash-spinner {
    width: 50px;
    height: 50px;
    position: relative;
    /* Force hardware acceleration for better PWA performance */
    transform: translateZ(0);
    will-change: transform;
}

.splash-spinner::before,
.splash-spinner::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 4px solid transparent;
    border-top-color: white;
    animation: spin 1s linear infinite;
    /* Force hardware acceleration */
    transform: translateZ(0);
    will-change: transform;
    /* Ensure animation runs even with reduced motion preferences */
    animation-play-state: running !important;
}

.splash-spinner::after {
    border-top-color: rgba(255, 255, 255, 0.3);
    animation-direction: reverse;
    animation-duration: 0.7s;
    animation-play-state: running !important;
}

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

/* Force animations even with reduced motion preference for splash screen */
@media (prefers-reduced-motion: reduce) {
    .splash-spinner::before,
    .splash-spinner::after {
        animation: spin 1s linear infinite !important;
        animation-play-state: running !important;
    }
    
    .splash-spinner::after {
        animation-direction: reverse !important;
        animation-duration: 0.7s !important;
    }
}

/* Alternativa: Dots Loading */
.splash-dots {
    display: flex;
    gap: 0.5rem;
}

.splash-dot {
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    animation: dotBounce 1.4s ease-in-out infinite;
}

.splash-dot:nth-child(1) {
    animation-delay: 0s;
}

.splash-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.splash-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotBounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 768px) {
    .login-container {
        padding: 1.5rem 0.5rem 0.5rem;
    }

    .login-card {
        padding: 1rem 1rem;
        border-radius: 12px;
    }

    .login-title {
        font-size: 1.2rem;
    }

    .login-subtitle {
        font-size: 0.8rem;
    }

    .logo-circle {
        width: 55px;
        height: 55px;
    }

    .login-logo {
        width: 35px;
        height: 45px;
    }

    .btn-login {
        font-size: 1rem;
    }

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

    .nav-link {
        font-size: 0.95rem;
    }
}

@media (max-width: 576px) {
    .login-card {
        padding: 1.5rem 1rem;
    }

    .form-control-lg {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }

    .btn-login {
        padding: 0.75rem 1.25rem;
        font-size: 0.95rem;
    }
}

/* ========================================
   Loading States
   ======================================== */

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* ========================================
   PWA Specific Optimizations
   ======================================== */

/* Melhor experiência em tela cheia */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .app-navbar {
        padding-top: calc(0.75rem + env(safe-area-inset-top));
    }

    .login-container {
        padding-top: calc(6rem + env(safe-area-inset-top));
    }
    
    /* Force animations to work in PWA mode */
    #pwa-splash {
        /* Ensure splash screen appears correctly */
        position: fixed !important;
        z-index: 99999 !important;
        display: flex !important;
        animation: none !important; /* Disable any conflicting animations */
    }
    
    .splash-spinner,
    .splash-spinner::before,
    .splash-spinner::after {
        /* Force animations in PWA */
        animation-play-state: running !important;
        will-change: transform !important;
        backface-visibility: hidden !important;
    }
    
    .splash-logo {
        /* Force logo animation in PWA */
        animation-play-state: running !important;
        will-change: transform !important;
        backface-visibility: hidden !important;
    }
}

/* Touch feedback */
@media (hover: none) and (pointer: coarse) {
    .btn-login:active {
        background: var(--primary-dark);
    }

    .nav-link:active {
        background-color: rgba(255, 255, 255, 0.2);
    }
}

/* Desabilita zoom duplo-toque no iOS */
button,
input,
select,
textarea {
    touch-action: manipulation;
}

/* ========================================
   Accessibility
   ======================================== */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus visible para acessibilidade */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ========================================
   Modal Customizations
   ======================================== */

.modal-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.modal-header .close {
    color: white;
    opacity: 1;
    text-shadow: none;
}

.modal-body .form-label {
    color: var(--primary-color);
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.modal-body select.form-control,
.modal-body select {
    font-size: 1.1rem !important;
    padding: 1rem !important;
    height: auto !important;
    min-height: 50px !important;
    border: 2px solid var(--border-color) !important;
    border-radius: 8px !important;
    background: white !important;
    color: #333 !important;
    transition: all 0.3s ease;
    line-height: 1.5 !important;
}

.modal-body select.form-control:focus,
.modal-body select:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 0.2rem rgba(5, 57, 120, 0.15) !important;
    outline: none !important;
}

.modal-body select.form-control option,
.modal-body select option {
    padding: 0.75rem !important;
    color: #333 !important;
    background: white !important;
    font-size: 1.1rem !important;
    line-height: 1.8 !important;
}

/* Força cor do texto em todos os estados */
#cmbFiliaisLavaJato,
#cmbFiliaisLavaJato option {
    color: #333 !important;
    font-size: 1.1rem !important;
}

/* Modal de Instruções PWA */
#modalInstrucoesPWA .modal-body ol {
    font-size: 1rem;
    line-height: 1.8;
}

#modalInstrucoesPWA .modal-body ol li {
    margin-bottom: 0.75rem;
}

#modalInstrucoesPWA .alert {
    border-radius: 8px;
    font-size: 0.9rem;
}

/* ========================================
   Botão Instalar PWA
   ======================================== */

#btnInstalarPWA {
    border-radius: 8px;
    padding: 0.75rem;
    font-weight: 600;
    transition: all 0.3s ease;
    border: 2px solid var(--primary-color);
    background: white;
    color: var(--primary-color);
    animation: pulse-border 2s infinite;
}

#btnInstalarPWA:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(5, 57, 120, 0.3);
}

#btnInstalarPWA i {
    margin-right: 8px;
}

@keyframes pulse-border {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(5, 57, 120, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(5, 57, 120, 0);
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    .app-navbar,
    .login-footer,
    .google-signin-wrapper,
    .forgot-password,
    .create-account-link {
        display: none;
    }
}
