/* =========================================================
   PLUS INVENTORY ERP - LAYOUT Y MENÚ RESPONSIVE
========================================================= */

:root {
    --sidebar-width: 235px;
    --sidebar-collapsed-width: 88px;
    --topbar-height: 76px;
    --primary: var(--primary);
    --primary-dark: #2b1b72;
    --sidebar-bg: #2b1b72;
    --sidebar-text: #d9d4ff;
    --sidebar-muted: #8f85c8;
    --surface: var(--white);
    --page-bg: var(--page-bg);
    --border: var(--border);
    --text: var(--text);
    --muted: var(--muted);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body.erp-body {
    min-width: 320px;
    font-family: "Inter", sans-serif;
    font-size: 13px;
    color: var(--text);
    background: var(--page-bg);
}

button,
input,
select,
textarea {
    font: inherit;
}

.erp-shell {
    min-height: 100vh;
}

/* SIDEBAR ================================================= */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    display: flex;
    width: var(--sidebar-width);
    height: 100vh;
    flex-direction: column;
    overflow: hidden;
    background: linear-gradient(180deg, #2d1b75 0%, #241665 100%);
    color: var(--white);
    transition:
        width .25s ease,
        transform .25s ease;
}

.sidebar-brand {
    display: flex;
    min-height: var(--topbar-height);
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    white-space: nowrap;
}

.sidebar-brand__icon {
    display: grid;
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    place-items: center;
    border-radius: 14px;
    color: #211466;
    background: linear-gradient(135deg, #c9bfff, #7d62ff);
    font-size: 19px;
}

.sidebar-brand__text {
    min-width: 0;
    overflow: hidden;
}

.sidebar-brand strong,
.sidebar-brand small {
    display: block;
}

.sidebar-brand strong {
    font-size: 16px;
    font-weight: 800;
}

.sidebar-brand small {
    margin-top: 3px;
    color: #a99de2;
    font-size: 13px;
}

.sidebar-nav {
    flex: 1;
    padding: 18px 10px 28px;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .35) transparent;
}

.sidebar-section {
    display: block;
    margin: 17px 10px 8px;
    color: var(--sidebar-muted);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .09em;
    white-space: nowrap;
}

.nav-item {
    display: flex;
    min-height: 42px;
    align-items: center;
    gap: 13px;
    margin: 2px 0;
    padding: 0 13px;
    border-radius: 10px;
    color: var(--sidebar-text);
    text-decoration: none;
    white-space: nowrap;
    transition:
        color .2s ease,
        background .2s ease;
}

.nav-item i {
    flex: 0 0 20px;
    width: 20px;
    text-align: center;
    font-size: 14px;
}

.nav-item span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item:hover {
    color: var(--white);
    background: rgba(255, 255, 255, .08);
}

.nav-item.active {
    color: var(--white);
    background: linear-gradient(135deg, #6c4df2, #5639d6);
    box-shadow: 0 8px 18px rgba(43, 21, 130, .25);
}

/* MAIN ==================================================== */

.main-area {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    transition: margin-left .25s ease;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    min-height: var(--topbar-height);
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 0 28px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(10px);
}

.topbar-left,
.topbar-actions,
.user-menu {
    display: flex;
    align-items: center;
}

.topbar-left {
    gap: 16px;
    min-width: 0;
}

.topbar-actions {
    gap: 12px;
}

.topbar-heading {
    min-width: 0;
}

.topbar-heading h1 {
    margin: 0;
    font-size: 18px;
    line-height: 1.2;
    white-space: nowrap;
}

.topbar-heading p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.icon-button {
    position: relative;
    display: grid;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: #343049;
    background: var(--white);
    cursor: pointer;
    transition:
        background .2s ease,
        color .2s ease,
        border-color .2s ease;
}

.icon-button:hover {
    color: var(--primary);
    border-color: #d7d0ff;
    background: #f8f6ff;
}

.notification-dot {
    position: absolute;
    top: 9px;
    right: 9px;
    width: 6px;
    height: 6px;
    border: 2px solid var(--white);
    border-radius: 999px;
    background: #ef4c55;
}

.user-menu {
    min-width: 0;
    gap: 10px;
    padding-left: 12px;
    border-left: 1px solid var(--border);
}

.user-avatar {
    display: grid;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    place-items: center;
    border-radius: 12px;
    color: var(--primary);
    background: #efeaff;
    font-weight: 800;
}

.user-data {
    min-width: 0;
}

.user-data strong,
.user-data span {
    display: block;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-data strong {
    font-size: 13px;
}

.user-data span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
}

.logout-button {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 0;
    border-radius: 9px;
    color: #9693a5;
    background: transparent;
    cursor: pointer;
}

.logout-button:hover {
    color: var(--danger);
    background: var(--danger-soft);
}

.content-area {
    min-height: calc(100vh - var(--topbar-height));
    padding: 0;
    background: var(--page-bg);
}

/* MENÚ COMPACTO ESCRITORIO ================================= */

body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .main-area {
    margin-left: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 0;
}

body.sidebar-collapsed .sidebar-brand__text,
body.sidebar-collapsed .sidebar-section,
body.sidebar-collapsed .nav-item span {
    display: none;
}

body.sidebar-collapsed .sidebar-nav {
    padding-inline: 10px;
}

body.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 0;
}

body.sidebar-collapsed .nav-item i {
    flex-basis: auto;
    width: auto;
    font-size: 16px;
}

body.sidebar-collapsed .nav-item {
    position: relative;
}

body.sidebar-collapsed .nav-item:hover::after {
    content: attr(title);
    position: fixed;
    left: calc(var(--sidebar-collapsed-width) + 10px);
    z-index: 1080;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--white);
    background: #1e1831;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
    font-size: 13px;
    white-space: nowrap;
}

