/* ==========================================================================
   Help Madhes - Double-Sided CR80 Digital Member ID Card Stylesheet
   Standard CR80 Size: 85.6mm x 54mm (Fixed 640px x 404px)
   Ultra-precision typography and canvas rendering rules to eliminate clipping
   ========================================================================== */

.hm-dual-card-container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
    width: 100%;
}

/* Single CR80 Card Box (Fixed 640px x 404px with explicit pixel sizing) */
.hm-cr80-card {
    width: 640px;
    height: 404px;
    background: #F8F1D8; /* warm ivory cream */
    border-radius: 18px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 12px 28px rgba(0, 59, 143, 0.12), 0 0 1px 1px rgba(215, 25, 32, 0.2);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
    border: 2px solid #D71920; /* deep official red */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    user-select: none;
    flex-shrink: 0;
}

/* ==========================================================================
   FRONT SIDE CARD
   ========================================================================== */

/* Top-Right Fluid Wave with safe breathing margins */
.hm-front-top-wave-container {
    position: absolute;
    top: 0;
    right: 0;
    width: 380px;
    height: 90px;
    pointer-events: none;
    z-index: 1;
}

.hm-wave-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.hm-top-motto-text {
    position: absolute;
    top: 10px;
    right: 18px;
    color: #ffffff;
    font-size: 0.76rem;
    font-style: italic;
    font-weight: 700;
    line-height: 1.2;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    z-index: 4;
    pointer-events: auto;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.hm-leaf-icon {
    width: 16px;
    height: 16px;
    color: #00843D;
    flex-shrink: 0;
}

/* ==================== DUAL-LOGO CARD HEADER ==================== */
.hm-dual-card-header {
    padding: 10px 16px 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 2;
    background: #F8F1D8; /* warm ivory cream */
    box-sizing: border-box;
    width: 100%;
}

.hm-header-logo-box {
    width: 52px;
    height: 52px;
    min-width: 52px;
    max-width: 52px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #ffffff; /* clean white */
    border: 1.5px solid #D71920; /* deep official red */
    box-shadow: 0 2px 6px rgba(215, 25, 32, 0.12);
    padding: 2px;
    box-sizing: border-box;
}

.hm-header-logo-box img, .hm-hdr-logo-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 50%;
    display: block;
}

.hm-header-center-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 8px;
    min-width: 0;
}

.hm-hdr-title-nepali {
    font-size: 1.35rem;
    font-weight: 900;
    color: #00843D; /* fresh medium green */
    line-height: 1.15;
    margin: 0;
    padding: 0;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.hm-hdr-title-english {
    font-size: 0.82rem;
    font-weight: 800;
    color: #003B8F; /* dark royal blue */
    letter-spacing: 0.5px;
    line-height: 1.2;
    margin: 1px 0 3px;
    white-space: nowrap;
}

.hm-hdr-reg-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.68rem;
    line-height: 1;
    white-space: nowrap;
}

.hm-hdr-badge-red {
    background: #D71920; /* deep official red */
    color: #ffffff;
    font-weight: 800;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.65rem;
    letter-spacing: 0.2px;
}

.hm-hdr-reg-text {
    color: #003B8F; /* dark royal blue */
    font-weight: 700;
    font-size: 0.66rem;
}

/* Official Red Header Strip / Motto Bar */
.hm-card-motto-bar {
    background: #D71920; /* deep official red */
    color: #ffffff;
    font-size: 0.68rem;
    font-weight: 700;
    text-align: center;
    padding: 2.5px 10px;
    letter-spacing: 0.4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hm-hdr-gold-bar {
    width: 100%;
    height: 2px;
    margin: 0;
    background: #00843D; /* fresh medium green accent line */
}

/* Front Body */
.hm-card-body {
    display: grid;
    grid-template-columns: 125px 1fr 115px;
    gap: 14px;
    padding: 6px 24px 6px;
    align-items: center;
    position: relative;
    z-index: 2;
    background: #F8F1D8; /* warm ivory cream */
}

/* Photo Box */
.hm-photo-col {
    display: flex;
    justify-content: center;
}

.hm-photo-frame {
    width: 120px;
    height: 148px;
    border-radius: 16px;
    border: 2px solid #D71920; /* deep official red */
    overflow: hidden;
    background: #ffffff; /* clean white */
    box-shadow: 0 4px 10px rgba(0, 59, 143, 0.1);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-sizing: border-box;
}

.hm-photo-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    display: block;
}

