/* =========================================================
   ESChE DIGITAL MEMBER PORTAL
   Brand: #1E90FF / #1560BD
   Responsive member dashboard
   ========================================================= */

.esche-portal {
    --esche-primary: #1E90FF;
    --esche-deep-blue: #1560BD;
    --esche-text: #172B4D;
    --esche-muted: #64748B;
    --esche-background: #F5F8FC;
    --esche-border: #E2E8F0;
    --esche-white: #FFFFFF;
    --esche-success: #15803D;
    --esche-success-bg: #DCFCE7;

    width: 100%;
    max-width: 1440px;
    margin: 24px auto;
    color: var(--esche-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
}

.esche-portal *,
.esche-portal *::before,
.esche-portal *::after {
    box-sizing: border-box;
}

/* =========================================================
   MAIN LAYOUT
   ========================================================= */

.esche-portal__layout {
    display: grid;
    grid-template-columns: 245px minmax(0, 1fr);
    min-height: 650px;
    overflow: hidden;
    background: var(--esche-background);
    border: 1px solid var(--esche-border);
    border-radius: 16px;
}

/* =========================================================
   SIDEBAR
   ========================================================= */

.esche-portal__sidebar {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 20px 14px 18px;
    background: var(--esche-white);
    border-right: 1px solid var(--esche-border);
}

/* =========================================================
   SIDEBAR MEMBER PROFILE
   Photo and member details are horizontally aligned.
   ========================================================= */

.esche-portal__profile {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    min-width: 0;
    padding: 18px 8px 22px;
    margin: 0 0 20px;
    text-align: left;
    border-bottom: 1px solid var(--esche-border);
}

.esche-portal__profile-photo {
    display: flex;
    flex: 0 0 58px;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    margin: 0;
    overflow: hidden;
    border: 2px solid #BFDBFE;
    border-radius: 50%;
    background: #EFF6FF;
}

.esche-portal__profile-avatar {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.esche-portal__profile-info {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-width: 0;
    gap: 3px;
}

.esche-portal__profile-name {
    width: 100%;
    margin: 0;
    color: var(--esche-text);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.esche-portal__profile-number {
    margin: 0;
    color: var(--esche-muted);
    font-size: 11px;
    font-weight: 400;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.esche-portal__profile-type {
    display: inline-block;
    max-width: 100%;
    margin-top: 3px;
    padding: 3px 8px;
    border: 1px solid #DBEAFE;
    border-radius: 20px;
    background: #EFF6FF;
    color: var(--esche-deep-blue);
    font-size: 10px;
    font-weight: 500;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

/* =========================================================
   SIDEBAR NAVIGATION
   ========================================================= */

.esche-portal__nav {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.esche-portal__nav a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 9px;
    color: var(--esche-muted);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.18s ease, color 0.18s ease;
}

/* =========================================================
   NOTIFICATION COUNTER BADGE
   ========================================================= */

.esche-portal__nav a[data-portal-target="notifications"] {
    gap: 10px;
}

.esche-portal__nav-badge {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;

    min-width: 20px;
    height: 20px;
    margin-left: auto;
    padding: 0 6px;

    color: #FFFFFF !important;
    background-color: #DC2626 !important;

    border: none;
    border-radius: 999px;

    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;

    white-space: nowrap;
    text-align: center;
    box-shadow: none;
}

/* Keep the badge compact when the notification link is active. */
.esche-portal__nav a.is-active .esche-portal__nav-badge,
.esche-portal__nav a[aria-current="page"] .esche-portal__nav-badge {
    color: #FFFFFF !important;
    background-color: #DC2626 !important;
}

/* Prevent the badge from becoming oversized on mobile. */
@media (max-width: 700px) {
    .esche-portal__nav a[data-portal-target="notifications"] {
        gap: 6px;
        justify-content: space-between;
    }

    .esche-portal__nav-badge {
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        font-size: 10px;
    }
}

.esche-portal__nav a:hover {
    background: #F1F7FF;
    color: var(--esche-deep-blue);
}

.esche-portal__nav a.is-active,
.esche-portal__nav a[aria-current="page"] {
    background: #EAF4FF;
    color: var(--esche-deep-blue);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--esche-primary);
}

.esche-portal__sidebar-footer {
    margin-top: auto;
    padding: 24px 10px 0;
    color: var(--esche-muted);
    font-size: 11px;
    line-height: 1.6;
}

/* =========================================================
   MAIN CONTENT
   ========================================================= */

.esche-portal__main {
    min-width: 0;
    padding: 32px;
}

.esche-portal__topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 30px;
}

.esche-portal__eyebrow {
    margin: 0 0 7px;
    color: var(--esche-deep-blue);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.09em;
    line-height: 1.6;
}

.esche-portal__title {
    margin: 0;
    color: var(--esche-text);
    font-size: clamp(24px, 3vw, 32px);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.6px;
    overflow-wrap: anywhere;
}

.esche-portal__subtitle {
    margin: 9px 0 0;
    color: var(--esche-muted);
    font-size: 13px;
    line-height: 1.6;
}

.esche-portal__avatar {
    display: flex;
    flex: 0 0 48px;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: 1px solid #BFDBFE;
    border-radius: 50%;
    background: #EAF4FF;
    color: var(--esche-deep-blue);
    font-size: 19px;
    font-weight: 700;
}

/* =========================================================
   MEMBERSHIP SUMMARY CARDS
   ========================================================= */

.esche-portal__stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.esche-portal__card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 150px;
    padding: 21px;
    overflow-wrap: anywhere;
    background: var(--esche-white);
    border: 1px solid var(--esche-border);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(23, 43, 77, 0.025);
}

.esche-portal__card-label {
    display: block;
    margin-bottom: 12px;
    color: var(--esche-muted);
    font-size: 12px;
    font-weight: 500;
}

.esche-portal__card-value {
    display: block;
    color: var(--esche-text);
    font-size: clamp(17px, 1.8vw, 22px);
    font-weight: 700;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.esche-portal__card-note {
    display: block;
    margin-top: 8px;
    color: var(--esche-muted);
    font-size: 11px;
    line-height: 1.5;
}

/* =========================================================
   CONTENT PANELS
   ========================================================= */

.esche-portal__content-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 18px;
    margin-bottom: 22px;
}

.esche-portal__panel {
    min-width: 0;
    padding: 24px;
    background: var(--esche-white);
    border: 1px solid var(--esche-border);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(23, 43, 77, 0.025);
}

.esche-portal__panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 22px;
}

.esche-portal__panel-header h2 {
    margin: 0;
    color: var(--esche-text);
    font-size: 16px;
    font-weight: 650;
    line-height: 1.4;
}

.esche-portal__panel-header p {
    margin: 5px 0 0;
    color: var(--esche-muted);
    font-size: 12px;
    line-height: 1.6;
}

/* =========================================================
   MEMBER INFORMATION
   ========================================================= */

.esche-portal__details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 23px 18px;
}

