/* ============================================================================
   Donify Admin — estilos del portal administrativo.
   Base: Bootstrap 5 (ya incluido en la plantilla, licencia MIT) + tokens propios.
   ============================================================================ */

:root {
    --admin-sidebar-width: 240px;
    --admin-sidebar-width-collapsed: 64px;
    --admin-sidebar-bg: #14213d;
    --admin-sidebar-color: #cbd5e1;
    --admin-sidebar-active: #fca311;
    --admin-topbar-height: 56px;
    --admin-bg: #f4f6fa;
    --admin-primary: #14213d;
    --admin-accent: #fca311;
}

html, body {
    font-family: 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: var(--admin-bg);
}

h1:focus {
    outline: none;
}

/* ---- Shell -------------------------------------------------------------- */

.admin-shell {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: var(--admin-sidebar-width);
    background-color: var(--admin-sidebar-bg);
    color: var(--admin-sidebar-color);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    transition: width 0.15s ease-in-out;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-collapsed .admin-sidebar {
    width: var(--admin-sidebar-width-collapsed);
}

.admin-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.admin-topbar {
    height: var(--admin-topbar-height);
    background-color: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 0.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.admin-topbar-toggle {
    text-decoration: none;
    font-size: 1.2rem;
    color: var(--admin-primary);
}

.admin-topbar-spacer {
    flex-grow: 1;
}

.admin-content {
    padding: 1.25rem;
    max-width: 1400px;
    width: 100%;
}

/* ---- Sidebar brand & nav ------------------------------------------------ */

.admin-brand {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-brand-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
}

.admin-brand-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background-color: var(--admin-accent);
    color: var(--admin-primary);
    font-weight: 700;
    flex-shrink: 0;
}

.admin-nav {
    padding: 0.75rem 0.5rem;
}

.admin-nav-section {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    padding: 0.75rem 0.6rem 0.25rem;
}

.admin-nav-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--admin-sidebar-color);
    text-decoration: none;
    padding: 0.5rem 0.6rem;
    border-radius: 8px;
    margin-bottom: 2px;
    white-space: nowrap;
}

.admin-nav-link:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.admin-nav-link.active {
    background-color: rgba(252, 163, 17, 0.18);
    color: var(--admin-accent);
    font-weight: 600;
}

.admin-nav-icon {
    width: 1.4rem;
    text-align: center;
    flex-shrink: 0;
}

/* ---- User menu ---------------------------------------------------------- */

.admin-user-menu {
    position: relative;
}

.admin-user-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--admin-primary);
}

.admin-user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--admin-primary);
    color: #fff;
    font-weight: 600;
}

.admin-user-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
    min-width: 220px;
    z-index: 1000;
}

.admin-user-dropdown-email {
    font-size: 0.85rem;
    color: #475569;
    word-break: break-all;
}

.admin-logout-button {
    padding: 0;
    color: #dc3545;
    text-decoration: none;
}

/* ---- Page pieces -------------------------------------------------------- */

.admin-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.admin-page-title {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 0;
    color: var(--admin-primary);
}

.admin-breadcrumb {
    margin-bottom: 0.15rem;
    font-size: 0.8rem;
}

.admin-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
}

.admin-card-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 0.5rem;
}

.admin-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.admin-stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--admin-primary);
}

.admin-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.admin-search-input {
    max-width: 320px;
}

.admin-date-input {
    max-width: 170px;
}

.admin-table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #64748b;
    white-space: nowrap;
    user-select: none;
}

.admin-row-inactive {
    opacity: 0.6;
}

.admin-row-clickable {
    cursor: pointer;
}

