/* Mejoras UI/UX — complementa style.css sin reemplazar funcionalidad */

/* --- Layout app --- */
body.app-layout {
    overflow-x: hidden;
}

/* Por encima del sidebar y del contenido; ancho completo */
.top-navbar {
    background-color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    width: 100%;
    margin-left: 0 !important;
    z-index: 1070;
    height: 56px;
}

.top-navbar .container-fluid {
    height: 100%;
    align-items: center;
}

.top-navbar .dropdown-menu {
    z-index: 1080;
}

#sidebar-toggle {
    color: var(--primary);
    border: 1px solid #dee2e6;
    padding: 0.35rem 0.65rem;
}

.sidebar {
    background-color: var(--primary);
    color: #fff;
    height: calc(100vh - 56px);
    position: fixed;
    top: 56px;
    left: 0;
    width: 250px;
    z-index: 1040;
    overflow-y: auto;
    padding-top: 0;
    transition: transform 0.25s ease;
}

.sidebar-menu {
    padding: 0 10px 20px;
}

.sidebar-link-top {
    color: #fff;
    padding: 12px 15px;
    display: block;
    text-decoration: none;
    border-radius: 5px;
    margin-bottom: 8px;
    transition: background-color 0.2s;
}

.sidebar-link-top:hover,
.sidebar-menu a:hover {
    background-color: var(--secondary);
    color: #fff;
}

.sidebar-link-top.active,
.sidebar-menu a.active {
    background-color: var(--secondary);
    border-left: 4px solid #fff;
    color: #fff;
}

.sidebar-group {
    margin-bottom: 4px;
}

.sidebar-group-toggle {
    width: 100%;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.92);
    text-align: left;
    padding: 10px 12px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.sidebar-group-toggle:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.sidebar-chevron {
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.sidebar-group-toggle:not(.collapsed) .sidebar-chevron {
    transform: rotate(180deg);
}

.sidebar-group-items {
    padding: 2px 0 8px 8px;
}

.sidebar-group-items a {
    color: #fff;
    padding: 10px 14px;
    display: block;
    text-decoration: none;
    border-radius: 5px;
    margin-bottom: 3px;
    font-size: 0.92rem;
}

.main-content {
    position: relative;
    z-index: 1;
    margin-left: 250px;
    padding: 20px;
    padding-top: 76px;
    min-height: 100vh;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1035;
    pointer-events: none;
}

body.sidebar-open .sidebar-backdrop {
    pointer-events: auto;
}

/* --- Dashboard tarjetas clicables --- */
a.stat-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

a.stat-card-link .stat-card {
    cursor: pointer;
    border: 1px solid transparent;
}

a.stat-card-link:hover .stat-card {
    border-color: var(--secondary);
    box-shadow: 0 8px 20px rgba(52, 152, 219, 0.15);
}

a.stat-card-link:focus-visible .stat-card {
    outline: 2px solid var(--secondary);
    outline-offset: 2px;
}

.stat-card-hint {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 8px;
}

/* --- Encabezado de página --- */
.page-heading {
    margin-bottom: 1.25rem;
}

.page-heading .breadcrumb {
    margin-bottom: 0.35rem;
    font-size: 0.875rem;
}

/* --- Acciones en tablas --- */
.btn-action-labeled .btn-label {
    display: none;
}

@media (min-width: 1200px) {
    .btn-action-labeled .btn-label {
        display: inline;
        margin-left: 4px;
        font-size: 0.8rem;
    }
}

/* --- Formularios: estado enviando --- */
form.is-submitting .btn[type="submit"]:not(.no-loading) {
    pointer-events: none;
    opacity: 0.75;
}

/* --- Toasts --- */
.toast-container-app {
    z-index: 1080;
}

/* --- Login --- */
body.login-page {
    min-height: 100vh;
    margin: 0;
    background: linear-gradient(145deg, var(--primary) 0%, #1a252f 42%, var(--secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.login-shell {
    width: 100%;
    max-width: 420px;
}

.login-card--polished {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.18);
    padding: 2rem 2rem 1.75rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.login-brand {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-brand-logo {
    max-height: 56px;
    max-width: 200px;
    object-fit: contain;
    margin-bottom: 0.75rem;
}

.login-brand-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

.login-brand h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 0.25rem;
    line-height: 1.35;
}

.login-brand p {
    font-size: 0.875rem;
    color: #6c757d;
    margin: 0;
}

.login-alert {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
    border-radius: 8px;
    padding: 0.75rem 0.9rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.login-alert i {
    margin-top: 0.15rem;
    flex-shrink: 0;
}

.login-attempts-meter {
    margin-bottom: 1rem;
}

.login-attempts-meter .progress {
    height: 6px;
    border-radius: 3px;
}

.login-attempts-meter small {
    display: block;
    margin-top: 0.35rem;
    color: #6c757d;
    font-size: 0.8rem;
}

.login-field .input-group-text {
    background: #f8f9fa;
    color: var(--primary);
    min-width: 2.75rem;
    justify-content: center;
}

.login-field .form-control {
    border-left: 0;
}

.login-field .input-group:focus-within .input-group-text,
.login-field .input-group:focus-within .form-control {
    border-color: var(--secondary);
    box-shadow: none;
}

.login-field .input-group:focus-within {
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.2);
    border-radius: 0.375rem;
}

.login-toggle-pwd {
    border-left: 0;
    color: #6c757d;
}

.login-toggle-pwd:hover {
    color: var(--primary);
}

.login-hint {
    font-size: 0.78rem;
    color: #6c757d;
    text-align: center;
    margin-bottom: 1rem;
}

.login-submit.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    padding: 0.65rem 1rem;
    font-weight: 600;
}

.login-submit.btn-primary:hover:not(:disabled) {
    background-color: #1a252f;
    border-color: #1a252f;
}

.login-submit.btn-primary:disabled {
    opacity: 0.65;
}

#login-form.is-submitting .login-submit {
    pointer-events: none;
    opacity: 0.8;
}

.login-lock-bar {
    height: 4px;
    border-radius: 2px;
    background: #e9ecef;
    overflow: hidden;
    margin-top: 0.5rem;
}

.login-lock-bar-fill {
    height: 100%;
    background: var(--danger);
    transition: width 1s linear;
}

.login-footer {
    text-align: center;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
    font-size: 0.75rem;
    color: #adb5bd;
}

.login-form-locked {
    opacity: 0.55;
    pointer-events: none;
}

.login-dev-hint {
    font-size: 0.8rem;
}

/* --- Móvil --- */
@media (max-width: 991.98px) {
    .sidebar {
        top: 56px;
        height: calc(100vh - 56px);
        transform: translateX(-100%);
        z-index: 1055;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding-top: 72px;
    }
}
