/* --- UTILS CRÍTICOS (No topo para garantir carregamento) --- */
.hidden, #loader-overlay.hidden { 
    display: none !important; 
    visibility: hidden !important; 
    opacity: 0 !important;
    pointer-events: none !important;
}

/* --- Variáveis de Design (Modern Edu Theme) --- */
:root {
    --primary: #2563eb;        
    --primary-dark: #1e40af;    
    --primary-light: #eff6ff; 
    --secondary: #0ea5e9;        
    --accent: #f59e0b;        
    
    /* Variável Dinâmica da Carteirinha (Padrão) */
    --card-color: #2563eb;    

    /* Cores de Fundo e Texto */
    --bg-body: #f1f5f9;        
    --bg-card: #ffffff;        
    --text-main: #1e293b;        
    --text-muted: #64748b;        
    
    /* Sombras e Bordas */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-float: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-pill: 50px;
}

/* --- Configurações Globais --- */
* { box-sizing: border-box; }

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    padding-bottom: 100px; /* Espaço para FAB */
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p { margin: 0; }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; outline: none; }

/* --- HERO SECTION --- */
.hero-header {
    position: relative; width: 100%; height: 320px;
    background-color: var(--primary-dark); background-size: cover; background-position: center;
    border-bottom-left-radius: 30px; border-bottom-right-radius: 30px;
    overflow: hidden; box-shadow: var(--shadow-md);
    display: flex; align-items: center; justify-content: center; text-align: center; color: white;
}
.hero-bg-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(to bottom, rgba(30, 58, 138, 0.6), rgba(30, 58, 138, 0.9)); z-index: 1;
}
.hero-content {
    position: relative; z-index: 2; padding: 20px; display: flex; flex-direction: column; align-items: center; width: 100%; max-width: 800px;
}
.logo-container { margin-bottom: 15px; }
.sys-logo {
    width: 100px; height: 100px; object-fit: contain; background: white;
    border-radius: 50%; padding: 5px; box-shadow: 0 4px 15px rgba(0,0,0,0.2); border: 3px solid rgba(255,255,255,0.3);
}
.text-container h1 { font-size: 1.8rem; font-weight: 700; margin-bottom: 5px; text-shadow: 0 2px 4px rgba(0,0,0,0.3); }
.sys-phrase { font-size: 0.95rem; font-weight: 300; opacity: 0.9; max-width: 90%; margin: 0 auto; }

/* --- CONTEÚDO PRINCIPAL --- */
main { max-width: 900px; margin: -40px auto 0; padding: 0 20px; position: relative; z-index: 10; }

.section-title {
    margin-bottom: 25px; display: flex; flex-direction: column; align-items: flex-start;
    width: 100%; background: white; padding: 15px; border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
}
.section-title h2 { font-size: 1.2rem; color: var(--primary); font-weight: 700; display: flex; align-items: center; gap: 10px; line-height: 1.4; flex-wrap: wrap; }
.title-bar { width: 50px; height: 4px; background: var(--accent); border-radius: 2px; margin-top: 8px; }

/* --- CARDS DE EVENTOS --- */
.cards-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media(min-width: 768px) { .cards-grid { grid-template-columns: 1fr 1fr; } }

.card-event {
    background: var(--bg-card); border-radius: var(--radius-md); box-shadow: var(--shadow-md);
    padding: 20px; transition: all 0.3s ease; border: 1px solid rgba(0,0,0,0.05);
    display: flex; flex-direction: column; position: relative; overflow: visible;
}
.card-event:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); border-color: var(--secondary); }

.card-status {
    align-self: flex-start; font-size: 0.75rem; font-weight: 700; padding: 6px 12px;
    border-radius: 20px; text-transform: uppercase; margin-bottom: 15px; display: inline-block;
    letter-spacing: 0.5px; position: relative;
}
.status-ativo { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }

.card-title { font-size: 1.25rem; color: var(--primary-dark); font-weight: 700; margin-bottom: 12px; line-height: 1.4; display: block; }
.card-desc { font-size: 0.95rem; color: var(--text-muted); margin-bottom: 20px; flex-grow: 1; }
.card-dates {
    display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--text-main);
    background: var(--primary-light); padding: 10px 15px; border-radius: 8px; margin-bottom: 20px;
    font-weight: 600; border: 1px solid #dbeafe;
}

.btn-inscrever {
    width: 100%; padding: 14px; background: linear-gradient(90deg, var(--primary), #3b82f6);
    color: white; font-weight: 600; border-radius: var(--radius-sm); display: flex;
    justify-content: space-between; align-items: center; transition: all 0.3s;
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2);
}
.btn-inscrever:hover { opacity: 1; transform: translateY(-2px); box-shadow: 0 6px 12px rgba(37, 99, 235, 0.3); }
.btn-inscrever i { transition: transform 0.3s; }
.btn-inscrever:hover i { transform: translateX(5px); }

/* --- FORMULÁRIO --- */
#area-inscricao { position: relative; padding-top: 40px; }
.nav-bar { margin-bottom: 25px; display: flex; justify-content: flex-start; }
.btn-back {
    background: white; padding: 12px 24px; border-radius: var(--radius-pill); font-weight: 600;
    box-shadow: var(--shadow-md); color: var(--text-main); transition: all 0.2s;
    border: 1px solid #e2e8f0; display: flex; align-items: center; gap: 8px; cursor: pointer;
}
.btn-back:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-light); }

.form-card-container { width: 100%; }
.form-card {
    background: var(--bg-card); border-radius: var(--radius-lg); padding: 25px;
    box-shadow: var(--shadow-lg); border: 1px solid rgba(0,0,0,0.05);
}
.form-header {
    display: flex; align-items: flex-start; gap: 15px; margin-bottom: 30px;
    padding-bottom: 20px; border-bottom: 1px solid #e2e8f0;
}
.header-icon {
    width: 50px; height: 50px; background: var(--primary-light); color: var(--primary);
    border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; flex-shrink: 0;
}
.subtitle { font-size: 0.9rem; color: var(--text-muted); margin-top: 5px; }

.grid-form { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media(min-width: 600px) { .grid-form { grid-template-columns: 1fr 1fr; } }

label { display: block; margin-bottom: 8px; font-size: 0.95rem; font-weight: 600; color: var(--text-main); }
input, select {
    width: 100%; padding: 14px; border: 2px solid #e2e8f0; border-radius: var(--radius-sm);
    font-size: 1rem; background: #f8fafc; transition: all 0.3s; color: var(--text-main);
}
input:focus, select:focus { border-color: var(--primary); background: white; box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1); }

.upload-section {
    background: #f8fafc; border: 2px dashed #cbd5e1; border-radius: var(--radius-md);
    padding: 25px; margin-top: 30px;
}
.upload-info {
    font-size: 0.9rem; color: var(--text-muted); margin-bottom: 20px;
    display: flex; align-items: center; gap: 10px; font-weight: 500;
}
.file-input-wrapper { margin-bottom: 15px; }
.file-label {
    display: flex; align-items: center; gap: 15px; background: white; padding: 15px;
    border-radius: var(--radius-sm); border: 1px solid #e2e8f0; cursor: pointer;
    transition: all 0.2s; box-shadow: var(--shadow-sm);
}
.file-label:hover { border-color: var(--primary); background: var(--primary-light); transform: translateY(-2px); }
.icon-box {
    width: 45px; height: 45px; background: #f1f5f9; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 1.2rem;
}
.text-box { flex: 1; }
.text-box strong { display: block; font-size: 1rem; color: var(--text-main); margin-bottom: 2px; }
.text-box small { font-size: 0.85rem; color: var(--text-muted); }
.status-icon { color: var(--accent); font-size: 1.2rem; }
input[type="file"] { display: none; }

