/* =========================================================================
   CONNEXA - Paleta Sunrise
   Coral vivo / ambar miel / crema / pizarra azulada / turquesa
   ========================================================================= */

:root {
    /* Primary - Coral (calidez, conexion, alegria) */
    --cx-primary: #FF8C5A;
    --cx-primary-hover: #FF9E74;
    --cx-primary-light: rgba(255, 140, 90, 0.14);
    --cx-primary-border: rgba(255, 140, 90, 0.28);

    /* Accent - Ambar miel (puntos, niveles, logros) */
    --cx-accent: #FFD166;
    --cx-accent-hover: #FFDB85;
    --cx-accent-light: rgba(255, 209, 102, 0.18);

    /* Neutral - Crema */
    --cx-cream: #FFF8F1;
    --cx-cream-hover: #FFF2E4;

    /* Dark - Pizarra azulada */
    --cx-dark-1: #2D3142;
    --cx-dark-2: #373B4F;
    --cx-dark-3: #4A4F66;

    /* Feedback */
    --cx-success: #06D6A0;
    --cx-warning: #FFB37A;
    --cx-danger: #EF476F;
    --cx-info: #118AB2;

    /* Surfaces */
    --cx-bg-content: var(--cx-cream);
    --cx-bg-card: #FFFFFF;
    --cx-text-dark: var(--cx-dark-1);
    --cx-text-muted: #6C7290;
    --cx-text-light: #E8EAF0;
    --cx-border: #EBE2D4;
    --cx-border-subtle: rgba(45, 49, 66, 0.08);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--cx-bg-content);
    color: var(--cx-text-dark);
    font-size: 14px;
}

h1, h2, h3 {
    color: var(--cx-dark-1);
    font-weight: 600;
    letter-spacing: -0.01em;
}

a {
    color: var(--cx-primary);
    text-decoration: none;
}

a:hover {
    color: var(--cx-primary-hover);
}

/* =========================================================================
   Admin layout: sidebar + top-bar
   ========================================================================= */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--cx-dark-1) 0%, var(--cx-dark-2) 100%);
    color: var(--cx-text-light);
    padding: 1rem 0;
    overflow-y: auto;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 0.5rem;
}

.sidebar-brand-icon {
    font-size: 1.5rem;
}

.sidebar-brand-text {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--cx-primary);
}

.sidebar-section-title {
    padding: 1rem 1.25rem 0.4rem;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--cx-accent);
    font-weight: 600;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 1.25rem;
    color: var(--cx-text-light);
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 0.15s;
}

.sidebar-link:hover {
    background: rgba(255, 140, 90, 0.1);
    color: var(--cx-primary);
}

.sidebar-link.active {
    background: var(--cx-primary-light);
    color: var(--cx-primary);
    border-left: 3px solid var(--cx-primary);
    padding-left: calc(1.25rem - 3px);
}

.sidebar-link .icon {
    font-size: 1rem;
    width: 1.2rem;
    display: inline-block;
    text-align: center;
}

/* Nav groups colapsables con <details>/<summary> nativo HTML5 */
.nav-group {
    margin: 0;
    background: transparent !important;
    border: 0;
}

.nav-group[open] {
    background: transparent !important;
}

/* <summary> default tiene un triangulito + cursor + display list-item — todo a tirar */
.nav-group-toggle {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 1.25rem;
    color: var(--cx-text-light);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    user-select: none;
    background: transparent !important;
    transition: background 0.15s, color 0.15s;
}

/* Esconder el marker default (Safari + Chrome/Firefox) */
.nav-group-toggle::-webkit-details-marker { display: none; }
.nav-group-toggle::marker { display: none; content: ""; }

.nav-group-toggle:hover {
    background: rgba(255, 140, 90, 0.1) !important;
    color: var(--cx-primary);
}

.nav-group-toggle .nav-group-label {
    flex: 1 1 auto;
}

.nav-group-toggle .nav-chevron {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--cx-text-muted);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.nav-group[open] > .nav-group-toggle .nav-chevron {
    transform: rotate(180deg);
    color: var(--cx-primary);
}

.nav-group[open] > .nav-group-toggle {
    color: var(--cx-primary);
}

.nav-group-items {
    padding-bottom: 0.25rem;
    animation: navGroupExpand 0.15s ease-out;
}

