/* =========================================================
   iatros · navbar
   Sistema de navegación principal. Usado por nav/{public,patient,doctor,admin}.ejs
   ========================================================= */

:root {
    --iatros-purple-50: #eeedfe;
    --iatros-purple-100: #cecbf6;
    --iatros-purple-200: #afa9ec;
    --iatros-purple-400: #7f77dd;
    --iatros-purple-600: #5d4fbe;
    --iatros-purple-800: #3c3489;
    --iatros-purple-900: #26215c;

    --iatros-text-primary: #1f1b2e;
    --iatros-text-secondary: #525252;
    --iatros-text-tertiary: #888;

    --iatros-surface: #fff;
    --iatros-surface-hover: #f4f2fb;
    --iatros-border: rgba(0, 0, 0, 0.08);

    --iatros-nav-height: 64px;
}

/* ---------- contenedor raíz ---------- */
.iatros-nav {
    background: var(--iatros-surface);
    border-bottom: 0.5px solid var(--iatros-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.iatros-nav-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    min-height: var(--iatros-nav-height);
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
}

/* ---------- brand (logo + wordmark) ---------- */
.iatros-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--iatros-text-primary);
    flex-shrink: 0;
}

.iatros-brand-mark {
    display: block;
}

.iatros-brand-word {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1;
}

.iatros-brand-context {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--iatros-text-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--iatros-surface-hover);
    margin-left: 4px;
}

/* ---------- items principales (desktop) ---------- */
.iatros-nav-items {
    display: flex;
    align-items: stretch;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 2px;
    flex: 1;
}

.iatros-nav-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--iatros-text-secondary);
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.iatros-nav-item:hover {
    background: var(--iatros-surface-hover);
    color: var(--iatros-text-primary);
}

.iatros-nav-item.is-active {
    background: var(--iatros-purple-50);
    color: var(--iatros-text-primary);
    font-weight: 600;
}

.iatros-nav-chevron {
    font-size: 0.65rem;
    line-height: 1;
    transition: transform 0.15s ease;
}

/* punto rosa de embarazo activo */
.iatros-nav-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ed93b1;
}

/* ---------- dropdowns desktop ---------- */
.iatros-nav-dropdown {
    position: relative;
}

.iatros-nav-dropdown-trigger {
    cursor: pointer;
}

.iatros-nav-dropdown-panel {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--iatros-surface-hover);
    border: 0.5px solid var(--iatros-purple-100);
    border-radius: 0 8px 8px 8px;
    padding: 6px;
    min-width: 220px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.06);
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 20;
}

.iatros-nav-dropdown:hover .iatros-nav-dropdown-panel,
.iatros-nav-dropdown.is-open .iatros-nav-dropdown-panel {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.iatros-nav-dropdown:hover .iatros-nav-item,
.iatros-nav-dropdown.is-open > .iatros-nav-item {
    background: var(--iatros-surface-hover);
    border-radius: 8px 8px 0 0;
    color: var(--iatros-text-primary);
}

.iatros-nav-dropdown:hover .iatros-nav-chevron,
.iatros-nav-dropdown.is-open .iatros-nav-chevron {
    transform: rotate(180deg);
}

.iatros-nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    font-size: 0.8125rem;
    color: var(--iatros-text-primary);
    text-decoration: none;
    border-radius: 6px;
    transition: background-color 0.1s ease;
}

.iatros-nav-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.7);
    color: var(--iatros-text-primary);
}

.iatros-nav-dropdown-item.is-active {
    background: rgba(255, 255, 255, 0.9);
    font-weight: 600;
}

.iatros-nav-dropdown-item i {
    color: var(--iatros-purple-600);
    width: 16px;
    text-align: center;
    font-size: 0.875rem;
}

.iatros-nav-dropdown-overview {
    color: var(--iatros-purple-600);
    font-weight: 500;
}

.iatros-nav-dropdown-divider {
    margin: 4px 0;
    border: 0;
    border-top: 0.5px solid var(--iatros-purple-100);
    opacity: 0.6;
}

.iatros-nav-dropdown-item--danger {
    color: #a32d2d;
}

.iatros-nav-dropdown-item--danger:hover {
    color: #791f1f;
    background: #fcebeb;
}

.iatros-nav-dropdown-item--danger i {
    color: #a32d2d;
}

/* ---------- acciones (CTA + perfil + burger) ---------- */
.iatros-nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.iatros-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--iatros-purple-600);
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
}

.iatros-cta:hover {
    background: var(--iatros-purple-800);
    color: #fff;
}

.iatros-cta:active {
    transform: translateY(1px);
}

.iatros-cta-label-short {
    display: none;
}

/* ---------- avatar + role badge ---------- */
.iatros-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 600;
    flex-shrink: 0;
}

.iatros-avatar--lg {
    width: 40px;
    height: 40px;
    font-size: 0.95rem;
}

.iatros-avatar--patient {
    background: var(--iatros-purple-600);
}
.iatros-avatar--doctor {
    background: #185fa5;
}
.iatros-avatar--admin {
    background: #ba7517;
}

.iatros-role-badge {
    display: inline-block;
    font-size: 0.625rem;
    line-height: 1;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: lowercase;
    letter-spacing: 0.02em;
    margin-top: 3px;
}

.iatros-role-badge--patient {
    background: #e1f5ee;
    color: #0f6e56;
}
.iatros-role-badge--doctor {
    background: #e6f1fb;
    color: #0c447c;
}
.iatros-role-badge--admin {
    background: #faeeda;
    color: #854f0b;
}

/* ---------- perfil (desktop) ---------- */
.iatros-nav-profile {
    position: relative;
}

