/* Panel admin — layout + tema (Bootstrap como base) */
:root {
    --cms-body-bg: #f5f5f4;
    --cms-body-color: #000000;
    --cms-border: #c8c8c7;
    --cms-sidebar-width: 280px;
    --cms-topbar-height: 56px;
    --cms-sidebar-surface: #141414;
    --cms-sidebar-border: rgba(255, 255, 255, 0.06);
    --bs-primary: #302c67;
    --bs-primary-rgb: 48, 44, 103;
}

/* Botón primario */
.btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: #302c67;
    --bs-btn-border-color: #302c67;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #302c67;
    --bs-btn-hover-border-color: #302c67;
    --bs-btn-focus-shadow-rgb: 48, 44, 103;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #302c67;
    --bs-btn-active-border-color: #302c67;
    --bs-btn-active-shadow: none;
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: #302c67;
    --bs-btn-disabled-border-color: #302c67;
}

/* Cancelar / volver: fondo blanco, borde y texto marca */
.btn-secondary {
    --bs-btn-color: #302c67;
    --bs-btn-bg: #ffffff;
    --bs-btn-border-color: #302c67;
    --bs-btn-hover-color: #302c67;
    --bs-btn-hover-bg: #ffffff;
    --bs-btn-hover-border-color: #302c67;
    --bs-btn-active-color: #302c67;
    --bs-btn-active-bg: #ffffff;
    --bs-btn-active-border-color: #302c67;
    --bs-btn-active-shadow: none;
    --bs-btn-focus-shadow-rgb: 48, 44, 103;
}

.btn-danger {
    --bs-btn-hover-bg: var(--bs-btn-bg);
    --bs-btn-hover-border-color: var(--bs-btn-border-color);
    --bs-btn-hover-color: var(--bs-btn-color);
    --bs-btn-active-bg: var(--bs-btn-bg);
    --bs-btn-active-border-color: var(--bs-btn-border-color);
    --bs-btn-active-color: var(--bs-btn-color);
    --bs-btn-active-shadow: none;
}

.btn-dark {
    --bs-btn-hover-bg: var(--bs-btn-bg);
    --bs-btn-hover-border-color: var(--bs-btn-border-color);
    --bs-btn-hover-color: var(--bs-btn-color);
    --bs-btn-active-bg: var(--bs-btn-bg);
    --bs-btn-active-border-color: var(--bs-btn-border-color);
    --bs-btn-active-color: var(--bs-btn-color);
    --bs-btn-active-shadow: none;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body.app-body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--cms-body-bg);
    color: var(--cms-body-color);
    font-family: var(--font-sans, system-ui, -apple-system, 'Segoe UI', sans-serif);
}

.app-shell {
    display: flex;
    flex-direction: row;
    min-height: 100vh;
}

.app-main-wrap {
    flex: 1;
    order: 2;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-sidebar {
    order: 1;
    width: var(--cms-sidebar-width);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--cms-sidebar-surface) 0%, #000 55%);
    color: #fff;
    padding: 0.75rem 0 1.25rem;
    position: sticky;
    top: 0;
    align-self: flex-start;
    min-height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--cms-sidebar-border);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.app-sidebar::-webkit-scrollbar {
    width: 4px;
}

.app-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.app-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 100px;
}

.app-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.app-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.app-sidebar-module {
    border-bottom: 1px solid var(--cms-sidebar-border);
    padding-bottom: 0.35rem;
    margin-bottom: 0.25rem;
}

.app-sidebar-module:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.app-sidebar-module > summary {
    list-style: none;
    cursor: pointer;
}

.app-sidebar-module > summary::-webkit-details-marker {
    display: none;
}

.app-sidebar-module-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #a8a8a7;
    padding: 0.65rem 1rem 0.5rem 1.25rem;
    user-select: none;
}

.app-sidebar-module-title::after {
    content: "";
    width: 0.35rem;
    height: 0.35rem;
    border-right: 2px solid var(--cms-border);
    border-bottom: 2px solid var(--cms-border);
    transform: rotate(45deg);
    flex-shrink: 0;
    opacity: 0.75;
    transition: transform 0.2s ease;
}

.app-sidebar-module[open] > .app-sidebar-module-title::after {
    transform: rotate(-135deg);
    margin-top: 0.15rem;
}

