/* Carteirinha Wrapper */
.carteirinha-wrapper {
    display: none;
    flex-direction: column;
    align-items: stretch;
    margin-top: 6px;
    margin-bottom: 16px;
}

.carteirinha-wrapper.active {
    display: flex;
}

.carteirinha-top {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 8px;
}

/* Carteirinha estilo identidade */
.carteirinha-identidade {
    width: 100%;
    max-width: 600px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 25px var(--shadow);
    border: 3px solid var(--primary);
    overflow: hidden;
    margin: 0 auto;
}

/* Header */
.carteirinha-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid var(--primary-dark);
}

.logo-escola .logo-brasao {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
    background: white;
    max-width: 100%;
    max-height: 100%;
}

.dados-escola {
    flex: 1;
}

.nome-escola {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 3px;
    text-transform: uppercase;
}

.tipo-documento {
    font-size: 12px;
    opacity: 0.9;
}

/* Corpo */
.carteirinha-corpo {
    display: flex;
    padding: 20px;
    gap: 25px;
    min-height: 240px;
    align-items: flex-start;
}

.coluna-foto {
    flex: 0 0 126px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.foto-container {
    border: 2px solid var(--primary);
    padding: 3px;
    background: var(--light);
    border-radius: 5px;
    width: 120px;
    height: 160px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.foto-aluno {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    display: block;
    background: #e9ecef;
    border-radius: 3px;
    max-width: 100%;
    max-height: 100%;
}

.coluna-dados {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.linha-dado {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

.linha-dado .rotulo {
    font-weight: bold;
    color: var(--primary);
    width: 120px;
    font-size: 12px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.linha-dado .valor {
    color: var(--dark);
    font-weight: 600;
    font-size: 13px;
    flex: 1;
}

.valor-horario {
    color: var(--success);
    font-weight: bold;
    font-size: 13px;
}

.valor-horario.nao-definido {
    color: var(--danger);
}

/* Rodapé */
.carteirinha-rodape {
    background: var(--light);
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.logo-rodape {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-escola-rodape {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 5px;
    max-width: 100%;
    max-height: 100%;
}

.texto-rodape {
    font-size: 12px;
    color: var(--primary);
    font-weight: bold;
}

.data-geracao {
    text-align: center;
}

.rotulo-data {
    font-size: 10px;
    color: var(--muted);
    display: block;
}

.valor-data {
    font-size: 11px;
    color: var(--dark);
    font-weight: bold;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Garantir que as imagens não ultrapassem os containers */
.carteirinha-header img,
.carteirinha-rodape img {
    max-width: 100%;
    height: auto;
}

/* ========== NOVAS FUNCIONALIDADES ========== */

/* Miniaturas de alunos na listagem */
.aluno-com-foto {
    display: flex;
    align-items: center;
    gap: 12px;
}

.miniatura-aluno {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
    background: var(--light);
}

.miniatura-aluno.miniatura-error {
    display: none;
}

.miniatura-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 12px;
    border: 2px solid var(--primary);
}

/* Estados do login inteligente */
.login-loading {
    position: relative;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234f46e5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a9 9 0 11-6.219-8.56'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 16px 16px !important;
    padding-right: 35px !important;
}

.login-success {
    border-color: #10b981 !important;
    background-color: #f0fdf4 !important;
}

.login-error {
    border-color: #ef4444 !important;
    background-color: #fef2f2 !important;
}

/* Loading spinner */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f4f6;
    border-top: 2px solid #4f46e5;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}
/* ========== CORREÇÃO MOBILE CARTEIRINHA ========== */

@media (max-width: 768px) {
    /* Ajusta o layout da carteirinha */
    .carteirinha-corpo {
        flex-direction: column;
        padding: 15px;
        gap: 15px;
        align-items: center;
    }

    .coluna-foto {
        flex: 0 0 auto;
        width: 100%;
        max-width: 150px;
        align-items: center;
    }

    .foto-container {
        width: 140px !important;  /* Aumenta para mobile */
        height: 180px !important; /* Aumenta para mobile */
        border-width: 3px;
    }

    .foto-aluno {
        object-fit: cover !important;
        object-position: center top !important;
        width: 100% !important;
        height: 100% !important;
        border-radius: 2px;
    }

    /* Ajusta a coluna de dados */
    .coluna-dados {
        width: 100%;
    }

    .linha-dado {
        flex-wrap: wrap;
    }

    .linha-dado .rotulo {
        width: 100px;
        font-size: 11px;
    }

    .linha-dado .valor {
        font-size: 12px;
        flex: 1;
    }
}

/* Para telas muito pequenas */
@media (max-width: 480px) {
    .carteirinha-identidade {
        max-width: 100%;
        margin: 0 10px;
    }

    .coluna-foto {
        max-width: 130px;
    }

    .foto-container {
        width: 130px !important;
        height: 170px !important;
    }

    .carteirinha-header {
        padding: 12px 15px;
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .logo-escola .logo-brasao {
        width: 40px;
        height: 40px;
    }
}