.esche-portal__details > div {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 5px;
}

.esche-portal__details > div > span {
    color: var(--esche-muted);
    font-size: 11px;
    font-weight: 400;
}

.esche-portal__details > div > strong {
    color: var(--esche-text);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

/* =========================================================
   DIGITAL ID PREVIEW
   ========================================================= */

.esche-portal__id-preview {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-height: 190px;
    padding: 24px;
    overflow-wrap: anywhere;
    border: 1px solid #C9DFFF;
    border-radius: 11px;
    background: linear-gradient(135deg, #F0F7FF 0%, #FFFFFF 100%);
}

.esche-portal__id-label {
    margin-bottom: 13px;
    color: var(--esche-deep-blue);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.09em;
}

.esche-portal__id-number {
    color: var(--esche-text);
    font-size: clamp(15px, 1.7vw, 20px);
    font-weight: 700;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.esche-portal__id-preview .esche-portal__card-note {
    margin-top: 12px;
}

/* =========================================================
   MEMBER SERVICES
   Retained for compatibility with existing markup.
   ========================================================= */

.esche-portal__quick-links {
    margin-bottom: 22px;
}

.esche-portal__service-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.esche-portal__service-grid a {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
    min-height: 90px;
    padding: 17px;
    border: 1px solid var(--esche-border);
    border-radius: 10px;
    background: var(--esche-white);
    color: var(--esche-text);
    text-decoration: none;
    transition: border-color 0.18s ease, background-color 0.18s ease;
}

.esche-portal__service-grid a:hover {
    border-color: #93C5FD;
    background: #F8FBFF;
}

.esche-portal__service-grid a strong {
    font-size: 13px;
    font-weight: 650;
}

.esche-portal__service-grid a span {
    color: var(--esche-muted);
    font-size: 11px;
    line-height: 1.6;
}

/* =========================================================
   FOOTER AND NOTICES
   ========================================================= */

.esche-portal__footer {
    padding: 12px 0 0;
    color: var(--esche-muted);
    font-size: 11px;
    text-align: center;
}

.esche-portal__notice {
    padding: 16px 18px;
    border: 1px solid #BFDBFE;
    border-radius: 9px;
    background: #EFF6FF;
    color: #1E40AF;
    font-size: 14px;
    line-height: 1.6;
}

/* =========================================================
   ACCESSIBILITY
   ========================================================= */

.esche-portal a:focus-visible,
.esche-portal button:focus-visible {
    outline: 3px solid #93C5FD;
    outline-offset: 3px;
}

/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 1100px) {
    .esche-portal__layout {
        grid-template-columns: 220px minmax(0, 1fr);
    }

    .esche-portal__main {
        padding: 24px;
    }

    .esche-portal__stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .esche-portal__content-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .esche-portal__profile {
        gap: 10px;
        padding-right: 4px;
        padding-left: 4px;
    }

    .esche-portal__profile-photo {
        flex-basis: 52px;
        width: 52px;
        height: 52px;
    }

    .esche-portal__profile-name {
        font-size: 13px;
    }
}

/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 700px) {
    .esche-portal {
        margin: 12px auto;
        font-size: 14px;
    }

    .esche-portal__layout {
        grid-template-columns: minmax(0, 1fr);
        min-height: 0;
        border-radius: 10px;
    }

    .esche-portal__sidebar {
        padding: 12px 14px 16px;
        border-right: 0;
        border-bottom: 1px solid var(--esche-border);
    }

    .esche-portal__profile {
        justify-content: flex-start;
        gap: 12px;
        padding: 8px 4px 16px;
        margin-bottom: 14px;
    }

    .esche-portal__profile-photo {
        flex: 0 0 54px;
        width: 54px;
        height: 54px;
    }

    .esche-portal__profile-name {
        font-size: 14px;
    }

    .esche-portal__profile-number {
        font-size: 11px;
    }

    .esche-portal__nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }

    .esche-portal__nav a {
        min-height: 42px;
        padding: 9px 10px;
        font-size: 12px;
        overflow-wrap: anywhere;
    }

    .esche-portal__sidebar-footer {
        padding: 14px 4px 0;
    }

    .esche-portal__main {
        padding: 20px 15px;
    }

    .esche-portal__topbar {
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 22px;
    }

    .esche-portal__eyebrow {
        font-size: 9px;
    }

    .esche-portal__title {
        font-size: 25px;
    }

    .esche-portal__subtitle {
        font-size: 12px;
    }

    .esche-portal__avatar {
        flex-basis: 40px;
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .esche-portal__stats,
    .esche-portal__content-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
    }

    .esche-portal__card {
        min-height: 0;
        padding: 18px;
    }

    .esche-portal__card-value {
        font-size: 20px;
    }

    .esche-portal__panel {
        padding: 18px;
    }

    .esche-portal__details {
        grid-template-columns: minmax(0, 1fr);
        gap: 17px;
    }

    .esche-portal__service-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .esche-portal__service-grid a {
        min-height: 75px;
    }

    .esche-portal__id-preview {
        min-height: 160px;
        padding: 20px;
    }
}

