/* ========================================
   MODAIS RESPONSIVOS - ANATOMIA FINANCEIRA
   ========================================
   CSS global para tornar todos os modais
   responsivos em telas pequenas
   ======================================== */

/* ========================================
   CHOICES.JS - ESTILOS PERSONALIZADOS
   ======================================== */

/* Classe personalizada para Choices.js */
.choices-banco {
    position: relative;
    display: inline-block;
    vertical-align: top;
    width: 100%;
    background-color: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    min-height: 48px;
    overflow: hidden;
}

.choices-banco.is-focused {
    border-color: #2c5530;
    box-shadow: 0 0 0 3px rgba(44, 85, 48, 0.1);
}

.choices-banco.is-open {
    border-color: #2c5530;
    box-shadow: 0 0 0 3px rgba(44, 85, 48, 0.1);
}

.choices-banco .choices__inner {
    background-color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    min-height: 48px;
    overflow: hidden;
    padding: 0.75rem 1rem;
}

.choices-banco .choices__list--single .choices__item {
    color: #374151;
    font-weight: 500;
}

.choices-banco .choices__placeholder {
    color: #9ca3af;
    opacity: 1;
}

.choices-banco .choices__list--dropdown {
    background-color: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: block;
}

.choices-banco .choices__item--choice {
    color: #374151;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    transition: background-color 0.2s ease;
    cursor: pointer;
    display: block;
}

.choices-banco .choices__item--choice:hover {
    background-color: #f8fafc;
}

.choices-banco .choices__item--choice.is-highlighted {
    background-color: #2c5530;
    color: #fff;
}

.choices-banco .choices__input {
    background-color: transparent;
    border: none;
    font-size: 1rem;
    margin: 0;
    padding: 0;
    width: 100%;
}

.choices-banco .choices__input:focus {
    outline: none;
}

/* Garantir que o dropdown seja visível */
.choices-banco.is-open .choices__list--dropdown {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Estilo para o botão de dropdown */
.choices-banco .choices__button {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: center;
    background-repeat: no-repeat;
    background-size: 16px;
    border: none;
    cursor: pointer;
    height: 20px;
    padding: 0;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
}

/* ========================================
   CONFIGURAÇÕES GERAIS PARA TODOS OS MODAIS
   ======================================== */

/* Aplicar scroll automático em modais quando necessário */
.modal-dialog-scrollable .modal-body {
    overflow-y: auto;
    scroll-behavior: smooth;
    /* Estilização da barra de scroll */
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color, #2c5530) #f1f5f9;
}

/* Estilização da barra de scroll para WebKit */
.modal-dialog-scrollable .modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-dialog-scrollable .modal-body::-webkit-scrollbar-track {
    background: #f1f5f0;
    border-radius: 3px;
}

.modal-dialog-scrollable .modal-body::-webkit-scrollbar-thumb {
    background: var(--accent-color, #2c5530);
    border-radius: 3px;
}

.modal-dialog-scrollable .modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color-light, #22543d);
}

/* ========================================
   RESPONSIVIDADE PARA TELAS PEQUENAS
   ======================================== */

/* Telas com altura menor que 800px */
@media (max-height: 800px) {
    .modal-dialog {
        max-height: 95vh !important;
        margin: 1rem auto !important;
    }

    .modal-content {
        max-height: 95vh !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .modal-body {
        max-height: calc(95vh - 140px) !important;
        overflow-y: auto !important;
        flex: 1 !important;
    }
}

/* Telas com altura menor que 600px */
@media (max-height: 600px) {
    .modal-body {
        max-height: calc(95vh - 120px) !important;
        padding: 1rem !important;
    }

    .modal-header {
        padding: 1rem !important;
    }

    .modal-footer {
        padding: 0.75rem 1rem !important;
    }

    .modal-title {
        font-size: 1.1rem !important;
    }
}

/* Telas com altura menor que 500px */
@media (max-height: 500px) {
    .modal-body {
        max-height: calc(95vh - 100px) !important;
        padding: 0.75rem !important;
    }

    .modal-header {
        padding: 0.75rem !important;
    }

    .modal-footer {
        padding: 0.5rem 0.75rem !important;
    }

    .modal-title {
        font-size: 1rem !important;
    }

    .form-control,
    .form-select {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.9rem !important;
    }
}

/* ========================================
   MODAIS ESPECÍFICOS QUE PRECISAM DE ATENÇÃO
   ======================================== */

/* Modal de Nova Conta Bancária */
.modal-conta .modal-dialog {
    max-height: 90vh !important;
}

.modal-conta .modal-content {
    max-height: 90vh !important;
    display: flex !important;
    flex-direction: column !important;
}

.modal-conta .modal-body {
    overflow-y: auto !important;
    flex: 1 !important;
}

/* Modal de Novo Cartão */
.modal-cartao .modal-dialog {
    max-height: 90vh !important;
}

.modal-cartao .modal-content {
    max-height: 90vh !important;
    display: flex !important;
    flex-direction: column !important;
}

.modal-cartao .modal-body {
    overflow-y: auto !important;
    flex: 1 !important;
}

/* Modais de Despesa e Receita */
.modal-form .modal-body {
    overflow-y: auto !important;
}

/* ========================================
   MELHORIAS PARA MODAIS GRANDES
   ======================================== */

/* Modais grandes (modal-lg, modal-xl) */
.modal-lg,
.modal-xl {
    max-height: 95vh !important;
}

.modal-lg .modal-content,
.modal-xl .modal-content {
    max-height: 95vh !important;
    display: flex !important;
    flex-direction: column !important;
}

.modal-lg .modal-body,
.modal-xl .modal-body {
    overflow-y: auto !important;
    flex: 1 !important;
}

/* ========================================
   COMPATIBILIDADE COM BOOTSTRAP
   ======================================== */

/* Garantir que modais com modal-dialog-scrollable funcionem */
.modal-dialog-scrollable {
    max-height: calc(100vh - 1rem) !important;
}

.modal-dialog-scrollable .modal-content {
    max-height: calc(100vh - 1rem) !important;
}

/* ========================================
   MELHORIAS DE UX
   ======================================== */

/* Adicionar sombra sutil quando há scroll */
.modal-body:not(:last-child) {
    box-shadow: inset 0 -10px 10px -10px rgba(0, 0, 0, 0.1);
}

/* Indicador visual de scroll disponível */
.modal-body[style*="overflow-y: auto"]::after {
    content: "";
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    height: 20px;
    background: linear-gradient(transparent, rgba(255, 255, 255, 0.8));
    pointer-events: none;
    z-index: 1;
}