/* ===============================================
   LOGIN MODERNIZADO - Design Refinado com Glassmorphism
   =============================================== */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&family=Inter:wght@300;400;500;600&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: transparent;
    color: var(--login-text-color, #fff);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: var(--login-form-vertical-align, center);
    align-items: var(--login-form-horizontal-align, center);
    position: relative;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===============================================
   BACKGROUND LAYERS - Camadas de fundo com profundidade
   =============================================== */

/* Camada 1: Gradiente de cor base */
body::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background: var(--login-bg-color, 
        linear-gradient(135deg, #1e3a8a 0%, #7c3aed 50%, #ec4899 100%));
    opacity: var(--login-bg-opacity, 1);
    animation: gradientShift 20s ease infinite;
}

@keyframes gradientShift {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(5deg); }
}

/* Camada 2: Imagem de fundo (se houver) */
.bg-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background-image: var(--login-bg-image, none);
    background-position: var(--login-bg-position, center);
    background-repeat: var(--login-bg-repeat, no-repeat);
    background-size: var(--login-bg-fit, cover);
    opacity: var(--login-bg-opacity, 1);
    animation: subtleZoom 30s ease-in-out infinite alternate;
}

@keyframes subtleZoom {
    0% { transform: scale(1); }
    100% { transform: scale(1.05); }
}

/* Camada 3: Overlay com textura de ruído sutil */
body::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    background: 
        radial-gradient(circle at 20% 50%, rgba(124, 58, 237, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(236, 72, 153, 0.15) 0%, transparent 50%),
        rgba(0, 0, 0, var(--login-overlay-opacity, 0.3));
    backdrop-filter: blur(0px);
}

/* Partículas flutuantes decorativas */
.floating-particles {
    position: absolute;
    inset: 0;
    z-index: 2;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    animation: float 20s infinite ease-in-out;
}

.particle:nth-child(1) { width: 80px; height: 80px; top: 10%; left: 15%; animation-delay: 0s; }
.particle:nth-child(2) { width: 120px; height: 120px; top: 60%; left: 80%; animation-delay: 3s; }
.particle:nth-child(3) { width: 60px; height: 60px; top: 80%; left: 20%; animation-delay: 6s; }
.particle:nth-child(4) { width: 100px; height: 100px; top: 30%; left: 70%; animation-delay: 9s; }

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.3; }
    25% { transform: translate(20px, -30px) scale(1.1); opacity: 0.5; }
    50% { transform: translate(-15px, 20px) scale(0.9); opacity: 0.4; }
    75% { transform: translate(25px, 15px) scale(1.05); opacity: 0.6; }
}

/* ===============================================
   LOGIN CONTAINER - Glassmorphism refinado
   =============================================== */

.login-container {
    position: relative;
    z-index: 3;
    background: var(--login-container-bg-color, 
        linear-gradient(135deg, 
            rgba(255, 255, 255, 0.15) 0%, 
            rgba(255, 255, 255, 0.08) 100%));
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 24px;
    padding: 3rem 2.5rem;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.2),
        0 2px 8px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    max-width: 440px;
    width: 100%;
    margin-top: var(--login-form-margin-top, 0px);
    margin-bottom: var(--login-form-margin-bottom, 0px);
    margin-left: var(--login-form-margin-left, 0px);
    margin-right: var(--login-form-margin-right, 0px);
    animation: containerFadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    opacity: 0;
    transform: translateY(20px);
}

@keyframes containerFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Brilho sutil no hover do container */
.login-container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.4) 50%, 
        transparent 100%);
    opacity: 0.5;
}

/* ===============================================
   TIPOGRAFIA
   =============================================== */

.login-container h2 {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 2rem;
    text-align: center;
    margin-bottom: 2rem;
    color: var(--login-title-color, #ffffff);
    letter-spacing: -0.02em;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    background: linear-gradient(135deg, #ffffff 0%, rgba(255, 255, 255, 0.9) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: titleSlideIn 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.2s forwards;
    opacity: 0;
    transform: translateY(-10px);
}

@keyframes titleSlideIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===============================================
   FORM ELEMENTS - Inputs modernos
   =============================================== */

.mb-3 {
    margin-bottom: 1.5rem;
    animation: inputSlideIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    animation-delay: calc(0.3s + var(--item-index, 0) * 0.1s);
    opacity: 0;
    transform: translateX(-20px);
}

@keyframes inputSlideIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.form-label,
label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--login-label-color, rgba(255, 255, 255, 0.95));
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: color 0.3s ease;
}

