/* ── Google Font: Inter ──────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --c1:  #001D39;
    --c2:  #0A4174;
    --c3:  #49769F;
    --c4:  #4E8EA2;
    --c5:  #6EA2B3;
    --c6:  #7BBDE8;
    --c7:  #BDD8E9;

    --primary:        var(--c3);
    --primary-dark:   var(--c2);
    --primary-deep:   var(--c1);

    --bg:      #EEF5FA;
    --bg-card: #FFFFFF;
    --border:  #C4D9E8;
    --text-dark:   #0D2137;
    --text-medium: #3A5570;
    --text-light:  #7090A8;

    --radius: 10px;
    --shadow: 0 1px 6px rgba(0, 29, 57, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 29, 57, 0.12);

    --font: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

/* ── Base ────────────────────────────────────── */
html {
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    font-weight: 400;
    line-height: 1.6;
    background-color: var(--bg);
    color: var(--text-dark);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5 {
    font-family: var(--font);
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.015em;
    color: var(--c1);
    margin-bottom: 0.5rem;
}

h1:focus { outline: none; }

p { margin-bottom: 0.75rem; }

a, .btn-link { color: var(--c3); text-decoration: none; }
a:hover { color: var(--c2); text-decoration: underline; }

small, .small { font-size: 0.8rem; }

/* ── Page header ─────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--c1);
    letter-spacing: -0.02em;
    margin: 0;
}

/* ── Buttons ─────────────────────────────────── */
.btn {
    font-family: var(--font);
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: 8px;
    letter-spacing: 0.01em;
    transition: background-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.btn-sm { font-size: 0.8rem; padding: 0.28rem 0.7rem; }

.btn-primary {
    color: #fff;
    background-color: var(--c2);
    border-color: var(--c2);
}
.btn-primary:hover, .btn-primary:focus {
    background-color: var(--c1);
    border-color: var(--c1);
    box-shadow: 0 2px 8px rgba(0,29,57,0.25);
    color: #fff;
}
.btn-primary:active { transform: scale(0.97); }

.btn-outline-primary  { color: var(--c2); border-color: var(--c3); border-radius: 8px; }
.btn-outline-primary:hover  { background-color: var(--c2); border-color: var(--c2); color: #fff; }
.btn-outline-secondary { border-radius: 8px; }
.btn-outline-info      { border-radius: 8px; }
.btn-outline-success   { border-radius: 8px; }
.btn-outline-danger    { border-radius: 8px; }

.btn:focus, .btn:active:focus,
.form-control:focus, .form-select:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(73, 118, 159, 0.22);
    outline: none;
}

/* ── Cards ───────────────────────────────────── */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    background-color: var(--bg-card);
}

.card-header {
    background-color: #F2F8FC;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0 !important;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--c1);
    padding: 0.85rem 1.25rem;
    letter-spacing: -0.01em;
}

.card-body { padding: 1.25rem; }

/* ── Form controls ───────────────────────────── */
.form-label {
    font-family: var(--font);
    font-weight: 500;
    font-size: 0.8125rem;
    color: var(--text-medium);
    margin-bottom: 0.3rem;
    display: block;
}

.form-control, .form-select {
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-dark);
    background-color: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.45rem 0.75rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    line-height: 1.5;
}

.form-control:focus, .form-select:focus {
    border-color: var(--c5);
    background-color: #fff;
}

.form-control::placeholder {
    color: #A8C4D4;
    font-weight: 300;
}

.form-control:disabled, .form-select:disabled {
    background-color: #F4F8FB;
    color: var(--text-light);
    border-color: #D8E8F0;
}

/* Validação: só mostra erro após o usuário sair do campo */
.form-control:user-invalid,
.form-select:user-invalid {
    border-color: #E07070;
    background-image: none;
}

.form-control:user-valid,
.form-select:user-valid {
    border-color: #6BC48A;
    background-image: none;
}

