/* ==========================================================================
   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: #ffffff;
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 16px 36px -8px rgba(11, 61, 145, 0.22), 0 0 1px 1px rgba(11, 61, 145, 0.12);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
    border: 1px solid #cbd5e1;
    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: #7CB342;
    flex-shrink: 0;
}

/* Front Header */
.hm-card-header {
    padding: 16px 24px 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 2;
}

.hm-brand-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 400px;
}

.hm-brand-logo {
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.hm-brand-logo img, .hm-brand-logo svg {
    max-width: 46px;
    max-height: 46px;
    object-fit: contain;
}

.hm-brand-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Help Madhes Title - Clear vertical clearance from the green line */
.hm-org-name {
    font-size: 1.65rem;
    font-weight: 900;
    color: #0B3D91;
    line-height: 1.15;
    letter-spacing: -0.3px;
    display: block;
    margin: 0 0 2px;
    padding: 0;
}

/* Separate Green Divider Line with explicit margin so it never cuts into letters */
.hm-header-divider-line {
    width: 100%;
    height: 2.5px;
    background: #7CB342;
    border-radius: 2px;
    margin: 4px 0 5px;
    display: block;
}

.hm-org-tagline {
    font-size: 0.68rem;
    color: #7CB342;
    font-weight: 700;
    letter-spacing: 0.1px;
    line-height: 1.25;
    white-space: nowrap;
    display: block;
}

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

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

.hm-photo-frame {
    width: 120px;
    height: 148px;
    border-radius: 16px;
    border: 2.5px solid #0B3D91;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(11, 61, 145, 0.15);
    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: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    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: #0B3D91;
    background: #ffffff;
    padding: 2px 10px;
    border-radius: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Details Rows with precision mathematical alignment & zero vertical clipping */
.hm-info-col {
    display: flex;
    flex-direction: column;
    border-top: 1px solid #e2e8f0;
    width: 100%;
    overflow: visible;
}

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

.hm-icon-badge {
    width: 20px;
    height: 20px;
    background: #0B3D91;
    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: #334155;
    font-weight: 600;
    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: #64748b;
    font-weight: 800;
    line-height: 1.25;
    display: block;
    flex-shrink: 0;
    margin-right: 6px;
    padding: 0;
}

.hm-field-value {
    color: #0B3D91;
    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 {
    font-family: monospace, -apple-system, sans-serif;
    font-size: 0.94rem;
    font-weight: 800;
    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 #0B3D91;
    padding: 3px;
    background: #ffffff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.06);
    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: #0B3D91;
    margin-bottom: 2px;
}

.hm-sig-text {
    font-size: 0.56rem;
    color: #0B3D91;
    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: #0B3D91;
    background: #ffffff;
    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: #0B3D91;
    text-transform: uppercase;
}

.hm-mem-yr {
    font-size: 0.78rem;
    font-weight: 800;
    color: #7CB342;
}

.hm-footer-banner {
    flex-grow: 1;
    background: #0B3D91;
    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: radial-gradient(circle at center, #ffffff 60%, #f8fafc 100%);
    padding: 16px 20px 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
}

/* Back Header */
.hm-back-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2.5px solid #0B3D91;
    padding-bottom: 6px;
}

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

.hm-back-main-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: #0B3D91;
    letter-spacing: 0.5px;
    line-height: 1.2;
}

.hm-back-sub-title {
    font-size: 0.62rem;
    font-weight: 700;
    color: #7CB342;
    letter-spacing: 0.3px;
    line-height: 1.2;
}

.hm-back-badge {
    background: #0B3D91;
    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: #f8fafc;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1.5px solid #e2e8f0;
    box-sizing: border-box;
}

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

.hm-back-lbl {
    font-size: 0.62rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    line-height: 1.3;
    display: block;
    margin-bottom: 1px;
}

.hm-back-val {
    font-size: 0.80rem;
    font-weight: 800;
    color: #0B3D91;
    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 #cbd5e1;
    border-bottom: 1px dashed #cbd5e1;
}

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

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

.hm-barcode-num {
    font-family: monospace, -apple-system, sans-serif;
    font-size: 0.72rem;
    font-weight: 800;
    color: #0B3D91;
    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: #475569;
}

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

/* Back Footer */
.hm-back-footer {
    background: #0B3D91;
    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;
}

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

@media print {
    @page {
        size: A4 portrait;
        margin: 10mm;
    }
    body {
        background: #ffffff !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    body * {
        visibility: hidden !important;
    }
    .hm-dual-card-container, .hm-dual-card-container * {
        visibility: visible !important;
    }
    .hm-dual-card-container {
        position: absolute !important;
        top: 20mm !important;
        left: 50% !important;
        transform: translateX(-50%) scale(0.50) !important;
        transform-origin: top center !important;
        width: 1350px !important;
        display: flex !important;
        flex-direction: row !important;
        justify-content: center !important;
        align-items: flex-start !important;
        gap: 30px !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
    }
    .hm-cr80-card {
        width: 640px !important;
        height: 404px !important;
        box-shadow: none !important;
        border: 1.5px solid #94a3b8 !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
    .no-print, header, footer, .admin-sidebar, .admin-topbar, .btn {
        display: none !important;
    }
}
