/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --sidebar-w: 240px;
    --topbar-h: 56px;
    --color-primary: #0D4EA6;
    --color-primary-dark: #0C4089;
    --color-accent: #00A2FF;        /* Azul eléctrico: acción, enlaces, foco */
    --color-accent-hover: #00E0FF;  /* Cian: hover de la acción */
    --color-on-accent: #061833;     /* Azul profundo: texto sobre el acento */
    --color-sidebar-bg: #11233D;
    --color-sidebar-text: #AFB9C7;
    --color-sidebar-hover: #1a2b44;
    --color-topbar-bg: #11233D;
    --color-body-bg: #061833;
    --color-card-bg: #11233D;
    --color-border: #2a3a52;
    --color-text: #E6ECF3;
    --color-text-muted: #929EB0;
    --color-success: #22C55E;
    --color-danger: #EF4444;
    --color-warning: #F59E0B;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.2);
}

html, body {
    height: 100%;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-body-bg);
}

h1:focus { outline: none; }

/* ===== LAYOUT PRINCIPAL ===== */
.app-layout { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-w);
    background: var(--color-sidebar-bg);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 16px 20px 14px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.sidebar-logo-img { display: block; height: 34px; width: auto; }
.sidebar-logo-sub { color: var(--color-sidebar-text); font-size: 11px; }

.sidebar-nav { flex: 1; padding: 8px 0; }

.sidebar-section-label {
    color: var(--color-text-muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 16px 20px 6px;
}
.sidebar-section-label:first-child { padding-top: 8px; }

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 20px;
    color: var(--color-sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    transition: background .15s, color .15s;
}

.nav-item:hover { background: var(--color-sidebar-hover); color: #fff; }

.nav-item.active {
    background: rgba(29, 78, 216, 0.18);
    color: #00A2FF;
    border-left: 3px solid var(--color-accent);
    padding-left: 17px;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--color-border); }

.sidebar-user-badge { background: var(--color-sidebar-hover); border-radius: var(--radius); padding: 10px 12px; display: flex; align-items: center; gap: 10px; }

.user-avatar {
    width: 30px; height: 30px;
    background: var(--color-primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 12px; flex-shrink: 0;
}

.sidebar-user-info { overflow: hidden; }
.sidebar-user-name { color: var(--color-text); font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-email { color: var(--color-text-muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== TOPBAR ===== */
.topbar {
    position: fixed;
    top: 0; left: var(--sidebar-w); right: 0;
    height: var(--topbar-h);
    background: var(--color-topbar-bg);
    border-bottom: 1px solid var(--color-border);
    display: flex; align-items: center; justify-content: flex-end;
    padding: 0 24px;
    z-index: 90;
}

.topbar-logout {
    /* Ahora es un <button type="submit"> dentro de un <form> (POST + antiforgery,
       no un <a> a un GET que cambia estado) — se resetea el estilo por defecto del
       navegador para que siga pareciendo el mismo enlace de siempre. */
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 12.5px;
    padding: 6px 10px;
    border-radius: var(--radius);
    transition: background .15s, color .15s;
}
.topbar-logout:hover { background: var(--color-sidebar-hover); color: var(--color-danger); }

/* ===== CONTENIDO PRINCIPAL ===== */
.main-content {
    flex: 1; min-width: 0;
    margin-left: var(--sidebar-w);
    margin-top: var(--topbar-h);
    padding: 24px;
}

/* ===== CARDS ===== */
.card {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 24px;
    margin-bottom: 20px;
}

.card-title { font-size: 16px; font-weight: 600; color: var(--color-text); }
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.page-subtitle { font-size: 13px; color: var(--color-text-muted); margin-bottom: 20px; }

/* ===== BOTONES ===== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px;
    font-size: 13.5px; font-weight: 500;
    border-radius: 6px; border: none;
    cursor: pointer;
    transition: background .15s;
    text-decoration: none;
    line-height: 1.4;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--color-accent); color: var(--color-on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--color-accent-hover); }

.btn-secondary { background: var(--color-sidebar-hover); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover:not(:disabled) { background: var(--color-border); }

.btn-ghost { background: transparent; color: var(--color-text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--color-sidebar-hover); color: var(--color-text); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-icon { padding: 6px; }
.btn-icon.btn-danger-ghost:hover:not(:disabled) { background: rgba(239, 68, 68, .15); color: var(--color-danger); }

/* ===== FORMULARIOS ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--color-text); margin-bottom: 6px; }

.form-control {
    display: block; width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-body-bg);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    outline: none;
    transition: border-color .15s;
}
.form-control:focus { border-color: var(--color-accent); }
.form-control::placeholder { color: var(--color-text-muted); }

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%2364748B'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
    appearance: none;
}

/* ===== EDITOR DE TEXTO ENRIQUECIDO ===== */
.rte {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--color-bg-card, #11233D);
}

.rte-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--color-border);
}

.rte-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: #E6ECF3;
    font-size: 13px;
    cursor: pointer;
}

.rte-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--color-border);
}