/* OVERLAY ================================================= */

.sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 1030;
    display: none;
    background: rgba(13, 10, 30, .52);
    opacity: 0;
    transition: opacity .25s ease;
}

/* ALERTAS ================================================= */

.alert {
    margin: 20px 28px 0;
    padding: 13px 15px;
    border: 1px solid transparent;
    border-radius: 12px;
}

.alert-success {
    color: #11603d;
    border-color: #bfead8;
    background: #eaf8f2;
}

.alert-danger {
    color: #8a2f35;
    border-color: var(--danger-soft);
    background: var(--danger-soft);
}

/* TABLET Y MÓVIL ========================================== */

@media (max-width: 991px) {
    .sidebar {
        width: var(--sidebar-width);
        transform: translateX(-100%);
        box-shadow: 14px 0 35px rgba(18, 10, 55, .28);
    }

    .main-area,
    body.sidebar-collapsed .main-area {
        margin-left: 0;
    }

    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-width);
    }

    body.sidebar-collapsed .sidebar-brand {
        justify-content: flex-start;
        padding: 0 20px;
    }

    body.sidebar-collapsed .sidebar-brand__text,
    body.sidebar-collapsed .sidebar-section,
    body.sidebar-collapsed .nav-item span {
        display: block;
    }

    body.sidebar-collapsed .nav-item {
        justify-content: flex-start;
        padding: 0 13px;
    }

    body.sidebar-collapsed .nav-item i {
        flex: 0 0 20px;
        width: 20px;
        font-size: 14px;
    }

    body.sidebar-mobile-open {
        overflow: hidden;
    }

    body.sidebar-mobile-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-mobile-open .sidebar-overlay {
        display: block;
        opacity: 1;
    }

    .topbar {
        padding-inline: 18px;
    }
}

@media (max-width: 640px) {
    :root {
        --topbar-height: 68px;
    }

    .topbar {
        gap: 10px;
        padding-inline: 12px;
    }

    .topbar-left {
        gap: 10px;
    }

    .topbar-heading h1 {
        font-size: 16px;
    }

    .topbar-heading p {
        display: none;
    }

    .user-data {
        display: none;
    }

    .user-menu {
        padding-left: 8px;
    }

    .topbar-actions {
        gap: 7px;
    }

    .icon-button {
        flex-basis: 40px;
        width: 40px;
        height: 40px;
    }

    .alert {
        margin-inline: 14px;
    }
}

/* Logo administrable del sistema */
.sidebar-brand__icon img {
    display: block;
    width: 34px;
    height: 34px;
    object-fit: contain;
}

body.sidebar-collapsed .sidebar-brand__icon img {
    width: 32px;
    height: 32px;
}

