/**
 * Estilos do Modal de Matrícula
 * Design moderno e responsivo para captura de matrícula do aluno
 * 
 * @author Arquiteto de Software
 * @version 1.0
 */

/* ===== OVERLAY E MODAL BASE ===== */
.matricula-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5) !important;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    /* Removido backdrop-filter para compatibilidade */
}

.matricula-modal-overlay.show {
    opacity: 1 !important;
    visibility: visible !important;
}

.matricula-modal {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.18);
    max-width: 420px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.96) translateY(12px);
    transition: transform 0.3s cubic-bezier(.4,0,.2,1);
    position: relative;
}

.matricula-modal.show {
    transform: scale(1) translateY(0);
}

/* ===== HEADER ===== */
.matricula-modal-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #2563EB 0%, #764ba2 100%);
    color: white;
    border-radius: 16px 16px 0 0;
}

.matricula-modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: white;
    margin: 0;
}

.matricula-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    color: white;
}

.matricula-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== BODY ===== */
.matricula-modal-body {
    padding: 24px;
    background: #f8f9fa;
}

/* ===== KIT INFO - REGRAS UNIVERSAIS ===== */
.kit-info {
    background: #fff;
    border-radius: 12px;
    margin-bottom: 24px;
    border: 1px solid #e9ecef;
    padding: 20px;
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: center;
    text-align: center;
}

/* Container da imagem - sempre à esquerda */
.kit-image-container {
    flex-shrink: 0;
}

.kit-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    background: linear-gradient(135deg, #2563EB 0%, #764ba2 100%);
}

/* Container dos detalhes - sempre centralizado */
.kit-details {
    flex: 1;
    min-width: 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Nome do kit - regra universal para qualquer tamanho */
.kit-name {
    margin: 0 0 8px 0;
    font-size: 1rem;
    font-weight: 600;
    color: #212529;
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
    max-width: 100%;
}

/* Preço do kit - regra universal para qualquer valor */
.kit-price {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #28a745;
    text-align: center;
    white-space: nowrap;
    display: block;
    width: 100%;
}

/* ===== RESPONSIVIDADE PARA KIT INFO ===== */
@media (max-width: 480px) {
    .kit-info {
        flex-direction: column;
        text-align: center;
        padding: 16px;
    }
    
    .kit-image-container {
        align-self: center;
        margin-bottom: 12px;
    }
    
    .kit-details {
        width: 100%;
    }
    
    .kit-name {
        font-size: 0.95rem;
        margin-bottom: 6px;
    }
    
    .kit-price {
        font-size: 1rem;
    }
}

/* ===== FORMULÁRIO ===== */
.matricula-form {
    margin-top: 8px;
}

/* ===== INPUT COM BOTÃO ===== */
.input-with-button {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.input-with-button .matricula-input {
    flex: 1;
}

.btn-search {
    padding: 12px 16px;
    background: #667eea;
    color: white;
    border: 2px solid #667eea;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
    gap: 6px;
}

.btn-search:hover {
    background: #5a6fd8;
    border-color: #5a6fd8;
    transform: translateY(-1px);
}

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

.btn-search:disabled {
    background: #6c757d;
    border-color: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.btn-search i {
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: white;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-label i {
    color: #6c757d;
    font-size: 0.9rem;
}


.matricula-input,
.cpf-cnpj-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #764ba2;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: #f4f6fb;
    color: #212529 !important;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.08);
}

.matricula-input {
    text-align: center;
    color: #212529 !important;
    font-weight: 600;
    letter-spacing: 1px;
    background: #e9eafc;
}

.cpf-cnpj-input[readonly] {
    background: #e9ecef !important;
    color: #495057;
    padding: 12px 14px;
    border: 1.5px solid #764ba2;
    border-radius: 8px;
    background: #fff;
    color: #222 !important;
}

.cpf-cnpj-input:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(118, 75, 162, 0.15);
    color: #212529 !important;
}

.matricula-input.error,
.cpf-cnpj-input.error {
    color: #222 !important;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15);
    color: #212529 !important;
}

.input-help {
    margin-top: 6px;
}

.input-help small {
    box-shadow: 0 0 0 2px rgba(118, 75, 162, 0.18);
    align-items: center;
    gap: 4px;
    color: #764ba2;
    font-size: 0.85rem;
}

.error-message {
    margin-top: 8px;
    padding: 8px 12px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 1rem;
    color: #764ba2;
    font-weight: 500;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.error-message i {
    color: #dc3545;
    font-size: 0.85rem;
}

.recent-matriculas {
    font-size: 0.95rem;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    color: #fff;
    border-top: 1px solid #e9ecef;
}

.matriculas-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.18);
}

.matricula-recent-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
    border-radius: 20px;
    transition: all 0.2s ease;
    border: 1px solid #764ba2;
    background: #f4f6fb;
    color: #764ba2;
}

.matricula-recent-btn:hover {
    background: #764ba2;
    color: white;
    border-color: #764ba2;
    transform: translateY(-2px);
}