/* Fallback para navegadores sem :user-invalid */
.form-control.input-error { border-color: #E07070; }
.form-control.input-ok    { border-color: #6BC48A; }

.form-text {
    font-size: 0.775rem;
    color: var(--text-light);
    margin-top: 0.2rem;
}

.text-danger { color: #C0392B !important; }

/* Blazor validation */
.valid.modified:not([type=checkbox]) { border-color: #6BC48A; }
.invalid { border-color: #E07070; }
.validation-message { color: #C0392B; font-size: 0.78rem; margin-top: 0.2rem; }

/* ── Tables ──────────────────────────────────── */
.table {
    font-size: 0.875rem;
    color: var(--text-dark);
}

.table thead th {
    background-color: #F2F8FC;
    color: var(--c2);
    border-bottom: 2px solid var(--c7);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    white-space: nowrap;
    padding: 0.65rem 0.85rem;
}

.table td, .table th { vertical-align: middle; padding: 0.6rem 0.85rem; }
.table-hover tbody tr:hover { background-color: #EBF4FA; }

.action-cell { white-space: nowrap; }
.action-cell .btn + .btn { margin-left: 0.25rem; }

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 576px) {
    .table {
        font-size: 0.8rem;
    }
    .table thead th, .table td {
        padding: 0.5rem 0.6rem;
    }
    .btn-sm {
        padding: 0.2rem 0.4rem;
    }
    .btn-sm svg {
        width: 12px;
        height: 12px;
    }
}

/* ── Stat cards (Dashboard) ──────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 0.875rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    border-radius: var(--radius);
    padding: 1.1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    box-shadow: var(--shadow);
    border: 1px solid transparent;
    transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card[style*="cursor:pointer"]:hover,
.stat-card[style*="cursor: pointer"]:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    opacity: 0.65;
}

.stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
}

.stat-primary     { background: #EAF3FA; color: var(--c1); border-color: var(--c7); }
.stat-neutral     { background: #F4F6F8; color: #2D3748; border-color: #DCE4EC; }
.stat-danger      { background: #FDF3F3; color: #8B2020; border-left: 3px solid #E07070; }
.stat-warning-red { background: #FDF6F0; color: #8B4513; border-left: 3px solid #E8944A; }
.stat-warning     { background: #FDFBEE; color: #6B5800; border-left: 3px solid #D4B800; }
.stat-purple      { background: #F8F4FF; color: #4A3080; border-left: 3px solid #9B7AE0; }
.stat-blue        { background: #EBF4FA; color: var(--c2); border-left: 3px solid var(--c6); }
.stat-yellow      { background: #FDFBEE; color: #6B5800; border-left: 3px solid #E8D44A; }
.stat-green       { background: #F0FBF4; color: #1E5C35; border-left: 3px solid #5BC47A; }
.stat-pink        { background: #FDF4F7; color: #7A2050; border-left: 3px solid #E07AAA; }

/* ── Global dashboard badge counts ──────────── */
.badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.6rem;
    height: 1.5rem;
    padding: 0 0.4rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
}
.badge-urgent  { background:#FDF3F3; color:#8B2020; border:1px solid #E8B4B4; }
.badge-warning { background:#FDFBEE; color:#6B5800; border:1px solid #E8D44A; }
.badge-stale   { background:#F8F4FF; color:#4A3080; border:1px solid #9B7AE0; }
.badge-disc    { background:#EBF4FA; color:var(--c2); border:1px solid var(--c6); }

.table-row-alert { background-color: #FFFBFB !important; }
.table-row-alert:hover { background-color: #FDF3F3 !important; }

/* ── Visit history ───────────────────────────── */
.history-row td { background-color: #F5FAFD !important; }

.visit-history-card {
    padding: 0.85rem 1rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-medium);
}

/* ── Alert / feedback ────────────────────────── */
.alert {
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 400;
    border-radius: 8px;
    padding: 0.65rem 1rem;
    line-height: 1.5;
}

.alert-success { background: #EEF9F3; color: #1A5C35; border: 1px solid #A8DDB8; }
.alert-danger  { background: #FDF3F3; color: #8B2020; border: 1px solid #E8B4B4; }
.alert-info    { background: #EAF3FA; color: var(--c1); border: 1px solid var(--c7); }

/* ── Filter badge ────────────────────────────── */
.filter-badge {
    display: inline-flex;
    align-items: center;
    background: #EAF3FA;
    border: 1px solid var(--c7);
    border-radius: 20px;
    padding: 0.28rem 0.85rem;
    font-size: 0.8rem;
    color: var(--c2);
    font-weight: 400;
}

/* ── Empty state ─────────────────────────────── */
.empty-state {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--text-light);
    font-size: 0.875rem;
}

.empty-state-full {
    padding: 5rem 2rem;
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* ── Content ─────────────────────────────────── */
.content { padding-top: 1.5rem; }

/* ── Login page ──────────────────────────────── */
.login-bg {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #001D39 0%, #0A4174 60%, #49769F 100%);
    padding: 1.5rem;
}

.login-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 380px;
    gap: 1.75rem;
}

.login-logo-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.login-svg {
    width: 130px;
    height: auto;
    filter: drop-shadow(0 4px 24px rgba(123,189,232,0.35));
}

.login-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.02em;
    margin: 0;
    text-align: center;
}

.login-ic-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 0.25rem;
}

.login-ic-logo {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    object-fit: contain;
    opacity: 0.85;
}

.login-subtitle {
    font-size: 0.8rem;
    font-weight: 500;
    color: rgba(189, 216, 233, 0.70);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin: 0;
}

.login-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 2rem;
    width: 100%;
    box-shadow: 0 8px 40px rgba(0, 29, 57, 0.40);
}

.login-card .form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-medium);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.login-card .form-control-lg {
    font-size: 0.95rem;
    border-radius: 10px;
    border-color: var(--border);
    padding: 0.65rem 0.9rem;
}

.login-card .btn-primary {
    border-radius: 10px;
    font-size: 0.95rem;
    padding: 0.7rem;
    letter-spacing: 0.02em;
}

/* ── Top bar logout ──────────────────────────── */
.top-row-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-medium);
}

.top-row-user .user-name {
    font-weight: 600;
    color: var(--c2);
}

.top-row-user .user-role {
    font-size: 0.72rem;
    color: var(--text-light);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.1rem 0.55rem;
}

.btn-logout {
    font-size: 0.78rem;
    color: var(--text-light);
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.25rem 0.65rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.btn-logout:hover {
    background: #FDF3F3;
    color: #8B2020;
    border-color: #E8B4B4;
}

/* ── Blazor error UI ─────────────────────────── */
#blazor-error-ui {
    font-family: var(--font);
    background: #FEFBEC;
    border-top: 2px solid #E8C84A;
    bottom: 0; left: 0;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
    display: none;
    padding: 0.65rem 1.25rem 0.75rem;
    position: fixed;
    width: 100%; z-index: 1000;
    color: #6B5000; font-size: 0.875rem;
}

#blazor-error-ui .dismiss {
    cursor: pointer; position: absolute;
    right: 0.75rem; top: 0.5rem; opacity: 0.5;
}

#blazor-error-ui .dismiss:hover { opacity: 1; }

.blazor-error-boundary {
    background-color: #FDF3F3;
    padding: 1rem 1rem 1rem 1.5rem;
    color: #8B2020;
    border-radius: var(--radius);
    border-left: 4px solid #E07070;
    font-size: 0.875rem;
}

.blazor-error-boundary::after { content: "Ocorreu um erro inesperado."; }

/* ── Loading ─────────────────────────────────── */
.loading-progress {
    position: relative;
    display: block;
    width: 5rem; height: 5rem;
    margin: 20vh auto 1.5rem;
}

.loading-progress circle {
    fill: none;
    stroke: var(--c7);
    stroke-width: 0.45rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--c3);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-family: var(--font);
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--c3);
    inset: calc(20vh + 2rem) 0 auto 0.2rem;
}

.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Carregando..."); }

code { color: #B83280; font-size: 0.875em; }