@keyframes navGroupExpand {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.sidebar-link.sub {
    padding-left: 2.6rem;
    font-size: 0.83rem;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}

.sidebar-link.sub.active {
    padding-left: calc(2.6rem - 3px);
}

.sidebar-link.sub .icon {
    font-size: 0.9rem;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.top-bar {
    background: var(--cx-bg-card);
    border-bottom: 1px solid var(--cx-border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-weight: 600;
    color: var(--cx-dark-1);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--cx-dark-1);
    cursor: pointer;
    display: none;
}

.top-bar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
}

.top-bar-user:hover {
    background: var(--cx-cream-hover);
}

.user-menu {
    position: absolute;
    top: 50px;
    right: 0;
    background: var(--cx-bg-card);
    border: 1px solid var(--cx-border);
    border-radius: 8px;
    padding: 0.5rem 0;
    min-width: 180px;
    z-index: 200;
    box-shadow: 0 4px 16px rgba(45, 49, 66, 0.12);
}

.user-menu-item {
    display: block;
    width: 100%;
    padding: 0.55rem 1rem;
    background: none;
    border: none;
    color: var(--cx-dark-1);
    text-align: left;
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: none;
}

.btn-link {
    background: none;
    border: none;
    color: var(--cx-text-muted);
    cursor: pointer;
    padding: 0.25rem 0.4rem;
    font-size: 0.95rem;
}

.btn-link:hover {
    color: var(--cx-primary);
}

.user-menu-item:hover {
    background: var(--cx-cream-hover);
    color: var(--cx-primary);
}

.page-content {
    flex: 1;
    padding: 1.5rem;
    overflow-x: auto;
}

/* =========================================================================
   Portal cliente final layout
   ========================================================================= */

.portal-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--cx-bg-content);
}

.portal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0.85rem 1.5rem;
    background: var(--cx-bg-card);
    border-bottom: 1px solid var(--cx-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.portal-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--cx-primary);
}

.portal-brand-icon {
    font-size: 1.3rem;
}

.portal-nav {
    display: flex;
    gap: 1.5rem;
    flex: 1;
    justify-content: center;
}

.portal-nav-link {
    color: var(--cx-text-muted);
    padding: 0.35rem 0;
    border-bottom: 2px solid transparent;
    font-size: 0.9rem;
    font-weight: 500;
}

.portal-nav-link:hover {
    color: var(--cx-primary);
}

.portal-nav-link.active {
    color: var(--cx-primary);
    border-bottom-color: var(--cx-primary);
}

.portal-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.portal-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--cx-dark-1);
}

.portal-user:hover {
    background: var(--cx-cream-hover);
}

.portal-user-menu {
    position: absolute;
    top: 48px;
    right: 0;
    background: var(--cx-bg-card);
    border: 1px solid var(--cx-border);
    border-radius: 8px;
    padding: 0.5rem 0;
    min-width: 180px;
    z-index: 200;
    box-shadow: 0 4px 16px rgba(45, 49, 66, 0.12);
}

.portal-user-menu-item {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--cx-dark-1);
    font-size: 0.85rem;
}

.portal-user-menu-item:hover {
    background: var(--cx-cream-hover);
    color: var(--cx-primary);
}

.portal-menu-toggle {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--cx-dark-1);
    cursor: pointer;
    display: none;
}

.portal-content {
    flex: 1;
    padding: 2rem 1.5rem;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

.portal-footer {
    padding: 1rem 1.5rem;
    text-align: center;
    color: var(--cx-text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--cx-border);
}

/* =========================================================================
   Login
   ========================================================================= */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #FFF8F1 0%, #FFE7D3 50%, #FFD166 100%);
    padding: 1rem;
}

.login-card {
    background: var(--cx-bg-card);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(45, 49, 66, 0.14);
}

.login-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.login-brand-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.login-brand-title {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: var(--cx-primary);
}

.login-brand-subtitle {
    color: var(--cx-text-muted);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.form-group {
    margin-bottom: 1.1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
    color: var(--cx-dark-1);
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--cx-border);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--cx-dark-1);
    background: var(--cx-bg-card);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--cx-primary);
    box-shadow: 0 0 0 3px var(--cx-primary-light);
}

