@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Design Tokens ───────────────────────────────────────────── */
:root {
    --primary:            #006bb7;
    --primary-dark:       #004d85;
    --primary-light:      #e8f2fb;
    --primary-gradient:   linear-gradient(135deg, #006bb7 0%, #004d85 100%);
    --success:            #16a34a;
    --danger:             #dc2626;
    --warning:            #d97706;

    --bg:                 #f1f5f9;
    --surface:            #ffffff;
    --border:             #e2e8f0;
    --text:               #0f172a;
    --text-muted:         #64748b;
    --text-light:         #94a3b8;

    --radius-sm:          0.5rem;
    --radius:             0.75rem;
    --radius-lg:          1rem;
    --radius-xl:          1.25rem;

    --shadow-xs:          0 1px 2px rgba(0,0,0,.05);
    --shadow-sm:          0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow:             0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.06);
    --shadow-lg:          0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.06);

    --header-h:           56px;
    --content-max:        1280px;
    --transition:         0.2s ease;
}

/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ── Layout ──────────────────────────────────────────────────── */
.page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Topbar */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 1rem;
}

.top-bar-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 1rem;
    flex: 1;
}

.top-bar-brand .brand-icon {
    width: 36px;
    height: 36px;
    background: var(--primary-gradient);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* Content */
.content-wrapper {
    flex: 1;
    padding: 1.25rem 1rem;
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
}

@media (min-width: 640px) {
    .content-wrapper { padding: 1.5rem 1.5rem; }
    .top-bar { padding: 0 1.5rem; }
}

@media (min-width: 1024px) {
    .content-wrapper { padding: 2rem 2rem; }
    .top-bar { padding: 0 2rem; }
}

/* ── Cards ───────────────────────────────────────────────────── */
.card-surface {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.modern-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

@media (min-width: 640px) {
    .modern-card { padding: 1.5rem; }
}

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
    margin-bottom: 1.25rem;
}

.page-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 0.25rem;
    letter-spacing: -0.01em;
}

.page-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

@media (min-width: 640px) {
    .page-header h1 { font-size: 1.5rem; }
}

/* ── Search Bar ──────────────────────────────────────────────── */
.search-bar {
    position: relative;
}

.search-bar .search-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 0.85rem;
    pointer-events: none;
}

.search-bar input {
    width: 100%;
    height: 44px;
    padding: 0 1rem 0 2.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.search-bar input::placeholder { color: var(--text-light); }

.search-bar input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,107,183,.12);
}

/* ── Pagination Bar ──────────────────────────────────────────── */
.pagination-bar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.pagination-bar .page-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

.pagination-bar .page-controls {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

@media (min-width: 640px) {
    .pagination-bar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    .pagination-bar .page-info { text-align: left; }
    .pagination-bar .page-controls { justify-content: flex-end; }
}

/* ── Badges ──────────────────────────────────────────────────── */
.count-badge {
    display: inline-flex;
    align-items: center;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    white-space: nowrap;
}

/* ── Spinners & States ───────────────────────────────────────── */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    gap: 0.75rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ── Syncfusion Overrides ────────────────────────────────────── */
.e-btn, .e-css.e-btn {
    border-radius: var(--radius-sm) !important;
    text-transform: none !important;
    font-weight: 600 !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 0.875rem !important;
}

.e-primary {
    background: var(--primary-gradient) !important;
    border-color: transparent !important;
}

.e-primary:hover {
    background: linear-gradient(135deg, #0079ce 0%, #00578f 100%) !important;
}

/* Grid */
.e-grid .e-headercell {
    background: #f8fafc !important;
    color: var(--text-muted) !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
}

.e-grid .e-rowcell {
    font-size: 0.875rem !important;
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
}

.e-grid .e-row:hover .e-rowcell {
    background: var(--primary-light) !important;
}

/* Dialog */
.e-dialog {
    border-radius: var(--radius-xl) !important;
    box-shadow: var(--shadow-lg) !important;
    border: none !important;
}

.e-dialog .e-dlg-header-content {
    padding: 1.25rem 1.5rem !important;
    border-bottom: 1px solid var(--border) !important;
    background: var(--surface) !important;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0 !important;
}

.e-dialog .e-dlg-header {
    font-size: 1rem !important;
    font-weight: 700 !important;
    color: var(--text) !important;
}

.e-dialog .e-dlg-content {
    padding: 0 !important;
}

/* ── GerirFoto specifics ─────────────────────────────────────── */
.foto-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.25rem;
}

@media (min-width: 768px) {
    .foto-section {
        flex-direction: row;
        padding: 1.5rem;
    }
    .foto-section .foto-info { width: 220px; flex-shrink: 0; }
    .foto-section .foto-capture { flex: 1; }
}

.pessoa-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    display: block;
    margin-bottom: 0.25rem;
}