.app-sidebar-module-title-text {
    flex: 1;
    border-left: 3px solid transparent;
    padding-left: 0.5rem;
    line-height: 1.25;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.app-sidebar-module--current .app-sidebar-module-title-text,
.app-sidebar-module[open] .app-sidebar-module-title-text {
    border-left-color: var(--bs-primary);
}

.app-sidebar-module--current > .app-sidebar-module-title .app-sidebar-module-title-text {
    color: #f0f0ef;
}

.app-sidebar-list {
    list-style: none;
    margin: 0 0 0.35rem;
    padding: 0 0.5rem 0 0.65rem;
}

.app-sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 0.65rem 0.5rem 0.85rem;
    margin: 0.1rem 0;
    color: #e8e8e7;
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: 8px;
    border-left: 3px solid transparent;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.app-sidebar-link-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.app-sidebar-link-text {
    flex: 1;
    min-width: 0;
}

.app-sidebar-link:hover {
    color: #fff;
    background: rgba(48, 44, 103, 0.18);
}

.app-sidebar-link:hover .app-sidebar-link-dot {
    background: var(--bs-primary);
}

.app-sidebar-link.is-active {
    color: #fff;
    border-left-color: var(--bs-primary);
    background: rgba(48, 44, 103, 0.22);
    font-weight: 600;
}

.app-sidebar-link.is-active .app-sidebar-link-dot {
    background: var(--bs-primary);
    box-shadow: 0 0 0 2px rgba(48, 44, 103, 0.35);
}

.app-topbar {
    height: var(--cms-topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    background: #fff;
    border-bottom: 1px solid var(--cms-border);
    gap: 1rem;
}

.app-topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
}

.app-topbar-brand img {
    height: 36px;
    width: auto;
}

.app-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.app-content {
    flex: 1;
    padding: 1.25rem;
}

.app-sidebar-toggle {
    display: none;
    border: 1px solid var(--cms-border);
    background: #fff;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
}

@media (max-width: 991.98px) {
    .app-sidebar-toggle {
        display: inline-block;
    }

    .app-shell {
        flex-direction: column;
    }

    .app-main-wrap {
        order: 1;
        width: 100%;
    }

    .app-sidebar {
        order: 2;
        position: fixed;
        left: 0;
        top: 0;
        z-index: 1040;
        height: 100vh;
        width: min(var(--cms-sidebar-width), 88vw);
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }

    .app-sidebar.is-open {
        transform: translateX(0);
    }
}

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: var(--cms-body-bg);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border: 1px solid var(--cms-border);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
}

.login-logo {
    display: block;
    margin: 0 auto 1.5rem;
    max-height: 56px;
    width: auto;
}

.login-page .form-title {
    text-align: center;
    color: var(--cms-body-color);
    font-weight: 700;
    margin-bottom: 1.25rem;
}

.login-page .copyright {
    margin-top: 2rem;
    text-align: center;
    color: var(--cms-border);
    font-size: 0.85rem;
}

/* BlockUI */
.cms-blockui-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    text-align: center;
    margin: 0;
    padding: 1.5rem 2rem;
    min-width: 11rem;
    background: #fff;
    border: 1px solid var(--cms-border);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

.cms-blockui-logo-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.65rem 1rem;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #eee;
}

.cms-blockui-logo {
    display: block;
    width: 100px;
    max-width: min(100px, 40vw);
    height: auto;
    margin: 0;
}

.cms-blockui-text {
    margin: 0;
    color: #000 !important;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.blockUI.blockOverlay {
    z-index: 19990 !important;
}

.blockUI.blockMsg {
    z-index: 20000 !important;
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    max-width: 90vw;
}

#toast-container {
    z-index: 25000 !important;
}

/* Formularios: obligatorio / opcional */
.cms-form-legend {
    font-size: 0.875rem;
    color: var(--bs-secondary-color);
    margin-bottom: 1rem;
    padding-left: 0.75rem;
    border-left: 3px solid var(--bs-primary);
}

.cms-form-required-star {
    color: var(--bs-danger, #dc3545);
    font-weight: 700;
    margin-left: 0.125rem;
    line-height: 1;
}

.cms-form-optional-hint {
    font-size: 0.8125rem;
    color: var(--bs-secondary-color);
    font-weight: 400;
    margin-left: 0.25rem;
}