.hm-avatar-fallback {
    width: 100%;
    height: 100%;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.hm-avatar-init {
    position: absolute;
    bottom: 8px;
    font-size: 1.1rem;
    font-weight: 800;
    color: #003B8F; /* dark royal blue */
    background: #ffffff;
    border: 1px solid #D71920;
    padding: 2px 10px;
    border-radius: 20px;
    box-shadow: 0 2px 4px rgba(0, 59, 143, 0.1);
}

/* Details Rows with precision mathematical alignment & zero vertical clipping */
.hm-info-col {
    display: flex;
    flex-direction: column;
    background: #ffffff; /* clean white */
    border-radius: 8px;
    padding: 4px 10px;
    border: 1px solid rgba(215, 25, 32, 0.2);
    box-shadow: 0 2px 6px rgba(0, 59, 143, 0.05);
    width: 100%;
    overflow: visible;
    box-sizing: border-box;
}

.hm-info-row {
    display: flex;
    align-items: center;
    padding: 3px 0;
    border-bottom: 1px solid rgba(215, 25, 32, 0.12);
    font-size: 0.85rem;
    line-height: 1.25 !important;
    box-sizing: border-box;
    min-height: 27px;
    width: 100%;
    overflow: visible;
}

.hm-info-row:last-child {
    border-bottom: none;
}

.hm-icon-badge {
    width: 20px;
    height: 20px;
    background: #003B8F; /* dark royal blue */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 0.62rem;
    margin-right: 8px;
    flex-shrink: 0;
}

.hm-field-label {
    width: 92px;
    color: #00843D; /* fresh medium green */
    font-weight: 700;
    font-size: 0.82rem;
    line-height: 1.25;
    display: block;
    flex-shrink: 0;
    text-align: left;
    margin: 0;
    padding: 0;
}

.hm-field-colon {
    width: 12px;
    text-align: center;
    color: #D71920; /* deep official red */
    font-weight: 800;
    line-height: 1.25;
    display: block;
    flex-shrink: 0;
    margin-right: 6px;
    padding: 0;
}

.hm-field-value {
    color: #003B8F; /* dark royal blue */
    font-weight: 700;
    font-size: 0.86rem;
    line-height: 1.25;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
    margin: 0;
    padding: 0;
}

.hm-field-value.hm-highlight-id {
    color: #D71920; /* deep official red */
    font-family: monospace, -apple-system, sans-serif;
    font-size: 0.94rem;
    font-weight: 900;
    letter-spacing: 0.5px;
}

/* QR & Signature */
.hm-verify-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.hm-qr-box {
    width: 90px;
    height: 90px;
    border-radius: 8px;
    border: 1.5px solid #003B8F; /* dark royal blue */
    padding: 3px;
    background: #ffffff; /* clean white */
    box-shadow: 0 2px 5px rgba(0, 59, 143, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.hm-qr-box img {
    width: 100%;
    height: 100%;
    display: block;
}

.hm-sig-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.hm-sig-img {
    height: 22px;
    max-width: 92px;
    object-fit: contain;
    margin-bottom: 2px;
    display: block;
}

.hm-sig-line {
    width: 96px;
    height: 1.5px;
    background: #003B8F; /* dark royal blue */
    margin-bottom: 2px;
}

.hm-sig-text {
    font-size: 0.56rem;
    color: #003B8F; /* dark royal blue */
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    line-height: 1.3;
}

/* Front Footer */
.hm-card-footer {
    display: flex;
    align-items: stretch;
    height: 44px;
    position: relative;
    z-index: 2;
    background: transparent;
}

.hm-footer-left {
    padding: 0 20px 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #003B8F; /* dark royal blue */
    background: #ffffff; /* clean white */
    border-top: 1.5px solid #D71920; /* deep official red */
    position: relative;
    z-index: 3;
}

.hm-mini-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.hm-member-year {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.hm-mem-lbl {
    font-size: 0.68rem;
    font-weight: 800;
    color: #003B8F; /* dark royal blue */
    text-transform: uppercase;
}

.hm-mem-yr {
    font-size: 0.78rem;
    font-weight: 800;
    color: #00843D; /* fresh medium green */
}

.hm-footer-banner {
    flex-grow: 1;
    background: #003B8F; /* dark royal blue */
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 0 16px;
    border-top-left-radius: 18px;
    position: relative;
    line-height: 1.4;
}

.hm-hands-community {
    width: 18px;
    height: 18px;
    color: #ffffff;
    flex-shrink: 0;
}


/* ==========================================================================
   BACK SIDE CARD
   ========================================================================== */

.hm-cr80-back {
    background: #F8F1D8; /* warm ivory cream */
    padding: 16px 20px 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
    border: 2px solid #D71920; /* deep official red */
}

/* Back Header */
.hm-back-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #D71920; /* deep official red */
    padding-bottom: 6px;
}

.hm-back-title-wrap {
    display: flex;
    flex-direction: column;
}

.hm-back-main-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: #003B8F; /* dark royal blue */
    letter-spacing: 0.5px;
    line-height: 1.2;
}

.hm-back-sub-title {
    font-size: 0.62rem;
    font-weight: 700;
    color: #00843D; /* fresh medium green */
    letter-spacing: 0.3px;
    line-height: 1.2;
}

.hm-back-badge {
    background: #D71920; /* deep official red */
    color: #ffffff;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 6px;
    letter-spacing: 0.5px;
    line-height: 1.2;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 24px;
    box-sizing: border-box;
}

/* Back Body Details */
.hm-back-body {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 2px 0;
}

.hm-back-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 14px;
    background: #ffffff; /* clean white */
    padding: 8px 12px;
    border-radius: 10px;
    border: 1.5px solid rgba(215, 25, 32, 0.25);
    box-sizing: border-box;
    box-shadow: 0 2px 6px rgba(0, 59, 143, 0.05);
}

.hm-back-info-item {
    display: flex;
    flex-direction: column;
    line-height: 1.35;
}

.hm-back-lbl {
    font-size: 0.62rem;
    font-weight: 700;
    color: #00843D; /* fresh medium green */
    text-transform: uppercase;
    line-height: 1.3;
    display: block;
    margin-bottom: 1px;
}

.hm-back-val {
    font-size: 0.80rem;
    font-weight: 800;
    color: #003B8F; /* dark royal blue */
    line-height: 1.35;
    display: block;
    white-space: nowrap;
    overflow: visible;
}

/* Back Auth & Stamp */
.hm-back-auth-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 10px;
    border-top: 1px dashed rgba(215, 25, 32, 0.35);
    border-bottom: 1px dashed rgba(215, 25, 32, 0.35);
}