.divider-form {
    display: flex; align-items: center; text-align: center; margin: 40px 0 30px 0;
    color: var(--text-muted); font-size: 0.85rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px;
}
.divider-form::before, .divider-form::after { content: ''; flex: 1; border-bottom: 1px solid #e2e8f0; }
.divider-form span { padding: 0 15px; background: var(--bg-card); }

.btn-submit {
    width: 100%; padding: 18px; background: var(--primary); color: white;
    font-size: 1.15rem; font-weight: 700; border-radius: var(--radius-pill);
    box-shadow: var(--shadow-float); display: flex; align-items: center; justify-content: center;
    gap: 12px; transition: transform 0.2s; margin-top: 10px;
}
.btn-submit:active { transform: scale(0.98); }

/* --- FAB --- */
#fab-consulta {
    position: fixed; bottom: 25px; right: 25px; background: var(--primary-dark);
    color: white; border-radius: var(--radius-pill); padding: 16px 28px;
    display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow-float);
    z-index: 1000; transition: transform 0.2s; cursor: pointer;
}
#fab-consulta:hover { transform: translateY(-3px); background: var(--primary); }
.fab-text { font-weight: 600; font-size: 1rem; }
.fab-icon { font-size: 1.3rem; }

/* --- MODAIS MODERNOS (REDESENHADO) --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.8); backdrop-filter: blur(8px); z-index: 2000;
    display: flex; align-items: center; justify-content: center;
}
.modal-content {
    background: white; width: 90%; max-width: 420px; border-radius: 24px;
    padding: 30px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); position: relative;
    max-height: 90vh; overflow-y: auto; text-align: center;
}
.modal-header-modern {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;
    position: absolute; top: 20px; right: 20px; width: auto; left: auto;
}
/* Esconder título do header pois já está no corpo centralizado */
.modal-header-modern h3 { display: none; }

.btn-close-modern {
    background: #f1f5f9; width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; color: var(--text-muted);
    transition: all 0.2s; font-size: 1.1rem; border: none; cursor: pointer;
}
.btn-close-modern:hover { background: #e2e8f0; color: #ef4444; transform: rotate(90deg); }

.modal-body-centered { padding-top: 10px; }

.icon-circle {
    width: 80px; height: 80px; background: linear-gradient(135deg, var(--primary-light), #fff); 
    color: var(--primary); font-size: 2rem; border-radius: 50%; 
    display: flex; align-items: center; justify-content: center; 
    margin: 0 auto 20px; box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.1);
    border: 1px solid #dbeafe;
}

.modal-body-centered h3 { margin-bottom: 10px; color: var(--text-main); }
.modal-body-centered p { font-size: 0.95rem; color: var(--text-muted); margin-bottom: 25px; line-height: 1.6; }

/* INPUT GROUP MODERNO (FUSIONADO) */
.input-group-modern {
    position: relative; display: flex; width: 100%; margin-top: 20px;
}
.input-group-modern input {
    width: 100%; padding: 16px 20px; padding-right: 60px; /* Espaço para o botão */
    border-radius: 50px; border: 2px solid #e2e8f0;
    font-size: 1.1rem; background: #f8fafc; outline: none;
    transition: all 0.3s ease; text-transform: uppercase;
    letter-spacing: 2px; font-weight: 600; color: var(--primary-dark);
    text-align: center;
}
.input-group-modern input::placeholder { text-transform: none; letter-spacing: normal; font-weight: 400; font-size: 1rem; }
.input-group-modern input:focus {
    border-color: var(--primary); background: white;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}
.input-group-modern button {
    position: absolute; right: 6px; top: 6px; bottom: 6px;
    width: 48px; border-radius: 50%;
    background: var(--primary); color: white; border: none;
    font-size: 1.2rem; cursor: pointer; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center; padding: 0;
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2);
}
.input-group-modern button:hover { background: var(--primary-dark); transform: scale(1.05); }
.input-group-modern button:active { transform: scale(0.95); }