.rte-sep {
    width: 1px;
    height: 20px;
    background: var(--color-border);
    margin: 0 4px;
}

.rte-content {
    min-height: 140px;
    max-height: 420px;
    overflow-y: auto;
    padding: 10px 12px;
    font-size: 14px;
    color: #E6ECF3;
    outline: none;
}

.rte-content:empty::before {
    content: attr(data-placeholder);
    color: #929EB0;
}

.rte-content p { margin: 0 0 8px; }
.rte-content ul, .rte-content ol { margin: 0 0 8px; padding-left: 24px; }

/* Solo lectura: mismo contenido HTML pero sin caja de editor (usado en CaseDetails). */
.html-content { font-size: 14px; color: #E6ECF3; }
.html-content p { margin: 0 0 8px; }
.html-content p:last-child { margin-bottom: 0; }
.html-content ul, .html-content ol { margin: 0 0 8px; padding-left: 24px; }

/* ===== TABLA ===== */
.table-wrapper { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.data-table thead tr { border-bottom: 2px solid var(--color-border); }
.data-table th {
    padding: 10px 14px; text-align: left;
    font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    color: var(--color-text-muted); white-space: nowrap;
}
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--color-border); color: var(--color-text); }
.data-table tbody tr:hover { background: var(--color-sidebar-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table a { color: #00A2FF; text-decoration: none; }
.data-table a:hover { text-decoration: underline; }

/* ===== BADGES ===== */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; }
.badge-success { background: rgba(34,197,94,.15); color: #4ADE80; }
.badge-warning { background: rgba(245,158,11,.15); color: #FBBF24; }
.badge-danger  { background: rgba(239,68,68,.15); color: #F87171; }

/* ===== ALERTAS ===== */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 13.5px; margin-bottom: 16px; }
.alert-danger  { background: rgba(239,68,68,.12); color: #F87171; border: 1px solid rgba(239,68,68,.3); }
.alert-info    { background: rgba(0,162,255,.12); color: #00A2FF; border: 1px solid rgba(0,162,255,.3); }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 20px;
}
.modal {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
    width: 100%; max-width: 460px;
    max-height: 90vh; overflow-y: auto;
}
.modal-header { padding: 18px 24px; border-bottom: 1px solid var(--color-border); font-size: 16px; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: 10px; }

/* ===== SPINNER ===== */
.spinner {
    width: 20px; height: 20px;
    border: 2px solid rgba(255,255,255,.15);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== BARRA DE ACCIONES DE FORMULARIO ===== */
/* Botones agrupados y alineados a la derecha, fuera de .card. Orden: Aceptar (btn-primary)
   a la izquierda del grupo, Cancelar (btn-secondary) a la derecha. */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

/* ===== UTILIDADES ===== */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.justify-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-3 { margin-top: 12px; }
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: 12px; }
.w-full { width: 100%; }

/* ===== LOGIN ===== */
.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: var(--color-body-bg);
    padding: 20px;
}
.login-card {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 32px 36px;
    width: 100%; max-width: 380px;
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo-img { display: block; height: 52px; width: auto; margin: 0 auto 10px; }
.login-logo-sub { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }

/* ===== BLAZOR ERROR UI ===== */
#blazor-error-ui {
    background: #450A0A; color: #F87171;
    bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.4);
    display: none; left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
