/* Reset básico */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Montserrat', sans-serif;
    background-color: #fff;
    overflow-x: hidden;
}

/* Container principal - sem overflow hidden */
.container-fluid {
    min-height: 100vh;
}

/* Row principal */
.row {
    min-height: 100vh;
}

/* Lado esquerdo com imagem */
.bg-side {
    background-color: #1a1a1a;
    background-image: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)), url('../images/bg-mountain.jpg');
    background-size: cover;
    background-position: center;
    min-height: 100vh;
}

/* Container do formulário - ajustado para mobile */
.login-form-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

/* Logo - responsiva */
.login-form-container img {
    max-height: 120px;
    width: auto;
    height: auto;
}

/* Inputs */
.form-control {
    border: 2px solid #e9ecef;
    padding: 12px;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 16px; /* Previne zoom no iOS */
}

.form-control:focus {
    border-color: #ff6201;
    box-shadow: 0 0 0 0.25rem rgba(255, 98, 1, 0.25);
}

/* Botão */
.btn-primary {
    background-color: #ff6201;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-primary:hover:not(:disabled) {
    background-color: #e55a01;
    transform: translateY(-2px);
}

.btn-primary:disabled {
    background-color: #ff6201;
    opacity: 0.7;
}

/* Lado direito - com padding vertical */
.col-md-6.bg-white {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem 1.5rem;
    min-height: 100vh;
    overflow-y: auto;
}

/* ===== CAMPO DE SENHA COM ÍCONE ===== */
.password-input-group {
    position: relative;
    display: flex;
    align-items: stretch;
}

.password-input-group .form-control {
    flex: 1;
    padding-right: 3.5rem; /* Espaço para o botão */
    border-radius: 8px !important; /* Mantém o border-radius padrão */
    z-index: 1;
}

.password-input-group .btn {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: #6c757d;
    z-index: 10;
    width: 30px;
    height: 30px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.password-input-group .btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #495057;
}

.password-input-group .btn:focus {
    box-shadow: none;
    outline: none;
    background-color: rgba(0, 0, 0, 0.05);
}

/* Estados de validação para o campo de senha */
.password-input-group .form-control.is-invalid {
    border-color: #dc3545;
    background-image: none;
    padding-right: 3.5rem;
}

.password-input-group .form-control.is-valid {
    border-color: #198754;
    background-image: none;
    padding-right: 3.5rem;
}

.password-input-group .form-control.is-invalid + .btn {
    color: #dc3545;
}

.password-input-group .form-control.is-valid + .btn {
    color: #198754;
}

/* Garante que o input tenha foco adequado */
.password-input-group .form-control:focus {
    z-index: 2;
    border-color: #ff6201;
    box-shadow: 0 0 0 0.25rem rgba(255, 98, 1, 0.25);
}

/* ===== RESPONSIVIDADE ===== */

/* Responsividade para tablets */
@media (max-width: 991.98px) {
    .bg-side {
        min-height: 40vh;
    }

    .col-md-6.bg-white {
        min-height: 60vh;
        padding: 1.5rem 1rem;
    }

    .login-form-container {
        max-width: 500px;
    }
}