input,
.form-control,
.form-select,
select {
    width: 100%;
    padding: 0.875rem 1.125rem;
    font-size: 0.9375rem;
    font-family: 'Inter', sans-serif;
    color: var(--login-text-color, #ffffff);
    background: rgba(255, 255, 255, 0.08);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

/* Ajuste de contraste no dropdown de empresas:
   garante que as opções fiquem legíveis sobre fundo claro */
.form-select option,
select option {
    color: #111111;
    background-color: #ffffff;
}

input::placeholder,
textarea::placeholder {
    color: var(--login-label-color, rgba(255, 255, 255, 0.5));
    font-weight: 300;
}

input:focus,
.form-control:focus,
.form-select:focus,
select:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 
        0 0 0 3px rgba(255, 255, 255, 0.1),
        0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

input:hover:not(:focus),
.form-control:hover:not(:focus),
.form-select:hover:not(:focus),
select:hover:not(:focus) {
    border-color: rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.1);
}

/* ===============================================
   BUTTON - Botão com gradiente animado
   =============================================== */

.btn-primary {
    width: 100%;
    padding: 1rem 2rem;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #ffffff;
    background: linear-gradient(135deg, #7c3aed 0%, #ec4899 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 4px 15px rgba(124, 58, 237, 0.4),
        0 2px 8px rgba(0, 0, 0, 0.2);
    margin-top: 0.5rem;
}

.btn-primary::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.2) 50%, 
        transparent 100%);
    transition: left 0.6s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 6px 20px rgba(124, 58, 237, 0.5),
        0 4px 12px rgba(0, 0, 0, 0.25);
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 
        0 2px 8px rgba(124, 58, 237, 0.4),
        0 1px 4px rgba(0, 0, 0, 0.2);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ===============================================
   STATUS INDICATORS - Spinner e ícones
   =============================================== */

#empresa_status {
    display: inline-flex;
    align-items: center;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 2px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#empresa_status_text {
    font-size: 0.8125rem;
    color: var(--login-label-color, rgba(255, 255, 255, 0.8));
}

.fa-check-circle,
#empresa_status_ok {
    color: #10b981;
    filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.5));
    animation: checkPulse 0.5s ease;
}

@keyframes checkPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* ===============================================
   ALERTS E MENSAGENS
   =============================================== */

.alert {
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    border-radius: 10px;
    border: 1px solid transparent;
    backdrop-filter: blur(10px);
    animation: alertSlideDown 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes alertSlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fecaca;
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
    color: #a7f3d0;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.3);
    color: #fde68a;
}

.alert-info {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
    color: #bfdbfe;
}

.is-invalid,
input.is-invalid,
.form-control.is-invalid {
    border-color: rgba(239, 68, 68, 0.6) !important;
    background: rgba(239, 68, 68, 0.1) !important;
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.invalid-feedback {
    color: #fca5a5;
    font-size: 0.8125rem;
    margin-top: 0.375rem;
    display: block;
}

/* ===============================================
   LINKS
   =============================================== */

.mt-3 {
    margin-top: 1.5rem;
}

.text-center {
    text-align: center;
}

a {
    color: var(--login-text-color, #ffffff);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 400;
    position: relative;
    display: inline-block;
    transition: all 0.3s ease;
    opacity: 0.9;
}

a::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background: currentColor;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

a:hover {
    opacity: 1;
    transform: translateY(-1px);
}

a:hover::after {
    width: 100%;
}

/* ===============================================
   RESPONSIVIDADE
   =============================================== */

@media (max-width: 768px) {
    body {
        align-items: center !important;
        justify-content: center !important;
        padding: 1rem;
    }
    
    .login-container {
        margin: 0 !important;
        padding: 2rem 1.5rem;
        max-width: 100%;
    }
    
    .login-container h2 {
        font-size: 1.625rem;
    }
    
    .particle {
        display: none; /* Oculta partículas em mobile para performance */
    }
}

@media (max-width: 480px) {
    .login-container {
        padding: 1.75rem 1.25rem;
        border-radius: 20px;
    }
    
    .login-container h2 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    input,
    .form-control,
    .form-select {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
    
    .btn-primary {
        padding: 0.875rem 1.5rem;
    }
}

/* ===============================================
   NEUTRALIZAÇÃO DE ESTILOS GLOBAIS
   =============================================== */

body.has-bg-image::before,
body.has-bg-overlay::after {
    content: none !important;
}

/* Força as cores do login mesmo com regras globais !important */
.login-container label,
.login-container .form-label {
    color: var(--login-label-color, rgba(255, 255, 255, 0.95)) !important;
}

.login-container,
.login-container input,
.login-container select,
.login-container textarea,
.login-container .form-control,
.login-container .form-select {
    color: var(--login-text-color, #fff) !important;
}

.login-container .form-text,
.login-container .text-muted {
    color: var(--login-label-color, rgba(255, 255, 255, 0.8)) !important;
}

.login-container input::placeholder,
.login-container textarea::placeholder {
    color: var(--login-label-color, rgba(255, 255, 255, 0.5)) !important;
}

/* ===============================================
   ACESSIBILIDADE
   =============================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visível para navegação por teclado */
*:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
}

/* ===============================================
   UTILITÁRIOS
   =============================================== */

.d-inline-flex { display: inline-flex; }
.align-items-center { align-items: center; }
.ms-2 { margin-left: 0.5rem; }
.me-2 { margin-right: 0.5rem; }
.w-100 { width: 100%; }
.small { font-size: 0.875rem; }
.text-muted { color: rgba(255, 255, 255, 0.7); }
.text-success { color: #10b981; }

.btn-close {
    background: transparent;
    border: none;
    color: currentColor;
    opacity: 0.7;
    cursor: pointer;
    padding: 0.5rem;
    transition: opacity 0.2s ease;
}

.btn-close:hover {
    opacity: 1;
}

.alert-dismissible {
    position: relative;
    padding-right: 3rem;
}

.alert-dismissible .btn-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
}

.fade {
    transition: opacity 0.15s linear;
}

.fade:not(.show) {
    opacity: 0;
}

.show {
    opacity: 1;
}