.pessoa-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    word-break: break-word;
}

.pessoa-id {
    font-size: 0.75rem;
    font-family: 'Courier New', monospace;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.375rem 0.625rem;
    color: var(--text-muted);
    display: block;
    word-break: break-all;
}

/* Photo preview */
.photo-preview-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.photo-box {
    position: relative;
    width: 180px;
    height: 240px;
    background: var(--bg);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: border-color var(--transition);
}

.photo-box.has-photo {
    border-style: solid;
    border-color: var(--primary);
}

.photo-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-light);
    text-align: center;
    padding: 1rem;
    font-size: 0.8rem;
}

@media (min-width: 640px) {
    .photo-box  { width: 210px; height: 280px; }
}

/* Capture buttons */
.capture-actions { display: grid; gap: 0.75rem; }

/* Label de upload estilizado como botão outline */
.btn-upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
    user-select: none;
}

.btn-upload-label:hover {
    background: var(--bg);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-upload-label.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    border-color: var(--border);
    color: var(--text-light);
}

/* Camera container */
.camera-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    max-height: 400px;
    background: #0f172a;
    border-radius: var(--radius);
    overflow: hidden;
}

#cameraVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.camera-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.face-frame {
    width: 55%;
    aspect-ratio: 3/4;
    border: 2px solid rgba(40,167,69,.4);
    border-radius: 1rem;
    position: relative;
    box-shadow: 0 0 0 2000px rgba(15,23,42,.65);
}

.corner {
    position: absolute;
    width: 28px;
    height: 28px;
    border: 3px solid #28a745;
}

.t-l { top: -2px; left: -2px; border-right: 0; border-bottom: 0; border-radius: 1rem 0 0 0; }
.t-r { top: -2px; right: -2px; border-left: 0; border-bottom: 0; border-radius: 0 1rem 0 0; }
.b-l { bottom: -2px; left: -2px; border-right: 0; border-top: 0; border-radius: 0 0 0 1rem; }
.b-r { bottom: -2px; right: -2px; border-left: 0; border-top: 0; border-radius: 0 0 1rem 0; }

.camera-hint {
    position: absolute;
    bottom: 1rem;
    width: 100%;
    text-align: center;
    pointer-events: none;
}

/* ── Alerts ──────────────────────────────────────────────────── */
.alert-inline {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.alert-inline.danger {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.alert-inline.success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.alert-inline .btn-close-sm {
    margin-left: auto;
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    padding: 0;
    line-height: 1;
    font-size: 1rem;
}

/* ── Blazor Error UI ─────────────────────────────────────────── */
#blazor-error-ui {
    background: #fef2f2;
    color: #991b1b;
    padding: 0.75rem 1.25rem;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 9999;
    display: none;
    border-top: 2px solid #fca5a5;
    font-size: 0.875rem;
}

#blazor-error-ui .reload {
    margin-left: 0.5rem;
    text-decoration: underline;
    font-weight: 600;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

/* ── Admin Login ──────────────────────────────────────────────── */
.login-container {
    min-height: 100vh;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-card {
    background: var(--surface);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header .brand-icon {
    width: 64px;
    height: 64px;
    background: var(--primary-gradient);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
    box-shadow: var(--shadow);
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.login-form .form-group {
    margin-bottom: 1.5rem;
}

.login-form label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.login-form .input-wrap {
    position: relative;
}

.login-form .input-wrap i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.login-form input {
    width: 100%;
    height: 48px;
    padding: 0 1rem 0 2.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
}

.login-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 107, 183, 0.1);
}

.btn-login {
    width: 100%;
    height: 48px;
    background: var(--primary-gradient);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
    filter: brightness(1.1);
}

/* ── Navigation ──────────────────────────────────────────────── */
.nav-link {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    padding: 0.5rem 0.25rem;
}

.nav-link:hover {
    color: var(--primary);
}

.btn-logout {
    color: var(--danger);
    font-size: 1rem;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-logout:hover {
    background: #fef2f2;
}

/* ── Histórico de Fotos ──────────────────────────────────────── */
.foto-historico {
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
}


.historico-item {
    transition: transform var(--transition), box-shadow var(--transition);
    cursor: default;
}

.historico-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