/* ===== FOOTER ===== */
.matricula-modal-footer {
    padding: 16px 24px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn {
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    min-width: 120px;
    justify-content: center;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-secondary {
    background: #e9ecef;
    color: #764ba2;
}

.btn-secondary:hover:not(:disabled) {
    background: #764ba2;
    color: white;
    transform: translateY(-2px);
}

.btn-primary {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(118, 75, 162, 0.18);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(118, 75, 162, 0.22);
}

.btn-outline-secondary {
    background: transparent;
    color: #764ba2;
    border: 1px solid #764ba2;
}

.btn-outline-secondary:hover {
    background: #764ba2;
    color: white;
    border-color: #764ba2;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
    min-width: auto;
}

/* ===== RESPONSIVIDADE ===== */
@media (max-width: 576px) {
    .matricula-modal-overlay {
        padding: 10px;
    }
    
    .matricula-modal {
        max-width: 100%;
        margin: 0;
        border-radius: 12px;
    }
    
    .matricula-modal-header {
        padding: 20px 20px 12px;
        border-radius: 12px 12px 0 0;
    }
    
    .matricula-modal-title {
        font-size: 1.1rem;
    }
    
    .matricula-modal-body {
        padding: 20px;
    }
    
    .kit-info {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }
    
    .kit-image {
        width: 80px;
        height: 80px;
    }
    
    .matricula-modal-footer {
        padding: 12px 20px 20px;
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .matriculas-list {
        justify-content: center;
    }
}

/* ===== ANIMAÇÕES ===== */
@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
        display: block;
        visibility: visible;
    }
}

@keyframes modalSlideOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
}

/* ===== ACESSIBILIDADE ===== */
.matricula-modal:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .matricula-modal-overlay,
    .matricula-modal,
    .btn,
    .matricula-input,
    .matricula-recent-btn {
        transition: none;
    }
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    .matricula-modal {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .matricula-modal-header {
        border-bottom-color: #4a5568;
    }
    
    .kit-info {
        background: #4a5568;
        border-color: #718096;
    }
    
    .kit-name {
        color: #e2e8f0;
    }
    
    .matricula-input {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }
    
    .matricula-input:focus {
        border-color: #667eea;
    }
    
    .recent-matriculas {
        border-top-color: #4a5568;
    }
    
    .matricula-recent-btn {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }
}

/* ===== ANIMAÇÃO PARA CAMPO AUTO-PREENCHIDO ===== */
.form-control.auto-filled {
    animation: autoFillHighlight 2s ease-out;
    border-color: #28a745 !important;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25) !important;
}

@keyframes autoFillHighlight {
    0% {
        background-color: rgba(40, 167, 69, 0.1);
        border-color: #28a745;
    }
    50% {
        background-color: rgba(40, 167, 69, 0.2);
    }
    100% {
        background-color: transparent;
        border-color: #28a745;
    }
}

/* Indicador visual de campo preenchido automaticamente */
.form-control.auto-filled::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="%2328a745"><path d="M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z"/></svg>') no-repeat center;
    background-size: contain;
    opacity: 0;
    animation: fadeInCheck 0.5s ease-in-out 0.5s forwards;
}

@keyframes fadeInCheck {
    from {
        opacity: 0;
        transform: translateY(-50%) scale(0.5);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}

/* ===== NOTIFICAÇÃO DE AUTO-PREENCHIMENTO ===== */
.auto-fill-notification {
    margin-top: 5px;
    padding: 8px 12px;
    background: rgba(40, 167, 69, 0.1);
    border: 1px solid rgba(40, 167, 69, 0.3);
    border-radius: 4px;
    animation: slideInNotification 0.3s ease-out;
}

.auto-fill-notification small {
    font-weight: 500;
}

@keyframes slideInNotification {
    from {
        opacity: 0;
        transform: translateY(-10px);
        max-height: 0;
        padding: 0 12px;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 50px;
        padding: 8px 12px;
    }
}

/* ===== ESTADOS DOS INPUTS ===== */
#nomeInput.success {
    border-color: #28a745;
    background-color: #f0fff4;
    color: #155724;
}

#nomeInput.warning {
    border-color: #ffc107;
    background-color: #fffbf0;
    color: #856404;
}

#nomeInput.error {
    border-color: #dc3545;
    background-color: #fff5f5;
    color: #721c24;
}

#nomeLoading {
    display: inline-block;
    margin-top: 4px;
    color: #6c757d;
    font-size: 0.875rem;
}

#nomeLoading i {
    margin-right: 4px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #495057;
    font-size: 0.9rem;
}

.form-group input[readonly] {
    background-color: #f8f9fa;
    cursor: not-allowed;
}

/* ===== CAMPO NOME DO ALUNO - FORÇAR VISIBILIDADE ===== */
#nomeAlunoGroup {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