.admin-cell-truncate {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-translations-button {
    text-decoration: none;
    display: inline-flex;
    gap: 0.3rem;
}

.admin-lang-chip {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    color: #64748b;
    background: #f8fafc;
}

.admin-lang-chip-on {
    border-color: #198754;
    color: #198754;
    background: #eaf6f0;
}

.admin-translation-row {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
    margin-bottom: 0.75rem;
}

.admin-activity-list {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.admin-activity-action {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--admin-primary);
}

/* ---- Loading / empty states --------------------------------------------- */

.admin-loading {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #475569;
    padding: 2rem 0;
    justify-content: center;
}

.admin-empty-state {
    padding: 2.5rem 1rem;
}

.admin-empty-state-icon,
.admin-access-denied-icon {
    font-size: 2.4rem;
    margin-bottom: 0.5rem;
}

.admin-access-denied {
    padding: 3rem 1rem;
}

/* ---- Modals ------------------------------------------------------------- */

.admin-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 1040;
}

.admin-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 4rem 1rem 1rem;
    z-index: 1050;
    pointer-events: none;
}

.admin-modal-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.25rem 1.4rem;
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
    /* .admin-modal (the flex container positioned over the whole screen) disables pointer-events so
       clicks in its empty padding fall through to the backdrop underneath and close the modal.
       pointer-events is inherited, so without this override every click inside the card — including
       on inputs and buttons — also fell through to the backdrop and closed the modal instantly. */
    pointer-events: auto;
}

.admin-modal-card-wide {
    max-width: 860px;
}

.admin-audit-json {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 8px;
    padding: 0.75rem;
    font-size: 0.78rem;
    max-height: 320px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    pointer-events: auto;
}

/* ---- Toasts ------------------------------------------------------------- */

.admin-toast-container {
    position: fixed;
    top: calc(var(--admin-topbar-height) + 10px);
    right: 14px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 360px;
}

.admin-toast {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: #fff;
    border-left: 4px solid #64748b;
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    font-size: 0.9rem;
}

.admin-toast-success { border-left-color: #198754; }
.admin-toast-info    { border-left-color: #0d6efd; }
.admin-toast-warning { border-left-color: #ffc107; }
.admin-toast-error   { border-left-color: #dc3545; }

/* ---- Auth pages --------------------------------------------------------- */

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--admin-primary) 0%, #1f2f56 60%, #2b3f6e 100%);
    padding: 1rem;
}

.auth-card {
    background: #fff;
    border-radius: 14px;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
    font-weight: 700;
    color: var(--admin-primary);
    font-size: 1.1rem;
}

/* ---- Forms / validation (plantilla) ------------------------------------- */

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
    font-size: 0.85rem;
}

/* ---- Responsive --------------------------------------------------------- */

/* Mobile off-canvas visibility is a SEPARATE concept from the desktop collapse toggle
   (.sidebar-collapsed, which just narrows the sidebar to icon-only — it stays visible either way).
   On mobile the sidebar must default to HIDDEN: it previously defaulted to shown (only .sidebar-collapsed
   hid it), so on first load on a phone the sidebar covered the whole screen and, because it's
   position:fixed and taken out of flow, the hamburger button underneath it became unreachable —
   there was no way to close it. .mobile-menu-open (driven by its own state, not .sidebar-collapsed)
   controls visibility here instead. */
.admin-sidebar-backdrop {
    display: none;
}

@media (max-width: 767.98px) {
    .admin-sidebar {
        position: fixed;
        z-index: 1030;
        height: 100vh;
        width: var(--admin-sidebar-width);
        transform: translateX(-100%);
        transition: transform 0.15s ease-in-out;
    }

    .mobile-menu-open .admin-sidebar {
        transform: translateX(0);
    }

    .admin-main {
        width: 100%;
    }

    .admin-content {
        padding: 0.9rem;
    }

    .mobile-menu-open .admin-sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1025;
        background: rgba(15, 23, 42, 0.5);
    }
}

/* ---- Blazor error UI (plantilla) ---------------------------------------- */

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 2000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
    border-radius: 8px;
}

.blazor-error-boundary::after {
    content: "Ocurrió un error en este componente.";
}