/* LOGIN / AUTENTICACIÓN */
:root{--primary:var(--primary);--primary-dark:var(--primary-dark);--primary-soft:#f0edff;--bg:#f5f7fb;--surface:var(--white);--text:#202235;--muted:#7b8195;--line:#e8eaf1;--success:#19a86b;--warning:#f0a12b;--danger:#e34d59;--shadow:0 10px 30px rgba(31,35,60,.08)}*{box-sizing:border-box}html,body{margin:0;min-height:100%;font-family:Inter,Arial,sans-serif;color:var(--text);font-size:13px}button,input{font:inherit}.auth-page{background:#f7f7fb}.auth-shell{min-height:100vh;display:grid;grid-template-columns:1.08fr .92fr}.auth-showcase{position:relative;overflow:hidden;padding:52px;background:linear-gradient(145deg,#31158d 0%,var(--primary) 52%,#7860ff 100%);color:var(--white)}.auth-showcase:before,.auth-showcase:after{content:"";position:absolute;border-radius:50%;border:1px solid rgba(255,255,255,.15)}.auth-showcase:before{width:540px;height:540px;right:-220px;top:-200px}.auth-showcase:after{width:380px;height:380px;left:-190px;bottom:-180px}.auth-showcase__content{position:relative;z-index:2;max-width:650px;height:100%;display:flex;flex-direction:column}.auth-logo{display:flex;align-items:center;gap:13px}.auth-logo__icon,.sidebar-brand__icon{width:46px;height:46px;display:grid;place-items:center;border-radius:13px;background:var(--white);color:var(--primary);font-size:21px;box-shadow:0 8px 24px rgba(0,0,0,.13)}.auth-logo strong{display:block;font-size:19px}.auth-logo small{display:block;margin-top:3px;opacity:.75}.auth-copy{margin:auto 0 38px;max-width:590px}.auth-kicker,.auth-eyebrow,.welcome-kicker{font-weight:700;font-size:13px;letter-spacing:1.5px}.auth-copy h1{font-size:42px;line-height:1.15;margin:18px 0}.auth-copy p{font-size:15px;line-height:1.8;opacity:.82}.auth-features{display:grid;gap:13px}.auth-features div{display:flex;align-items:center;gap:12px;color:rgba(255,255,255,.9)}.auth-features i{width:32px;height:32px;display:grid;place-items:center;border-radius:10px;background:rgba(255,255,255,.13)}.auth-panel{display:grid;place-items:center;padding:50px;background:var(--white)}.auth-card{width:100%;max-width:430px}.auth-card__mobile-logo{display:none}.auth-eyebrow{color:var(--primary)}.auth-card h2{font-size:32px;margin:12px 0 7px}.auth-description{color:var(--muted);margin:0 0 30px}.form-group{margin-bottom:18px}.form-group label{display:block;font-weight:600;margin-bottom:8px}.input-icon{position:relative}.input-icon>i{position:absolute;left:15px;top:50%;transform:translateY(-50%);color:#9298aa}.input-icon input{width:100%;height:50px;border:1px solid #dfe2eb;border-radius:11px;padding:0 46px 0 43px;outline:none;transition:.2s;background:var(--white)}.input-icon input:focus{border-color:var(--primary);box-shadow:0 0 0 4px rgba(90,54,255,.1)}.password-toggle{position:absolute;right:8px;top:8px;width:34px;height:34px;border:0;background:transparent;color:#858b9d;cursor:pointer}.remember-check{display:flex;align-items:center;gap:9px;color:#61677a;margin:3px 0 22px}.remember-check input{accent-color:var(--primary)}.btn-login{width:100%;height:51px;border:0;border-radius:11px;background:linear-gradient(135deg,var(--primary),#755cff);color:var(--white);font-weight:700;display:flex;align-items:center;justify-content:center;gap:13px;cursor:pointer;box-shadow:0 10px 22px rgba(90,54,255,.25)}.btn-login:hover{transform:translateY(-1px)}.auth-footer{text-align:center;color:#a0a5b5;margin-top:28px;font-size:13px}.auth-footer__link{color:inherit;text-decoration:none}.auth-footer__link:hover,.auth-footer__link:focus{color:inherit;text-decoration:none}.alert{display:flex;align-items:center;gap:10px;padding:12px 14px;border-radius:10px;margin-bottom:20px}.alert-danger{background:var(--danger-soft);color:#b52e3b}.alert-success{background:#eafaf3;color:#16875a}
.auth-logo__icon img,.auth-card__mobile-logo img{max-width:100%;max-height:100%;object-fit:contain;border-radius:10px}

/* Navegación moderna consolidada */
.sidebar-nav{padding-bottom:28px}.sidebar-section{margin-top:18px;letter-spacing:.09em;opacity:.82}.nav-item{position:relative;border-radius:11px;margin:3px 10px;padding-left:14px;transition:background .18s ease,transform .18s ease,color .18s ease}.nav-item:hover{transform:translateX(2px)}.nav-item.active:before{content:"";position:absolute;left:-10px;top:9px;bottom:9px;width:3px;border-radius:0 4px 4px 0;background:var(--white)}.nav-item i{width:22px;text-align:center}.content-area{background:radial-gradient(circle at 88% 0,rgba(90,54,255,.04),transparent 26%),#f3f6fb}

/* RESTAURACIÓN DEL HOVER ORIGINAL DEL SIDEBAR ================= */
.sidebar .nav-item:hover {
    color: var(--sidebar-text, var(--white)) !important;
    background: rgba(255, 255, 255, .08) !important;
}

body.sidebar-collapsed .nav-item,
body.sidebar-collapsed .nav-item:hover,
body.sidebar-collapsed .nav-item.active {
    width: 52px;
    min-width: 52px;
    height: 44px;
    margin: 3px auto;
    padding: 0 !important;
    justify-content: center;
    transform: none !important;
    border-radius: 11px;
}

body.sidebar-collapsed .nav-item:hover {
    color: var(--sidebar-text, var(--white)) !important;
    background: rgba(255, 255, 255, .08) !important;
    box-shadow: none !important;
}

body.sidebar-collapsed .nav-item.active {
    color: var(--white) !important;
    background: rgba(255, 255, 255, .12) !important;
    box-shadow: none !important;
}

body.sidebar-collapsed .nav-item.active::before {
    left: -10px;
    top: 9px;
    bottom: 9px;
}

body.sidebar-collapsed .nav-item:hover::after {
    display: none !important;
    content: none !important;
}

body.sidebar-collapsed .nav-item i {
    width: 22px !important;
    flex: 0 0 22px !important;
    text-align: center;
    color: inherit;
}