#nomeAlunoInput {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* ===== CAMPO NOME DO ALUNO - LAYOUT COM BOTÃO ===== */
.input-group {
    display: flex;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.input-group input {
    flex: 1;
    border: 1px solid #ddd;
    border-right: none;
    border-radius: 8px 0 0 8px;
    padding: 12px 16px;
    font-size: 16px;
    background-color: #f8f9fa;
}

.input-group input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.btn-buscar {
    border: 1px solid #007bff;
    border-left: none;
    border-radius: 0 8px 8px 0;
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 100px;
    justify-content: center;
}

.btn-buscar:hover {
    background: linear-gradient(135deg, #0056b3, #004085);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

.btn-buscar:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.3);
}

.btn-buscar:disabled {
    background: #6c757d;
    border-color: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-buscar i {
    font-size: 14px;
}

/* ===== MENSAGENS DE STATUS ===== */
.input-help {
    margin-top: 6px;
}

.input-help small {
    color: #6c757d;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.loading-indicator {
    margin-top: 8px;
}

.loading-indicator small {
    color: #ffc107;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.success-message {
    margin-top: 8px;
}

.success-message small {
    color: #28a745;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.error-message {
    margin-top: 8px;
}

.error-message small {
    color: #dc3545;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== PLACEHOLDER COLORS - PADRONIZAÇÃO PROFISSIONAL ===== */

/* Placeholder para inputs normais - cor consistente e profissional */
.matricula-input::placeholder,
.cpf-cnpj-input::placeholder {
    color: #94a3b8 !important;
    opacity: 1 !important;
    font-weight: 400;
    transition: color 0.2s ease;
}

/* Placeholder para inputs readonly (mais suave e italic) */
.cpf-cnpj-input[readonly]::placeholder {
    color: #94a3b8 !important;
    opacity: 0.8 !important;
    font-style: italic;
    font-weight: 300;
}

/* Placeholder para campos de busca */
.search-input::placeholder {
    color: #94a3b8 !important;
    opacity: 0.9 !important;
    font-weight: 400;
}

/* Placeholder em foco (mais visível e contrastado) */
.matricula-input:focus::placeholder,
.cpf-cnpj-input:focus::placeholder {
    color: #64748b !important;
    opacity: 0.7 !important;
    transition: all 0.2s ease;
}

/* Estados especiais com cores semânticas */
.form-control.error::placeholder {
    color: #dc3545 !important;
    opacity: 0.7 !important;
}

.form-control.success::placeholder {
    color: #28a745 !important;
    opacity: 0.7 !important;
}

/* Placeholder para campos específicos do modal */
#matriculaInput::placeholder {
    color: #94a3b8 !important;
    opacity: 1 !important;
    font-weight: 400;
}

#nomeAlunoInput::placeholder {
    color: #94a3b8 !important;
    opacity: 0.8 !important;
    font-style: italic;
}

#cpfCnpjInput::placeholder {
    color: #94a3b8 !important;
    opacity: 1 !important;
    font-weight: 400;
}

/* Hover effect nos placeholders */
.matricula-input:hover::placeholder,
.cpf-cnpj-input:hover::placeholder {
    color: #64748b !important;
    opacity: 0.9 !important;
}

/* Compatibilidade com diferentes navegadores */
.matricula-input::-webkit-input-placeholder,
.cpf-cnpj-input::-webkit-input-placeholder {
    color: #94a3b8 !important;
    opacity: 1 !important;
}

.matricula-input::-moz-placeholder,
.cpf-cnpj-input::-moz-placeholder {
    color: #94a3b8 !important;
    opacity: 1 !important;
}

.matricula-input::-webkit-input-placeholder,
.cpf-cnpj-input::-webkit-input-placeholder {
    color: #94a3b8 !important;
    opacity: 1 !important;
}

.matricula-input::-moz-placeholder,
.cpf-cnpj-input::-moz-placeholder {
    color: #94a3b8 !important;
    opacity: 1 !important;
}

/* Fallback para browsers que não suportam -webkit-input-placeholder */
.matricula-input::placeholder,
.cpf-cnpj-input::placeholder {
    color: #94a3b8 !important;
    opacity: 1 !important;
}

/* ===== CORREÇÃO COR DO TEXTO DIGITADO ===== */

/* Especificidade máxima para garantir cor visível do texto */
#matriculaInput {
    color: #212529 !important;
    background-color: #ffffff !important;
    font-weight: 600 !important;
    text-align: center !important;
}

#matriculaInput:focus {
    color: #212529 !important;
    background-color: #ffffff !important;
}

#matriculaInput:hover {
    color: #212529 !important;
    background-color: #ffffff !important;
}

/* Garantir que o texto seja sempre visível */
.form-control#matriculaInput {
    color: #212529 !important;
    background-color: #ffffff !important;
}

.input-group .form-control#matriculaInput {
    color: #212529 !important;
    background-color: #ffffff !important;
}

/* Estilos para outros campos também */
#nomeAlunoInput,
#cpfCnpjInput {
    color: #212529 !important;
    background-color: #ffffff !important;
}

#nomeAlunoInput[readonly] {
    background-color: #f8f9fa !important;
    color: #495057 !important;
