/* ============================================================
   SISTEMA DE PRESENÇAS — Estilos Globais
   ============================================================ */

:root {
  --primary:     #2563eb;
  --primary-dk:  #1d4ed8;
  --secondary:   #64748b;
  --success:     #16a34a;
  --danger:      #dc2626;
  --warning:     #d97706;
  --info:        #0891b2;
  --bg:          #f1f5f9;
  --sidebar-bg:  #1e293b;
  --sidebar-text:#94a3b8;
  --sidebar-act: #ffffff;
  --card-bg:     #ffffff;
  --border:      #e2e8f0;
  --text:        #1e293b;
  --text-muted:  #64748b;
  --radius:      10px;
  --shadow:      0 1px 6px rgba(0,0,0,.08);
  --sidebar-w:   240px;
  --topbar-h:    60px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; }
button { cursor: pointer; }

/* ---- Utilities ---- */
.text-center  { text-align: center; }
.text-muted   { color: var(--text-muted); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.mt-1 { margin-top: .25rem; } .mt-2 { margin-top: .5rem; } .mt-3 { margin-top: 1rem; }
.mb-1 { margin-bottom: .25rem; } .mb-2 { margin-bottom: .5rem; } .mb-3 { margin-bottom: 1rem; }
.ms-auto { margin-left: auto; }
.d-flex { display: flex; } .align-center { align-items: center; } .gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; }
.fw-bold { font-weight: 700; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: .72rem; font-weight: 600; }
.badge-success { background: #dcfce7; color: var(--success); }
.badge-warning { background: #fef9c3; color: var(--warning); }
.badge-info    { background: #e0f2fe; color: var(--info); }
.badge-danger  { background: #fee2e2; color: var(--danger); }
.badge-secondary { background: #f1f5f9; color: var(--secondary); }

/* ---- Forms ---- */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .35rem; color: var(--secondary); }
.form-control {
  width: 100%; padding: .55rem .8rem; border: 1.5px solid var(--border); border-radius: 7px;
  font-size: .9rem; color: var(--text); background: #fff; transition: border .2s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%2364748b' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; padding-right: 2rem; }
textarea.form-control { min-height: 120px; resize: vertical; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem 1.1rem; border-radius: 7px; border: none; font-size: .88rem; font-weight: 600;
  transition: all .18s; white-space: nowrap;
}
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-dk); }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.9); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover  { filter: brightness(.9); }
.btn-warning  { background: var(--warning); color: #fff; }
.btn-warning:hover { filter: brightness(.9); }
.btn-secondary{ background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-info     { background: var(--info); color: #fff; }
.btn-info:hover { filter: brightness(.9); }
.btn-sm       { padding: .3rem .7rem; font-size: .78rem; }
.btn-block    { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-icon     { padding: .3rem .5rem; background: transparent; border: 1px solid var(--border); border-radius: 6px; font-size: .85rem; }
.btn-icon:hover { background: var(--bg); }

/* ---- Alerts ---- */
.alert { padding: .7rem 1rem; border-radius: 7px; font-size: .88rem; margin-bottom: .75rem; }
.alert-danger  { background: #fee2e2; color: #7f1d1d; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #14532d; border: 1px solid #86efac; }
.alert-info    { background: #e0f2fe; color: #0c4a6e; border: 1px solid #7dd3fc; }
.alert-warning { background: #fef9c3; color: #713f12; border: 1px solid #fde047; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data-table th { background: var(--bg); padding: .65rem .9rem; text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); border-bottom: 2px solid var(--border); }
table.data-table td { padding: .65rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tr:hover td { background: #f8fafc; }
table.data-table .actions { display: flex; gap: .4rem; }

/* ---- Cards ---- */
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.card-header { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; padding-bottom: .75rem; border-bottom: 1px solid var(--border); }
.card-header h3 { font-size: 1rem; font-weight: 700; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--card-bg); border-radius: var(--radius); padding: 1rem 1.25rem; display: flex; align-items: center; gap: 1rem; box-shadow: var(--shadow); }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.stat-icon.blue   { background: #dbeafe; color: var(--primary); }
.stat-icon.green  { background: #dcfce7; color: var(--success); }
.stat-icon.orange { background: #fef3c7; color: var(--warning); }
.stat-icon.teal   { background: #ccfbf1; color: #0d9488; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .75rem; color: var(--text-muted); font-weight: 500; }

/* ---- Login ---- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%); }
.login-wrapper { width: 100%; max-width: 400px; padding: 1rem; }
.login-card { background: #fff; border-radius: 14px; padding: 2.5rem 2rem; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo i { font-size: 2.5rem; color: var(--primary); }
.login-logo h1 { font-size: 1.4rem; font-weight: 800; margin-top: .5rem; color: var(--text); }
.login-logo p  { color: var(--text-muted); font-size: .85rem; }

/* ---- Sidebar ---- */
.sidebar {
  position: fixed; top: 0; left: 0; width: var(--sidebar-w); height: 100vh;
  background: var(--sidebar-bg); display: flex; flex-direction: column; z-index: 100;
  transition: transform .25s;
}
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1.2rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand i { font-size: 1.3rem; color: var(--primary); }
.sidebar-brand span { font-size: 1rem; font-weight: 700; color: #fff; }
.sidebar-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.2rem; color: var(--sidebar-text); font-size: .88rem; font-weight: 500; transition: all .15s; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(37,99,235,.35); color: var(--sidebar-act); border-left: 3px solid var(--primary); }
.nav-item i { width: 18px; text-align: center; }
.sidebar-footer { padding: .9rem 1.2rem; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: .5rem; }
.sidebar-footer span { flex: 1; font-size: .82rem; color: var(--sidebar-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer button { background: transparent; border: none; color: var(--sidebar-text); font-size: 1rem; padding: .3rem; border-radius: 5px; transition: color .15s; }
.sidebar-footer button:hover { color: var(--danger); }

/* ---- Topbar ---- */
.topbar { height: var(--topbar-h); background: var(--card-bg); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem; position: sticky; top: 0; z-index: 50; }
.topbar-toggle { background: transparent; border: none; font-size: 1.1rem; color: var(--secondary); padding: .3rem; display: none; }
.topbar h2 { font-size: 1.05rem; font-weight: 700; }
.topbar-actions { margin-left: auto; display: flex; gap: .5rem; align-items: center; }

/* ---- Main Layout ---- */
.main-content { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.content-area { padding: 1.5rem; flex: 1; }

/* ---- Section toolbar ---- */
.section-toolbar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.section-toolbar .search-box { position: relative; flex: 1; min-width: 200px; }
.section-toolbar .search-box i { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: .85rem; }
.section-toolbar .search-box input { padding-left: 2rem; width: 100%; }
.section-filter { min-width: 180px; }

/* ---- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal-box { background: #fff; border-radius: var(--radius); width: 100%; max-width: 580px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-box.modal-lg { max-width: 720px; }
.modal-box.modal-xl { max-width: 900px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close { background: transparent; border: none; font-size: 1.1rem; color: var(--text-muted); padding: .2rem .4rem; border-radius: 5px; }
.modal-close:hover { background: var(--bg); color: var(--danger); }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .5rem; }

/* ---- QR Modal ---- */
.qr-modal-box { max-width: 440px; }
#qrCodeDisplay { display: flex; justify-content: center; padding: 1rem; }
#qrCodeDisplay canvas, #qrCodeDisplay img { border: 3px solid var(--primary); border-radius: 10px; }
.qr-stats { background: var(--bg); border-radius: 8px; padding: .75rem 1rem; }
.qr-stats-row { display: flex; justify-content: space-between; font-size: .88rem; }

/* ---- Loading ---- */
.loading-spinner { display: flex; align-items: center; justify-content: center; gap: .6rem; padding: 3rem; color: var(--text-muted); font-size: 1rem; }

/* ---- Empty state ---- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; margin-bottom: .75rem; opacity: .4; }
.empty-state p { font-size: .9rem; }

/* ---- Toast ---- */
#toastContainer { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; max-width: 340px; }
.toast { background: #1e293b; color: #fff; padding: .75rem 1rem; border-radius: 8px; font-size: .88rem; box-shadow: 0 4px 12px rgba(0,0,0,.25); display: flex; align-items: center; gap: .6rem; animation: slideIn .25s ease; }
.toast.toast-success { background: var(--success); }
.toast.toast-danger  { background: var(--danger); }
.toast.toast-warning { background: var(--warning); }
.toast.toast-info    { background: var(--info); }
@keyframes slideIn { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---- Meeting detail ---- */
.meeting-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.detail-item { padding: .75rem; background: var(--bg); border-radius: 7px; }
.detail-item .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 600; margin-bottom: .25rem; }
.detail-item .value { font-size: .95rem; font-weight: 600; }

/* ---- Presence page ---- */
.presence-page { background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 60%, #0891b2 100%); min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 1rem; }
.presence-container { width: 100%; max-width: 460px; padding-top: 1rem; }
.presence-header { text-align: center; color: #fff; padding: 1.5rem 0 1rem; }
.presence-icon { font-size: 3rem; margin-bottom: .5rem; }
.presence-header h1 { font-size: 1.5rem; font-weight: 800; }
.presence-card { background: #fff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25); overflow: hidden; }
.presence-info { padding: 1.25rem; border-bottom: 1px solid var(--border); }
.presence-name { font-size: 1.05rem; margin-bottom: .4rem; }
.presence-meeting, .presence-date { font-size: .88rem; color: var(--text-muted); display: flex; align-items: center; gap: .5rem; margin-top: .25rem; }
.scan-instructions { padding: 1rem 1.25rem; background: #f0f9ff; color: #0c4a6e; font-size: .88rem; line-height: 1.5; }
.scanner-container { position: relative; width: 100%; background: #000; }
#scannerWrapper { position: relative; }
#qrVideo { width: 100%; display: block; max-height: 300px; object-fit: cover; }
.scanner-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.scanner-frame { width: 200px; height: 200px; border: 3px solid rgba(255,255,255,.8); border-radius: 12px; box-shadow: 0 0 0 1000px rgba(0,0,0,.35); }
.scanner-error { padding: 2rem; text-align: center; background: #1e293b; color: #cbd5e1; }
.scanner-error i { font-size: 2rem; margin-bottom: .5rem; }
.scan-status { padding: .5rem 1.25rem; text-align: center; min-height: 36px; font-size: .88rem; }
.scanner-divider { display: flex; align-items: center; gap: .75rem; padding: .75rem 1.25rem; color: var(--text-muted); font-size: .8rem; }
.scanner-divider::before, .scanner-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.manual-section { padding: 0 1.25rem 1.25rem; }
.manual-input-row { display: flex; gap: .5rem; margin-top: .5rem; }
.manual-input-row input { flex: 1; }
.presence-confirmed { padding: 2.5rem 1.5rem; text-align: center; }
.presence-confirmed i { font-size: 3.5rem; color: var(--success); margin-bottom: 1rem; }
.presence-confirmed h2 { font-size: 1.3rem; margin-bottom: .5rem; color: var(--success); }
.presence-error { padding: 2rem 1.5rem; text-align: center; }
.presence-error i { font-size: 2.5rem; color: var(--warning); margin-bottom: .75rem; }
.success-anim { animation: popIn .4s cubic-bezier(.68,-.55,.27,1.55); }
@keyframes popIn { 0% { transform: scale(0); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.presence-header-html { padding: 1rem; }

/* ---- Attendance list ---- */
.attendance-confirmed { color: var(--success); font-weight: 600; font-size: .82rem; }
.attendance-pending   { color: var(--text-muted); font-size: .82rem; }

/* ---- Progress bar ---- */
.progress-bar-wrap { background: var(--bg); border-radius: 20px; height: 8px; overflow: hidden; flex: 1; }
.progress-bar-fill { height: 100%; background: var(--primary); border-radius: 20px; transition: width .4s; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar-toggle { display: block; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .meeting-detail-grid { grid-template-columns: 1fr; }
  .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; display: none; }
  .sidebar-overlay.show { display: block; }
}