/* RESULT AREA */
.result-area { min-height: 20px; margin-top: 20px; }
.result-card {
    padding: 20px; border-radius: 16px; text-align: left;
    background: white; border: 1px solid #e2e8f0; 
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    animation: fadeInUp 0.4s ease-out;
}
.result-success { border-left: 5px solid #10b981; background: #f0fdf4; }
.result-pending { border-left: 5px solid #f59e0b; background: #fffbeb; }

.btn-ver-cart {
    width: 100%; margin-top: 15px; padding: 14px; 
    background: linear-gradient(90deg, #2563eb, #3b82f6); color: white;
    border-radius: 12px; font-weight: 600; transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2); border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-ver-cart:hover { transform: translateY(-2px); box-shadow: 0 6px 12px rgba(37, 99, 235, 0.3); }

/* --- CARTEIRINHA DIGITAL (ESTRUTURA DE VISUALIZAÇÃO WEB) --- */
.transparent-modal { background: transparent !important; box-shadow: none !important; padding: 0; }
.carteirinha-wrapper {
    width: 100%; max-width: 350px; height: 520px; margin: 0 auto;
    perspective: 1200px; -webkit-perspective: 1200px;
}
.carteirinha-card-inner {
    position: relative; width: 100%; height: 100%; text-align: center;
    transition: transform 0.8s; transform-style: preserve-3d; -webkit-transform-style: preserve-3d;
    cursor: pointer;
}
.carteirinha-card-inner.is-flipped { transform: rotateY(180deg); -webkit-transform: rotateY(180deg); }

.carteirinha-face {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    -webkit-backface-visibility: hidden; backface-visibility: hidden;
    transform: translateZ(0); -webkit-transform: translateZ(0);
    border-radius: 20px; overflow: hidden;
    box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.4);
    background-color: #0f172a; color: white;
}

/* FRENTE */
.carteirinha-front {
    z-index: 2;
    background: radial-gradient(rgba(255,255,255,0.1) 1px, transparent 1px), linear-gradient(135deg, var(--card-color, #2563eb), #0f172a);
    background-size: 15px 15px, 100% 100%;
    display: flex; flex-direction: column; padding: 20px;
    transform: rotateY(0deg); -webkit-transform: rotateY(0deg);
}

/* --- ATUALIZAÇÃO NOVO CABEÇALHO 3 LINHAS --- */
.cart-header {
    display: flex; 
    align-items: center; /* Centraliza verticalmente com a logo */
    gap: 12px; 
    margin-bottom: 20px;
    position: relative; z-index: 2; 
    text-align: left; 
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}
.cart-logo {
    width: 50px; height: 50px; 
    background: white; border-radius: 50%;
    padding: 3px; object-fit: contain; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.cart-org-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* NOVAS CLASSES PARA AS 3 LINHAS */
.line-1-sistema {
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    line-height: 1.1;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    color: #ffffff;
}

.line-2-secretaria {
    font-size: 0.65rem;
    font-weight: 400;
    text-transform: uppercase;
    opacity: 0.9;
    line-height: 1.1;
    margin-bottom: 2px;
}

.line-3-evento {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #fbbf24; /* Amarelo destaque */
    line-height: 1.1;
}
/* ------------------------------------------- */

.cart-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; z-index: 2; gap: 15px; }
.cart-photo-frame {
    width: 110px; height: 140px; background: #e2e8f0; border: 3px solid white;
    border-radius: 12px; overflow: hidden; box-shadow: 0 4px 10px rgba(0,0,0,0.2); margin-bottom: 5px;
}
.cart-photo-frame img { width: 100%; height: 100%; object-fit: cover; }
.cart-info-main { width: 100%; text-align: center; }
.cart-info-main h2 { font-size: 1.1rem; text-transform: uppercase; font-weight: 700; margin-bottom: 5px; line-height: 1.2; text-shadow: 0 2px 2px rgba(0,0,0,0.2); }
.cart-info-main .cart-course {
    font-size: 0.85rem; background: rgba(255,255,255,0.15); padding: 4px 10px;
    border-radius: 15px; display: inline-block; margin-bottom: 10px;
}
.cart-details-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-top: 10px; }
.detail-item { background: rgba(0,0,0,0.2); padding: 5px; border-radius: 6px; text-align: center; }
.detail-label { display: block; font-size: 0.6rem; text-transform: uppercase; opacity: 0.7; }
.detail-value { display: block; font-size: 0.75rem; font-weight: 600; font-family: monospace; }

/* Ocultar elementos exclusivos de impressão na visualização Web */
.cart-print-auth, .assinatura-box-print { display: none; }

/* VERSO */
.carteirinha-back {
    transform: rotateY(180deg); -webkit-transform: rotateY(180deg);
    display: flex; flex-direction: column; padding: 20px;
    background: linear-gradient(135deg, var(--card-color, #1e293b), #000000);
}
.cart-back-header {
    text-align: center; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 2px;
    opacity: 0.6; margin-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 10px;
}
.qr-code-box {
    width: 130px; height: 130px; background: white; padding: 10px;
    border-radius: 12px; margin: 0 auto 10px; display: flex; align-items: center;
    justify-content: center;
}
.qr-code-box img { width: 100%; height: 100%; object-fit: contain; }
.validity-box { text-align: center; margin-bottom: 0; }
.validity-label { font-size: 0.8rem; opacity: 0.8; text-transform: uppercase; display: block; }
.validity-year { font-size: 3rem; font-weight: 800; line-height: 1; color: var(--accent); text-shadow: 0 4px 10px rgba(0,0,0,0.3); display: block; }

/* LOGO CENTRALIZADA (VISUAL DA TELA) */
.logo-center-container {
    display: flex; justify-content: center; align-items: center;
    flex: 1; padding: 10px 0;
}
.logo-sme-virtual {
    max-height: 100px; /* Grande para visualização */
    width: auto; object-fit: contain;
}

.cart-footer { 
    margin-top: 0; text-align: center; font-size: 0.65rem; opacity: 0.6; 
    border-top: 1px solid rgba(255,255,255,0.1); padding-top: 10px; 
}
.cart-sec-name { font-weight: 600; display: block; margin-bottom: 2px; text-transform: uppercase; }
.cart-sec-role { font-size: 0.65rem; opacity: 0.7; text-transform: uppercase; display: block; }

/* BOTÕES DO MODAL */
.modal-actions-row { margin-top: 25px; display: flex; justify-content: center; gap: 15px; flex-wrap: wrap; }
.btn-action-pri { 
    background: white; color: var(--primary); padding: 12px 24px; border-radius: 30px; 
    font-weight: 700; box-shadow: var(--shadow-md); border: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
}
.btn-action-sec { 
    background: rgba(255,255,255,0.1); color: white; padding: 12px 24px; border-radius: 30px; 
    border: 1px solid rgba(255,255,255,0.3); cursor: pointer; display: flex; align-items: center; gap: 8px;
}
.btn-flip {
    background: var(--accent); color: white; padding: 12px 24px; border-radius: 30px;
    font-weight: 700; border: none; cursor: pointer; box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 8px;
}

/* --- FOOTER --- */
#main-footer { text-align: center; margin-top: 50px; color: var(--text-muted); font-size: 0.9rem; }
.footer-links a { font-size: 0.8rem; color: var(--primary); opacity: 0.8; }

/* --- LOADER MODERNIZADO (ATUALIZADO) --- */
#loader-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    /* Fundo sutil em gradiente radial para um look mais moderno */
    background: radial-gradient(circle at center, #ffffff 0%, #f1f5f9 100%);
    z-index: 9999;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    transition: opacity 0.3s ease;
}

.loader-logo { 
    width: 140px; /* Aumentado de 80px */
    height: auto;
    max-height: 140px;
    margin-bottom: 30px; 
    animation: pulse-logo 2s infinite ease-in-out; 
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.1));
    object-fit: contain;
}

.spinner-ring {
    width: 50px; height: 50px; 
    border: 4px solid #cbd5e1; 
    border-top: 4px solid var(--primary);
    border-radius: 50%; 
    animation: spin 0.8s linear infinite; 
    margin-bottom: 20px;
    box-shadow: 0 0 15px rgba(37, 99, 235, 0.1);
}

#loader-text {
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-size: 0.85rem;
    animation: fadeIn 1s;
}

@keyframes pulse-logo { 
    0% { transform: scale(1); opacity: 1; } 
    50% { transform: scale(1.05); opacity: 0.9; } 
    100% { transform: scale(1); opacity: 1; } 
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Animações */
.fade-in { animation: fadeIn 0.6s ease-out forwards; opacity: 0; }
.fade-in-down { animation: fadeInDown 0.8s ease-out forwards; opacity: 0; }
.fade-in-up { animation: fadeInUp 0.6s ease-out forwards; opacity: 0; }
.zoom-in { animation: zoomIn 0.3s ease-out forwards; }
@keyframes fadeIn { to { opacity: 1; } }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes zoomIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }

/* --- SKELETON LOADING (Efeito de Carregamento) --- */
.skeleton {
    background: #e2e8f0;
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.card-skeleton {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    border: 1px solid rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 100%;
    min-height: 280px;
}

.skeleton-badge { width: 100px; height: 24px; border-radius: 20px; }
.skeleton-title { width: 70%; height: 32px; margin-top: 10px; }
.skeleton-date { width: 50%; height: 20px; }
.skeleton-text { width: 100%; height: 60px; }
.skeleton-btn { width: 100%; height: 50px; margin-top: auto; border-radius: 50px; }

/* --- IMPRESSÃO CORRIGIDA: LAYOUT EMPILHADO + DETALHES ALINHADOS + ASSINATURA + LOGO CENTRAL --- */
@media print {
    /* Forçar orientação Retrato na folha para empilhar os cards largos */
    @page { 
        size: portrait; 
        margin: 10mm; 
    }

    /* Oculta tudo por padrão */
    body > * { display: none !important; }
    
    /* Regra A: Se o print-layer estiver ativo (Fichas/Relatórios) */
    #print-layer { 
        display: block !important; 
        position: absolute; top: 0; left: 0; width: 100%; 
        background: white; 
        padding: 0; margin: 0; 
    }
    #print-layer * { visibility: visible; }

    /* Regra B: Se o Modal de Carteirinha Admin estiver aberto */
    #modal-carteirinha-admin:not(.hidden) {
        display: block !important; 
        position: absolute; top: 0; left: 0; 
        width: 100%; background: white; z-index: 9999; margin: 0; padding: 0;
        visibility: visible;
    }
    #modal-carteirinha-admin:not(.hidden) * { visibility: visible; }
    .modal-content, .modal-content-cart { box-shadow: none; padding: 0; margin: 0; background: transparent; }
    
    /* WRAPPER EMPILHADO */
    .carteirinha-wrapper {
        perspective: none; height: auto; margin-top: 10mm;
        display: flex; 
        flex-direction: column; /* EMPILHADO VERTICALMENTE */
        gap: 5mm; 
        align-items: center; /* Centraliza na folha */
        justify-content: start;
        width: 100% !important; 
    }
    
    .carteirinha-card-inner {
        transform: none !important; position: relative; height: auto;
        display: contents; 
    }
    
    /* DIMENSÕES HORIZONTAIS DO CARTÃO (120mm x 75mm) */
    .carteirinha-face {
        position: relative; transform: none !important;
        width: 120mm; height: 75mm; /* Formato LARGO */
        outline: 1px dashed #ccc; 
        box-sizing: border-box;
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
        font-size: 11pt; 
        margin-bottom: 0;
        color: white !important;
        background: linear-gradient(135deg, var(--card-color, #2563eb), #0f172a) !important;
        overflow: hidden; 
        border-radius: 4mm;
        /* MUDANÇA: Grid para garantir posição da logo e footer */
        display: grid;
        grid-template-columns: 40mm 1fr;
        /* Rows: Header | QR+Ano | Footer Area */
        grid-template-rows: 8mm 1fr 20mm; 
        padding: 4mm;
        align-items: center;
    }

    /* --- FRENTE (Layout Compacto) --- */
    .carteirinha-front {
        padding: 2.5mm !important; /* Margem interna reduzida para caber tudo */
        display: grid;
        grid-template-columns: 30mm 1fr; /* Coluna Foto | Coluna Dados */
        /* Row 1: Header (13mm)
           Row 2: Nome/Curso (Auto)
           Row 3: Detalhes (1fr - ocupa o resto)
           Row 4: Rodapé (5mm) */
        grid-template-rows: 13mm auto 1fr 6mm; 
        gap: 1mm; /* Gaps mínimos */
        align-items: center;
    }

    /* HEADER FRENTE */
    .carteirinha-front .cart-header {
        grid-column: 1 / -1; grid-row: 1;
        display: flex; align-items: center; gap: 3mm;
        border-bottom: 1pt solid rgba(255,255,255,0.4);
        margin: 0; padding-bottom: 0.5mm; height: 100%;
    }
    .carteirinha-front .cart-logo { width: 10mm; height: 10mm; padding: 0.5mm; }
    
    /* ATUALIZADO: AJUSTE DO HEADER 3 LINHAS NA IMPRESSÃO */
    .carteirinha-front .cart-org-info {
        display: flex; flex-direction: column; justify-content: center;
    }
    .carteirinha-front .line-1-sistema {
        font-size: 8pt; line-height: 1; font-weight: 800; margin-bottom: 1px;
    }
    .carteirinha-front .line-2-secretaria {
        font-size: 6pt; line-height: 1; opacity: 0.9; margin-bottom: 1px;
    }
    .carteirinha-front .line-3-evento {
        font-size: 6.5pt; line-height: 1; font-weight: 700; color: #fbbf24;
    }

    /* CORPO FRENTE */
    .carteirinha-front .cart-body { display: contents; }

    /* FOTO À ESQUERDA */
    .carteirinha-front .cart-photo-frame {
        width: 28mm; height: 36mm;
        margin: 0; border: 1.5pt solid white;
        grid-column: 1; grid-row: 2 / span 2; 
        align-self: center; margin-top: 1mm;
    }

    /* DADOS À DIREITA (Nome e Curso) */
    .carteirinha-front .cart-info-main { 
        grid-column: 2; grid-row: 2;
        text-align: left; margin-left: 2mm; margin-top: 1mm;
        display: flex; flex-direction: column; justify-content: center;
        align-items: flex-start; /* FIX: Evita que o fundo estique até o final */
        margin-bottom: 1mm;
    }
    
    .carteirinha-front .cart-info-main h2 { 
        font-size: 12pt; margin-bottom: 0.5mm; line-height: 1.1; 
        text-transform: uppercase; font-weight: 800;
        white-space: normal; overflow: visible; 
    }
    .carteirinha-front .cart-info-main .cart-course { 
        padding: 0.5mm 3mm; font-size: 8pt; border-radius: 3mm; 
        margin-bottom: 0; display: inline-block;
        background: rgba(255,255,255,0.2);
        white-space: normal;
        /* Garante que o fundo não ocupe 100% da largura, mas apenas o texto */
        width: fit-content; 
    }

    /* DETALHES EXTRAS (CPF, Nasc, Matrícula) - Alinhado ao topo */
    .carteirinha-front .cart-details-grid {
        display: grid; 
        grid-template-columns: 1fr 1fr; 
        gap: 1mm;
        grid-column: 2; grid-row: 3;
        margin-left: 2mm; margin-top: 1mm;
        align-self: flex-start;
    }
    .carteirinha-front .detail-item {
        background: transparent; padding: 0; border: none; text-align: left;
        margin-bottom: 0.5mm; display: flex; flex-direction: column;
    }
    .carteirinha-front .detail-label { 
        font-size: 5.5pt; text-transform: uppercase; opacity: 0.8; 
        display: block; margin-bottom: 0.5mm;
    }
    .carteirinha-front .detail-value { 
        font-size: 7.5pt; font-weight: 700; font-family: monospace;
        white-space: nowrap; 
    }

    /* CÓDIGO ÚNICO (RODAPÉ) - Compactado */
    .cart-print-auth {
        display: block !important;
        grid-column: 1 / -1; grid-row: 4;
        text-align: center; font-family: monospace; font-size: 8pt;
        background: rgba(0,0,0,0.3); padding: 1mm; border-radius: 1mm;
        margin-top: 0; align-self: end;
    }
    .cart-print-auth span { opacity: 0.7; font-size: 7pt; margin-right: 4px; }
    .cart-print-auth strong { font-size: 9pt; letter-spacing: 1.5px; color: #fff; }

    /* --- VERSO (Layout Horizontal Interno) --- */
    .carteirinha-back {
        padding: 4mm !important;
        display: grid;
        grid-template-columns: 40mm 1fr; 
        grid-template-rows: 8mm 1fr 20mm; 
        align-items: center;
    }

    /* Header Verso */
    .carteirinha-back .cart-back-header {
        grid-column: 1 / -1; grid-row: 1;
        font-size: 8pt; border-bottom: 1pt solid rgba(255,255,255,0.3);
        margin: 0; padding-bottom: 1mm; position: static; white-space: nowrap;
    }

    /* QR Code */
    .carteirinha-back .qr-code-box {
        grid-column: 1; grid-row: 2;
        width: 35mm; height: 35mm; padding: 2mm; background: white; margin: 0;
        align-self: center; justify-self: center;
    }

    /* Validade */
    .carteirinha-back .validity-box {
        grid-column: 2; grid-row: 2;
        text-align: center; margin: 0;
        align-self: center; justify-self: center;
    }
    .carteirinha-back .validity-label { font-size: 8pt; display: block; margin-bottom: 2mm; }
    .carteirinha-back .validity-year { font-size: 36pt; font-weight: 900; line-height: 1; display: block; }

    /* LOGO CENTRALIZADA NA IMPRESSÃO - POSICIONADA NO GRID À DIREITA */
    .logo-center-container {
        /* TRUQUE DO GRID: Joga a logo centralizada para o Canto Direito no rodapé */
        grid-column: 2; 
        grid-row: 3;
        display: flex !important;
        justify-content: flex-end; /* Alinha à direita */
        align-items: flex-end;
        height: 100%;
        margin: 0;
    }
    .logo-sme-virtual {
        max-height: 18mm; /* Altura máxima para impressão */
        max-width: 40mm;
        width: auto; 
        object-fit: contain;
    }

    /* Footer Verso - POSICIONADO NO GRID À ESQUERDA */
    .carteirinha-back .cart-footer {
        grid-column: 1 / -1; /* Ocupa tudo, mas vamos alinhar o conteúdo */
        grid-row: 3;
        position: static; padding: 0; margin: 0; border: none;
        font-size: 7.5pt; align-self: flex-end;
        display: flex; 
        flex-direction: column; 
        align-items: flex-start; /* Alinha à esquerda */
        justify-content: flex-end;
        width: 100%;
        border-top: 1pt solid rgba(255,255,255,0.2);
        padding-top: 1mm;
    }

    /* Ajuste na caixa de assinatura */
    .assinatura-box-print {
        display: block !important; 
        width: 35mm; height: 10mm; margin-bottom: 0;
        position: relative; z-index: 5;
    }
    .assinatura-box-print img {
        width: 100%; height: 100%; object-fit: contain; 
        object-position: bottom left; filter: invert(1);
    }

    .carteirinha-back .cart-sec-name { font-size: 9pt; margin-bottom: 0.5mm; line-height: 1; }
    .carteirinha-back .cart-sec-role { 
        display: block !important; 
        font-size: 6.5pt; text-transform: uppercase; opacity: 0.8; 
    }

    /* Esconder botões na impressão */
    .modal-actions-row, .cart-actions, .btn-close-modern, .btn-action-pri, .btn-action-sec, .btn-flip { display: none !important; }

    /* Layout da Ficha A4 (Mantido) */
    .ficha-container { font-family: Arial, sans-serif; color: #000; width: 100%; max-width: 210mm; margin: 0 auto; }
}

@media (max-width: 1200px) {
    .charts-wrapper { grid-template-columns: 1fr; height: auto; }
}