.iatros-nav-profile-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    padding: 4px 8px 4px 4px;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.iatros-nav-profile-trigger:hover {
    background: var(--iatros-surface-hover);
}

.iatros-nav-profile-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.1;
}

.iatros-nav-profile-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--iatros-text-primary);
}

.iatros-nav-profile-panel {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--iatros-surface);
    border: 0.5px solid var(--iatros-border);
    border-radius: 10px;
    padding: 6px;
    min-width: 240px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 20;
}

.iatros-nav-profile.is-open .iatros-nav-profile-panel {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.iatros-nav-profile-info {
    padding: 8px 10px;
}

.iatros-nav-profile-info-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--iatros-text-primary);
}

.iatros-nav-profile-info-email {
    font-size: 0.75rem;
    color: var(--iatros-text-tertiary);
    margin-top: 2px;
}

.iatros-nav-logout-form {
    margin: 0;
}

.iatros-nav-logout-form button {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    cursor: pointer;
}

/* ---------- hamburger button (visible solo en mobile) ---------- */
.iatros-nav-burger {
    display: none;
    background: transparent;
    border: 0.5px solid var(--iatros-border);
    color: var(--iatros-text-primary);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 1.125rem;
    line-height: 1;
    cursor: pointer;
}

.iatros-nav-burger:hover {
    background: var(--iatros-surface-hover);
}

/* ---------- drawer mobile ---------- */
.iatros-drawer {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(85vw, 360px);
    background: var(--iatros-surface);
    z-index: 200;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    flex-direction: column;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

.iatros-drawer-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 150;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.iatros-nav.is-drawer-open .iatros-drawer {
    transform: translateX(0);
}

.iatros-nav.is-drawer-open .iatros-drawer-backdrop {
    opacity: 1;
}

body.iatros-drawer-locked {
    overflow: hidden;
}

.iatros-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 0.5px solid var(--iatros-border);
}

.iatros-drawer-close {
    background: transparent;
    border: 0.5px solid var(--iatros-border);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    color: var(--iatros-text-primary);
}

.iatros-drawer-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px 12px 8px;
    padding: 12px;
    background: #f8f7fb;
    border-radius: 10px;
}

.iatros-drawer-profile-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.iatros-drawer-profile-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--iatros-text-primary);
}

.iatros-drawer-items {
    list-style: none;
    margin: 0;
    padding: 8px;
    flex: 1;
}

.iatros-drawer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px;
    font-size: 0.9375rem;
    color: var(--iatros-text-primary);
    text-decoration: none;
    border-radius: 8px;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    margin-bottom: 2px;
    font-family: inherit;
}

.iatros-drawer-item:hover {
    background: var(--iatros-surface-hover);
}

.iatros-drawer-item.is-active {
    background: var(--iatros-purple-50);
    font-weight: 600;
    color: var(--iatros-text-primary);
}

.iatros-drawer-item-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.iatros-drawer-group {
    background: transparent;
    border-radius: 8px;
    margin-bottom: 2px;
    transition: background-color 0.15s ease;
}

.iatros-drawer-group.is-open {
    background: var(--iatros-surface-hover);
    padding: 2px;
}

.iatros-drawer-group.is-active.is-open .iatros-drawer-group-trigger {
    color: var(--iatros-text-primary);
    font-weight: 600;
}

.iatros-drawer-group-trigger .iatros-nav-chevron {
    transition: transform 0.15s ease;
}

.iatros-drawer-group.is-open .iatros-drawer-group-trigger .iatros-nav-chevron {
    transform: rotate(180deg);
}

.iatros-drawer-group-panel {
    display: none;
    padding: 2px 0 6px;
}

.iatros-drawer-group.is-open .iatros-drawer-group-panel {
    display: block;
}

.iatros-drawer-subitem {
    display: block;
    padding: 9px 12px 9px 24px;
    font-size: 0.875rem;
    color: var(--iatros-text-secondary);
    text-decoration: none;
    border-radius: 6px;
    margin: 0 4px;
}

.iatros-drawer-subitem:hover {
    background: rgba(255, 255, 255, 0.7);
    color: var(--iatros-text-primary);
}

.iatros-drawer-subitem.is-active {
    background: rgba(255, 255, 255, 0.9);
    color: var(--iatros-text-primary);
    font-weight: 600;
}

.iatros-drawer-subitem--overview {
    color: var(--iatros-purple-600);
    font-style: italic;
    font-weight: 500;
}

.iatros-drawer-footer {
    border-top: 0.5px solid var(--iatros-border);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.iatros-drawer-footer-link {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    font-size: 0.875rem;
    color: var(--iatros-text-secondary);
    text-decoration: none;
    border-radius: 8px;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}

.iatros-drawer-footer-link:hover {
    background: var(--iatros-surface-hover);
    color: var(--iatros-text-primary);
}

.iatros-drawer-footer-link--danger {
    color: #a32d2d;
}

.iatros-drawer-footer-link--danger:hover {
    background: #fcebeb;
    color: #791f1f;
}

/* ---------- responsive: ocultar nav desktop, mostrar burger ---------- */
@media (max-width: 991.98px) {
    .iatros-nav-items,
    .iatros-nav-profile {
        display: none;
    }

    .iatros-nav-burger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .iatros-drawer {
        display: flex;
    }

    .iatros-nav.is-drawer-open .iatros-drawer-backdrop {
        display: block;
    }

    .iatros-cta-label {
        display: none;
    }

    .iatros-cta-label-short {
        display: inline;
    }

    .iatros-cta {
        padding: 7px 12px;
    }
}

@media (min-width: 992px) {
    .iatros-drawer,
    .iatros-drawer-backdrop {
        display: none !important;
    }
}