/* =========================================================
   SMALL MOBILE SCREENS
   ========================================================= */

@media (max-width: 380px) {
    .esche-portal__sidebar {
        padding-right: 10px;
        padding-left: 10px;
    }

    .esche-portal__profile-photo {
        flex-basis: 46px;
        width: 46px;
        height: 46px;
    }

    .esche-portal__profile {
        gap: 9px;
    }

    .esche-portal__profile-name {
        font-size: 13px;
    }

    .esche-portal__nav a {
        padding: 8px;
        font-size: 11px;
    }

    .esche-portal__details {
        gap: 14px;
    }
}

/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
    .esche-portal *,
    .esche-portal *::before,
    .esche-portal *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* =========================================================
   FIX: SIDEBAR PROFILE NAME AND AVATAR OVERFLOW
   ========================================================= */

.esche-portal .esche-portal__profile {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 10px !important;
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

/* Keep avatar at a fixed size */
.esche-portal .esche-portal__profile-photo {
    flex: 0 0 48px !important;
    width: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
    height: 48px !important;
    min-height: 48px !important;
    margin: 0 !important;
    overflow: hidden !important;
}

/* Prevent the image from growing */
.esche-portal .esche-portal__profile-avatar {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    object-fit: cover !important;
}

/* Allow member information to shrink beside the avatar */
.esche-portal .esche-portal__profile-info {
    flex: 1 1 0% !important;
    width: 0;
    min-width: 0 !important;
    overflow: hidden;
}

/* Lighter name and controlled wrapping */
.esche-portal .esche-portal__profile-name {
    display: -webkit-box !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    font-family: inherit !important;
    font-size: 12px !important;
    font-weight: 400 !important;
    line-height: 1.4 !important;
    letter-spacing: 0 !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: normal !important;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden !important;
}

/* Keep member number from stretching the sidebar */
.esche-portal .esche-portal__profile-number {
    max-width: 100% !important;
    margin: 2px 0 0 !important;
    font-size: 10px !important;
    font-weight: 400 !important;
    overflow-wrap: anywhere !important;
}

/* Keep membership badge within available width */
.esche-portal .esche-portal__profile-type {
    display: inline-block !important;
    max-width: 100% !important;
    margin-top: 4px !important;
    font-size: 9px !important;
    font-weight: 400 !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
}

/* Slightly larger avatar on wider screens */
@media (min-width: 701px) {
    .esche-portal .esche-portal__profile-photo {
        flex-basis: 52px !important;
        width: 52px !important;
        min-width: 52px !important;
        max-width: 52px !important;
        height: 52px !important;
    }
}

/* Member Portal Logout Button */
.esche-portal__logout-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: 1px solid #dc2626;
    border-radius: 8px;
    background: #ffffff;
    color: #dc2626;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.esche-portal__logout-button:hover,
.esche-portal__logout-button:focus {
    background: #dc2626;
    color: #ffffff;
    text-decoration: none;
}

.esche-portal__topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

@media (max-width: 600px) {
    .esche-portal__topbar {
        align-items: flex-start;
        flex-direction: column;
    }
}