/* Responsividade para dispositivos móveis */
@media (max-width: 767.98px) {
    html, body {
        overflow-x: hidden;
        overflow-y: auto;
        height: auto;
        min-height: 100vh;
    }

    .container-fluid {
        min-height: 100vh;
        height: auto;
    }

    .row {
        min-height: 100vh;
        height: auto;
    }

    /* Esconde o lado esquerdo no mobile */
    .bg-side {
        display: none !important;
    }

    /* Lado direito ocupa toda a tela com scroll */
    .col-md-6.bg-white {
        width: 100% !important;
        flex: 1 1 auto;
        min-height: 100vh;
        height: auto;
        padding: 1rem;
        justify-content: flex-start;
        overflow-y: visible;
    }

    .login-form-container {
        padding: 1rem 0;
        max-width: 100%;
        width: 100%;
        margin: 1rem auto;
        display: flex;
        flex-direction: column;
        justify-content: center;
        min-height: calc(100vh - 2rem);
    }

    /* Logo menor no mobile */
    .login-form-container img {
        max-height: 80px;
        margin-bottom: 1.5rem !important;
    }

    /* Título menor no mobile */
    .login-form-container h1,
    .login-form-container h3 {
        font-size: 1.4rem;
        margin-bottom: 1.5rem;
        line-height: 1.3;
    }

    /* Inputs com altura adequada para mobile */
    .form-control-lg {
        padding: 0.875rem 1rem;
        font-size: 16px; /* Previne zoom no iOS */
        line-height: 1.5;
    }

    /* Ajuste específico para o campo de senha no mobile */
    .password-input-group .form-control-lg {
        padding-right: 3rem;
    }

    .password-input-group .btn {
        right: 8px;
        width: 28px;
        height: 28px;
    }

    /* Botão com altura adequada e espaçamento */
    .btn-lg {
        padding: 0.875rem 1rem;
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }

    /* Ajusta o container do checkbox e "esqueci senha" */
    .d-flex.justify-content-between {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start !important;
        margin-bottom: 1.5rem !important;
    }

    .d-flex.justify-content-between a {
        align-self: flex-end;
        font-size: 0.9rem;
    }

    /* Margens adequadas */
    .mb-3 {
        margin-bottom: 1rem !important;
    }

    .mb-4 {
        margin-bottom: 1.5rem !important;
    }

    /* Link de registro menor */
    .btn-sm {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}

/* Responsividade para telas muito pequenas */
@media (max-width: 479.98px) {
    .col-md-6.bg-white {
        padding: 1rem 0.75rem;
    }

    .login-form-container {
        padding: 0.75rem;
        margin-top: 1rem;
    }

    .login-form-container img {
        max-height: 60px;
        margin-bottom: 1rem !important;
    }

    .login-form-container h1,
    .login-form-container h3 {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }

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

    .password-input-group .form-control-lg {
        padding-right: 2.8rem;
    }

    .btn-lg {
        padding: 0.75rem 0.875rem;
        font-size: 1rem;
    }

    /* Checkbox e links menores */
    .form-check-label,
    .text-decoration-none {
        font-size: 0.875rem;
    }

    /* Ajusta o container do checkbox e "esqueci senha" */
    .d-flex.justify-content-between {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start !important;
    }

    .d-flex.justify-content-between a {
        align-self: flex-end;
    }
}

/* Landscape orientation em mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .col-md-6.bg-white {
        justify-content: flex-start;
        padding-top: 1rem;
        padding-bottom: 1rem;
    }

    .login-form-container {
        margin-top: 0.5rem;
    }

    .login-form-container img {
        max-height: 40px;
        margin-bottom: 0.75rem !important;
    }

    .login-form-container h1,
    .login-form-container h3 {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
    }

    .mb-3 {
        margin-bottom: 0.75rem !important;
    }

    .mb-4 {
        margin-bottom: 1rem !important;
    }
}

/* Correção para iOS Safari */
@supports (-webkit-touch-callout: none) {
    .container-fluid {
        min-height: -webkit-fill-available;
    }

    .col-md-6.bg-white {
        min-height: -webkit-fill-available;
    }
}

/* Previne zoom em inputs no iOS */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    select,
    textarea,
    input[type="text"],
    input[type="password"],
    input[type="datetime"],
    input[type="datetime-local"],
    input[type="date"],
    input[type="month"],
    input[type="time"],
    input[type="week"],
    input[type="number"],
    input[type="email"],
    input[type="url"],
    input[type="search"],
    input[type="tel"],
    input[type="color"] {
        font-size: 16px;
    }
}

/* Garante que alertas não quebrem o layout */
.alert {
    margin-bottom: 1rem;
    word-wrap: break-word;
}

/* Melhora o espaçamento em telas pequenas */
@media (max-width: 767.98px) {
    .alert {
        margin-bottom: 0.75rem;
        padding: 0.75rem;
        font-size: 0.875rem;
    }
}

/* Estilos para loading state */
.btn-primary .spinner-border {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* Melhoria na aparência geral dos botões */
.btn-outline-primary {
    color: #ff6201;
    border-color: #ff6201;
}

.btn-outline-primary:hover {
    background-color: #ff6201;
    border-color: #ff6201;
    color: white;
}

/* Estilos para mensagens de erro personalizadas */
.invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #dc3545;
}

/* Garante que a validação funcione corretamente */
.form-control.is-invalid {
    border-color: #dc3545;
    background-image: none;
}

.form-control.is-valid {
    border-color: #198754;
    background-image: none;
}

/* Correção específica para o campo de senha com validação */
.password-input-group + .invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #dc3545;
}

/* Garante que a mensagem de erro apareça mesmo com o container especial */
.password-input-group.has-error + .invalid-feedback,
.password-input-group:has(.is-invalid) + .invalid-feedback {
    display: block;
}