.login-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--cx-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    margin-top: 0.5rem;
}

.login-btn:hover {
    background: var(--cx-primary-hover);
}

.login-btn:active {
    transform: translateY(1px);
}

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--cx-text-muted);
    font-size: 0.75rem;
}

.alert {
    padding: 0.7rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.alert-danger {
    background: rgba(239, 71, 111, 0.1);
    color: var(--cx-danger);
    border: 1px solid rgba(239, 71, 111, 0.2);
}

.alert-success {
    background: rgba(6, 214, 160, 0.14);
    color: #035840;
    border: 1px solid rgba(6, 214, 160, 0.55);
    font-weight: 600;
    font-size: 1rem;
    padding: 0.9rem 1rem;
}

/* =========================================================================
   Cards & tables
   ========================================================================= */

.card {
    background: var(--cx-bg-card);
    border: 1px solid var(--cx-border);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 3px rgba(45, 49, 66, 0.04);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 1rem;
    color: var(--cx-dark-1);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--cx-bg-card);
    border: 1px solid var(--cx-border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(45, 49, 66, 0.04);
}

.kpi-label {
    color: var(--cx-text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.25rem;
}

.kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--cx-primary);
}

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid var(--cx-border);
    border-radius: 8px;
    background: var(--cx-bg-card);
    color: var(--cx-dark-1);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}

.btn:hover {
    background: var(--cx-cream-hover);
}

.btn-primary {
    background: var(--cx-primary);
    color: #fff;
    border-color: var(--cx-primary);
}

.btn-primary:hover {
    background: var(--cx-primary-hover);
    border-color: var(--cx-primary-hover);
    color: #fff;
}

.btn-accent {
    background: var(--cx-accent);
    color: var(--cx-dark-1);
    border-color: var(--cx-accent);
}

.btn-accent:hover {
    background: var(--cx-accent-hover);
}

/* Pill-style action buttons — matched to the sidebar vibe (informal, playful) */
.btn-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.38rem 0.95rem;
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    line-height: 1.2;
}

.btn-pill:hover {
    transform: translateY(-1px);
}

.btn-pill:active {
    transform: translateY(0);
}

.btn-pill .icon {
    font-size: 0.95rem;
    line-height: 1;
}

.btn-pill-ghost {
    background: rgba(45, 49, 66, 0.04);
    border-color: rgba(45, 49, 66, 0.12);
    color: var(--cx-dark-1);
}

.btn-pill-ghost:hover {
    background: rgba(255, 140, 90, 0.12);
    border-color: rgba(255, 140, 90, 0.35);
    color: var(--cx-primary);
}

.btn-pill-danger {
    background: rgba(239, 71, 111, 0.1);
    border-color: rgba(239, 71, 111, 0.3);
    color: #b8274d;
}

.btn-pill-danger:hover {
    background: rgba(239, 71, 111, 0.22);
    border-color: var(--cx-danger);
    color: var(--cx-danger);
    box-shadow: 0 2px 8px rgba(239, 71, 111, 0.15);
}

.btn-pill-success {
    background: rgba(6, 214, 160, 0.12);
    border-color: rgba(6, 214, 160, 0.4);
    color: #035840;
}

.btn-pill-success:hover {
    background: rgba(6, 214, 160, 0.25);
    border-color: var(--cx-success);
    color: #024634;
    box-shadow: 0 2px 8px rgba(6, 214, 160, 0.18);
}

.role-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(255, 140, 90, 0.15) 0%, rgba(255, 209, 102, 0.2) 100%);
    color: #8b4513;
    border: 1px solid rgba(255, 140, 90, 0.3);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* =========================================================================
   Responsive
   ========================================================================= */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -260px;
        transition: left 0.3s;
        z-index: 500;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-toggle {
        display: block;
    }

    .portal-menu-toggle {
        display: block;
    }

    .portal-nav {
        display: none;
    }

    .portal-nav.open {
        display: flex;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        flex-direction: column;
        background: var(--cx-bg-card);
        border-bottom: 1px solid var(--cx-border);
        padding: 0.5rem 0;
    }

    .portal-nav.open .portal-nav-link {
        padding: 0.75rem 1.5rem;
        border-bottom: none;
    }
}
