/* --- CORE: Variáveis e Reset --- */
:root {
    --primary: #0f172a; --primary-light: #334155;
    --accent: #0ea5e9; --accent-hover: #0284c7;
    --success: #10b981; --danger: #ef4444; --warning: #f59e0b;
    --bg-body: #f1f5f9; --bg-card: #ffffff;
    --text-main: #1e293b; --text-muted: #64748b;
    --border: #e2e8f0; --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --radius: 12px; --header-h: 65px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; outline: none; margin: 0; padding: 0; }
body { margin: 0; background: var(--bg-body); color: var(--text-main); font-family: 'Inter', sans-serif; padding-top: var(--header-h); display: flex; flex-direction: column; min-height: 100vh; }
a { text-decoration: none; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
.flex { display: flex; align-items: center; } 
.flex-col { flex-direction: column; } 
.gap-2 { gap: 0.5rem; } 
.gap-3 { gap: 0.75rem; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.w-full { width: 100%; }
.text-center { text-align: center; }

/* --- UI KIT: Botões e Inputs --- */
.btn { padding: 0.6rem 1.2rem; border-radius: 8px; font-weight: 600; font-size: 0.9rem; border: none; cursor: pointer; transition: 0.2s; display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: white; box-shadow: 0 4px 12px rgba(14, 165, 233, 0.2); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f8fafc; color: var(--primary); border-color: var(--primary-light); }
.btn-icon { padding: 8px; width: 36px; height: 36px; border-radius: 50%; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

.form-group { margin-bottom: 1rem; text-align: left; }
.label { display: block; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 0.4rem; }
.input { width: 100%; padding: 0.7rem 1rem; border: 1px solid var(--border); border-radius: 8px; font-size: 0.95rem; background: var(--bg-card); transition: 0.2s; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1); }
select.input { appearance: none; background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 1rem center; background-size: 1em; }

/* --- HEADER & NAV --- */
.app-header { background: rgba(255,255,255,0.95); backdrop-filter: blur(10px); height: var(--header-h); position: fixed; top: 0; width: 100%; z-index: 999; border-bottom: 1px solid var(--border); padding: 0 1.5rem; }
.brand { font-weight: 800; font-size: 1.25rem; color: var(--primary); gap: 10px; cursor: pointer; }
.brand img { height: 32px; width: auto; }
.nav-actions { gap: 10px; }
.nav-actions .user-chip { background: #f1f5f9; padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }

/* Menu Avançado */
.menu-advanced { position: relative; }
.menu-dropdown { position: absolute; top: 100%; right: 0; margin-top: 8px; background: white; border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.15); min-width: 200px; padding: 8px; z-index: 1000; display: none; }
.menu-dropdown.show { display: block; animation: slideDown 0.2s; }
.menu-item { padding: 10px 14px; border-radius: 6px; cursor: pointer; transition: 0.2s; display: flex; align-items: center; gap: 10px; color: var(--text-main); }
.menu-item:hover { background: #f1f5f9; }
.menu-item i { width: 20px; text-align: center; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* --- TOAST NOTIFICATIONS --- */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 10000; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { background: white; padding: 12px 20px; border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); display: flex; align-items: center; gap: 10px; animation: slideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); min-width: 250px; border-left: 4px solid var(--primary); pointer-events: auto; }
.toast.success { border-left-color: var(--success); } 
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--accent); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* --- LOGIN --- */
.auth-container { position: fixed; inset: 0; background: var(--bg-body); z-index: 2000; display: flex; justify-content: center; align-items: center; padding: 1.5rem; }
.auth-card { background: white; width: 100%; max-width: 400px; padding: 2rem; border-radius: 16px; box-shadow: var(--shadow); text-align: center; }
.auth-tabs { display: flex; background: #f1f5f9; padding: 4px; border-radius: 8px; margin-bottom: 1.5rem; }
.auth-tab { flex: 1; padding: 8px; border-radius: 6px; font-size: 0.9rem; font-weight: 600; color: var(--text-muted); cursor: pointer; transition: 0.2s; }
.auth-tab.active { background: white; color: var(--primary); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }

/* --- QR CODE READER --- */
.qr-reader-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 3000; display: none; align-items: center; justify-content: center; padding: 20px; }
.qr-reader-modal.show { display: flex; }
.qr-reader-box { background: white; border-radius: 16px; padding: 20px; max-width: 500px; width: 100%; }
.qr-reader-video { width: 100%; border-radius: 8px; background: #000; max-height: 400px; }
.qr-reader-overlay { position: relative; }
.qr-scanner-frame { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 250px; height: 250px; border: 3px solid var(--accent); border-radius: 12px; pointer-events: none; }
.qr-scanner-frame::before, .qr-scanner-frame::after { content: ''; position: absolute; width: 30px; height: 30px; border: 3px solid var(--accent); }
.qr-scanner-frame::before { top: -3px; left: -3px; border-right: none; border-bottom: none; }
.qr-scanner-frame::after { bottom: -3px; right: -3px; border-left: none; border-top: none; }

/* --- CARD DIGITAL --- */
.viewer-container { padding: 1rem 1rem 1.5rem; display: flex; flex-direction: column; align-items: center; width: 100%; animation: fadeIn 0.5s; min-height: calc(100vh - var(--header-h)); overflow-y: auto; }
.breadcrumb-nav { width: 100%; max-width: 340px; margin-bottom: 10px; }
.breadcrumb-nav .btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.id-logo { display: block; margin: 0 auto; }
.card-wrapper { position: relative; width: 100%; max-width: 340px; margin-bottom: 1rem; }

.action-float { position: absolute; top: 0; right: -55px; display: flex; flex-direction: column; gap: 10px; }
.float-btn { width: 45px; height: 45px; background: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--primary); box-shadow: 0 4px 12px rgba(0,0,0,0.1); cursor: pointer; transition: 0.2s; font-size: 1.1rem; }
.float-btn:hover { background: var(--accent); color: white; transform: translateY(-2px); }
@media(max-width: 500px) { .action-float { right: 0; top: -60px; flex-direction: row; width: 100%; justify-content: flex-end; } }

.id-card { background: white; border-radius: 16px; overflow: hidden; box-shadow: 0 20px 40px rgba(0,0,0,0.12); position: relative; width: 100%; aspect-ratio: 1 / 1.55; display: flex; flex-direction: column; }
.id-header { background: var(--primary); padding: 1rem 0.8rem; text-align: center; color: white; position: relative; flex-shrink: 0; }
.id-badge { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 1.5px; opacity: 0.8; margin-bottom: 4px; font-weight: 700; border: 1px solid rgba(255,255,255,0.3); display: inline-block; padding: 2px 6px; border-radius: 4px; }
.id-school { font-size: 1rem; font-weight: 800; line-height: 1.1; margin: 0; }
.id-ribbon { position: absolute; bottom: -8px; left: 0; background: var(--warning); color: white; padding: 3px 16px; font-size: 0.7rem; font-weight: 700; clip-path: polygon(0 0, 100% 0, 85% 100%, 0% 100%); box-shadow: 2px 2px 5px rgba(0,0,0,0.2); }

.id-content { padding: 2.5rem 1rem 1rem; text-align: center; flex: 1; display: flex; flex-direction: column; align-items: center; overflow-y: auto; min-height: 0; }
.id-avatar-wrapper { width: 95px; height: 95px; border-radius: 50%; border: 3px solid white; outline: 2px solid var(--primary); background: #f1f5f9; margin-top: -60px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); margin-bottom: 6px; overflow: hidden; position: relative; cursor: pointer; transition: transform 0.2s; }
.id-avatar-wrapper:hover { transform: scale(1.05); }
.id-avatar-wrapper:hover .avatar-edit-overlay { opacity: 1; }
.id-avatar { width: 100%; height: 100%; object-fit: cover; object-position: center center; display: block; }
.avatar-edit-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.2s; border-radius: 50%; color: white; font-size: 1.2rem; }
.id-name { font-size: 1rem; font-weight: 800; color: var(--text-main); margin: 0; line-height: 1.1; }
.id-role { color: var(--accent); font-weight: 600; font-size: 0.75rem; margin-bottom: 0.6rem; }

.id-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; width: 100%; text-align: center; background: #f8fafc; padding: 0.7rem; border-radius: 8px; border: 1px solid var(--border); }
.id-field { text-align: center; }
.id-field h4 { font-size: 0.55rem; text-transform: uppercase; color: var(--text-muted); margin: 0 0 1px 0; font-weight: 700; }
.id-field p { font-size: 0.75rem; font-weight: 600; color: var(--text-main); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.id-verification { margin-top: 8px; font-size: 0.65rem; color: var(--text-muted); text-align: center; padding: 0 8px; word-break: break-all; line-height: 1.3; }
.id-verified { margin-top: 5px; font-size: 0.7rem; color: var(--success); text-align: center; display: flex; align-items: center; justify-content: center; gap: 5px; }

/* --- ADMIN PANEL --- */
.admin-layout { max-width: 1000px; width: 100%; margin: 20px auto; padding: 0 15px; animation: slideUp 0.4s; }
.admin-card { background: white; border-radius: 12px; box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.admin-tab-content { display: block; }
.admin-tab-content.hidden { display: none; }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 20px; }
.stat-box { background: linear-gradient(135deg, #f8fafc, #fff); border: 1px solid var(--border); padding: 1.5rem; border-radius: 12px; display: flex; align-items: center; gap: 15px; }
.stat-icon { width: 48px; height: 48px; background: rgba(14, 165, 233, 0.1); color: var(--accent); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.stat-info h3 { font-size: 1.5rem; font-weight: 800; margin: 0; color: var(--primary); }
.stat-info p { font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); margin: 0; font-weight: 600; }
.table-responsive { overflow-x: auto; border-radius: 8px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
thead { background: #f8fafc; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { font-weight: 700; color: var(--text-muted); text-transform: uppercase; font-size: 0.75rem; }
td img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); vertical-align: middle; margin-right: 8px; }
.badge { padding: 3px 8px; border-radius: 12px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; }
.badge.active { background: #dcfce7; color: #15803d; } 
.badge.expired { background: #fee2e2; color: #b91c1c; }

/* File Upload */
.upload-area { border: 2px dashed var(--border); border-radius: 8px; padding: 20px; text-align: center; cursor: pointer; transition: 0.2s; position: relative; background: #fafafa; }
.upload-area:hover { border-color: var(--accent); background: #f0f9ff; }
.upload-icon { font-size: 2rem; color: var(--text-muted); margin-bottom: 10px; }
.preview-img { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; border: 3px solid var(--accent); display: none; margin: 0 auto; }

/* --- PDF PRINT (CR80 Precision - Sem Bordas) --- */
#pdf-generator-box { position: fixed; left: -9999px; top: 0; background: white; overflow: visible; }
.pdf-page-crachas, .pdf-page-card { page-break-after: always; border: none !important; margin: 0 !important; padding: 0 !important; box-sizing: border-box; background: white !important; }
.pdf-page-crachas *, .pdf-page-card * { box-sizing: border-box; }
.pdf-side-bar { width: 90px; background: var(--primary); height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 5px; color: white; text-align: center; }
.pdf-main-content { flex: 1; padding: 10px 15px; display: flex; flex-direction: column; justify-content: center; position: relative; }
.pdf-avatar { width: 50px; height: 50px; border-radius: 50%; border: 2px solid var(--primary); object-fit: cover; }

/* Modal de Impressão */
.print-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 3000; display: none; align-items: center; justify-content: center; }
.print-modal.show { display: flex; }
.print-options { background: white; border-radius: 16px; padding: 30px; max-width: 400px; width: 90%; }
.print-option { padding: 20px; border: 2px solid var(--border); border-radius: 12px; margin-bottom: 15px; cursor: pointer; transition: 0.2s; }
.print-option:hover { border-color: var(--accent); background: #f0f9ff; }
.print-option.selected { border-color: var(--accent); background: #e0f2fe; }
.print-option h4 { margin: 0 0 8px 0; color: var(--primary); }
.print-option p { margin: 0; font-size: 0.85rem; color: var(--text-muted); }

/* Modal de PDF */
#pdf-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 3000; display: none; align-items: center; justify-content: center; }
#pdf-modal.show { display: flex; }
.pdf-options { background: white; border-radius: 16px; padding: 30px; max-width: 400px; width: 90%; }
.pdf-option { padding: 20px; border: 2px solid var(--border); border-radius: 12px; margin-bottom: 15px; cursor: pointer; transition: 0.2s; }
.pdf-option:hover { border-color: var(--accent); background: #f0f9ff; }
.pdf-option.selected { border-color: var(--accent); background: #e0f2fe; }
.pdf-option h4 { margin: 0 0 8px 0; color: var(--primary); }
.pdf-option p { margin: 0; font-size: 0.85rem; color: var(--text-muted); }

/* Utilitários */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media print {
    body * { visibility: hidden; }
    .pdf-page, .pdf-page * { visibility: visible; }
    .pdf-page { position: absolute; left: 0; top: 0; }
}