.hm-barcode-fake {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.hm-barcode-lines {
    width: 140px;
    height: 24px;
    background: repeating-linear-gradient(90deg, #003B8F 0, #003B8F 2px, transparent 2px, transparent 4px, #003B8F 4px, #003B8F 7px, transparent 7px, transparent 9px, #003B8F 9px, #003B8F 10px, transparent 10px, transparent 13px, #003B8F 13px, #003B8F 16px);
}

.hm-barcode-num {
    font-family: monospace, -apple-system, sans-serif;
    font-size: 0.72rem;
    font-weight: 800;
    color: #003B8F; /* dark royal blue */
    letter-spacing: 2px;
    line-height: 1.3;
}

.hm-seal-round {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hm-seal-round img {
    max-width: 52px;
    max-height: 52px;
    object-fit: contain;
}

/* Disclaimer */
.hm-back-disclaimer {
    font-size: 0.58rem;
    line-height: 1.4;
    color: #003B8F; /* dark royal blue */
}

.hm-back-disclaimer p {
    margin: 1px 0;
}

/* Back Footer */
.hm-back-footer {
    background: #003B8F; /* dark royal blue */
    color: #ffffff;
    border-radius: 6px;
    padding: 6px 10px;
    text-align: center;
}

.hm-back-footer-links {
    font-size: 0.65rem;
    font-weight: 600;
    display: flex;
    justify-content: center;
    gap: 8px;
    color: #ffffff;
    line-height: 1.3;
}

/* ==========================================================================
   Responsive Scaling for Mobile & Tablet Touchscreens
   ========================================================================== */

@media (max-width: 768px) {
    .hm-dual-card-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 1.5rem;
        padding: 0.5rem 0;
    }
}

/* ==========================================================================
   Print Dual-Side A4 Layout (Side-by-Side Front + Back on PVC/Paper)
   ========================================================================== */

@media print {
    @page {
        size: A4 portrait;
        margin: 10mm;
    }
    body, .print-card-section, .hm-dual-card-container, .hm-cr80-card {
        background: #ffffff !important;
        margin: 0 !important;
        padding: 0 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
    
    /* Hide everything by default when printing card */
    body:not(.print-mode-cert) * {
        visibility: hidden;
    }

    /* Keep active card container visible */
    body:not(.print-mode-cert) .print-card-section,
    body:not(.print-mode-cert) .print-card-section *,
    body.print-mode-card .print-card-target,
    body.print-mode-card .print-card-target *,
    body:not(.print-mode-cert) .modal-overlay.active .hm-dual-card-container,
    body:not(.print-mode-cert) .modal-overlay.active .hm-dual-card-container * {
        visibility: visible !important;
    }

    /* Hide inactive modal cards so they don't stack */
    .modal-overlay:not(.active) .hm-dual-card-container,
    .modal-overlay:not(.active) .hm-dual-card-container * {
        display: none !important;
        visibility: hidden !important;
    }

    body:not(.print-mode-cert) .print-card-section,
    body.print-mode-card .print-card-target,
    body:not(.print-mode-cert) .modal-overlay.active .modal-body {
        position: fixed !important;
        top: 15mm !important;
        left: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        justify-content: center !important;
        background: #ffffff !important;
    }

    .hm-dual-card-container {
        display: flex !important;
        flex-direction: row !important;
        justify-content: center !important;
        align-items: flex-start !important;
        gap: 12mm !important;
        margin: 0 auto !important;
        padding: 0 !important;
        background: #ffffff !important;
        transform: scale(0.52) !important;
        transform-origin: top center !important;
    }

    .hm-cr80-card {
        width: 640px !important;
        height: 404px !important;
        box-shadow: none !important;
        border: 1.5px solid #D71920 !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        background: #F8F1D8 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .no-print, header, footer, .admin-sidebar, .admin-topbar, .btn {
        display: none !important;
    }
}
