/* HG Connect — reusable Create Profile / Save Contact modal.
   Single CSS owner for modal opened by public-profile.js from Public Profile, Save Contact, or Boost Traction.
   No layout or palette values are set by the JS constructor. */
#hg-save-contact-profile-modal {
    position:fixed; inset:0; z-index:9999999;
    display:flex; align-items:center; justify-content:center;
    padding:14px; box-sizing:border-box;
}
#hg-save-contact-profile-modal .hg-modal-overlay {
    position:fixed; inset:0; background:rgba(0,0,0,.6);
    z-index:0; cursor:pointer;
}
#hg-save-contact-profile-modal .hg-modal-content {
    position:relative; z-index:1; box-sizing:border-box;
    background:#fff; border-radius:12px;
    width:90%; max-width:640px; min-width:0;
    max-height:90vh; overflow:auto;
    box-shadow:0 20px 60px rgba(0,0,0,.3);
    animation:hg-modal-slide .3s ease; padding:0;
}
#hg-save-contact-profile-modal .hg-modal-header {
    display:flex; justify-content:space-between; align-items:center;
    padding:20px 25px; border-bottom:2px solid #f0f0f0;
    background:#f8f9fa; border-radius:12px 12px 0 0;
}
#hg-save-contact-profile-modal .hg-modal-header h2 {
    margin:0; color:#001d6e; font-size:20px;
}
#hg-save-contact-profile-modal .hg-modal-close {
    font-size:28px; font-weight:300; cursor:pointer;
    color:#6c757d; line-height:1;
}
#hg-save-contact-profile-modal .hg-modal-close:hover { color:#dc3232; }
#hg-save-contact-profile-modal .hg-modal-body { padding:25px; }
#hg-save-contact-profile-modal .hg-profile-single-submit .hg-submit-btn {
    width:100%; justify-content:center;
}
#hg-save-contact-loading {
    position:fixed; inset:0; z-index:9999998; display:flex;
    align-items:center; justify-content:center;
    padding:16px; box-sizing:border-box;
    background:rgba(0,0,0,.5); backdrop-filter:blur(4px);
}
#hg-save-contact-loading .hg-profile-loading-card {
    background:#fff; padding:30px 40px; border-radius:12px;
    text-align:center; max-width:400px; width:100%; box-sizing:border-box;
}
#hg-save-contact-loading .hg-profile-loading-icon { font-size:32px; margin-bottom:12px; }
#hg-save-contact-loading .hg-profile-loading-title { margin:0 0 8px; color:#001d6e; }
#hg-save-contact-loading .hg-profile-loading-text { margin:0; color:#6c757d; font-size:14px; }
@media (max-width:768px) {
    #hg-save-contact-profile-modal { padding:9.5px; }
    #hg-save-contact-profile-modal .hg-modal-content {
        width:100%; max-width:100%; max-height:calc(100dvh - 19px);
        box-sizing:border-box;
    }
}

/* ============================================================
   SAVE CONTACT PROFILE MODAL - ALL BREAKPOINTS
   ============================================================ */

/* --- KEYFRAMES --- */
@keyframes hg-save-contact-slide-up {
    from {
        transform: translateY(30px) scale(0.98);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* --- MOBILE (max-width: 768px) --- */
@media (max-width: 768px) {

    #hg-save-contact-profile-modal {
        padding: 9.5px;
        align-items: center;
    }

    #hg-save-contact-profile-modal .hg-modal-content {
        border-radius: 12px;
        margin: 0 auto;
        animation: hg-save-contact-slide-up 0.35s ease;
    }

    #hg-save-contact-profile-modal .hg-modal-header {
        padding: 14px 18px;
        border-radius: 12px;
        background: #f8f9fa;
        border-bottom: 2px solid #f0f0f0;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    #hg-save-contact-profile-modal .hg-modal-header h2 {
        font-size: 17px;
        font-weight: 700;
    }

    #hg-save-contact-profile-modal .hg-modal-close {
        font-size: 26px;
    }

    #hg-save-contact-profile-modal .hg-modal-body {
        padding: 18px 16px 24px;
        -webkit-overflow-scrolling: touch;
    }

    #hg-save-contact-profile-modal .hg-form-group {
        margin-bottom: 14px;
    }

    #hg-save-contact-profile-modal .hg-form-group label {
        font-size: 13px;
        font-weight: 600;
        margin-bottom: 4px;
    }

    #hg-save-contact-profile-modal .hg-input,
    #hg-save-contact-profile-modal .hg-select,
    #hg-save-contact-profile-modal .hg-textarea {
        padding: 10px 14px;
        font-size: 15px;
        border-radius: 8px;
        border: 2px solid #d9e6f8;
        background: #ffffff;
        -webkit-appearance: none;
        appearance: none;
    }

    #hg-save-contact-profile-modal .hg-select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23001d6e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 14px center;
        padding-right: 40px;
    }

    #hg-save-contact-profile-modal .hg-phone-row > div {
        display: grid;
        grid-template-columns: 1fr;
    }

    #hg-save-contact-profile-modal .hg-phone-code-select {
        font-size: 14px;
    }

    #hg-save-contact-profile-modal .hg-phone-field {
        font-size: 15px;
    }

    #hg-save-contact-profile-modal .hg-remove-phone-row {
        width: 100%;
        font-size: 16px;
        background: #f8d7da;
        border: 1px solid #f5c6cb;
        border-radius: 6px;
    }

    #hg-save-contact-profile-modal .hg-add-phone-row {
        padding: 10px;
        font-size: 13px;
        background: #e8f0fe;
        border: 2px dashed #d9e6f8;
        border-radius: 8px;
        font-weight: 600;
        transition: all 0.2s ease;
    }

    #hg-save-contact-profile-modal .hg-add-phone-row:active {
        transform: scale(0.97);
    }

    #hg-save-contact-profile-modal .hg-profile-name-grid {
        grid-template-columns: 1fr;
    }

    #hg-save-contact-profile-modal input[type="checkbox"] {
        margin-right: 10px;
    }

    #hg-save-contact-profile-modal .hg-form-group label.hg-consent-label {
        font-size: 13px;
    }

    #hg-save-contact-profile-modal .hg-modal-actions {
        display: flex;
        flex-direction: column;
        margin-top: 22px;
        padding-top: 18px;
        border-top: 2px solid #f0f0f0;
    }

    #hg-save-contact-profile-modal .hg-modal-actions .hg-button,
    #hg-save-contact-profile-modal .hg-modal-actions .button {
        width: 100%;
        font-size: 15px;
        font-weight: 700;
        border-radius: 10px;
        padding: 0 16px;
        border: 2px solid transparent;
        transition: all 0.2s ease;
        text-align: center;
        display: inline-flex;
    }

    #hg-save-contact-profile-modal .hg-submit-btn {
        background: #001d6e;
        border-color: #001d6e;
    }

    #hg-save-contact-profile-modal .hg-submit-btn:active {
        transform: scale(0.97);
        background: #002a8a;
        border-color: #002a8a;
    }

    #hg-save-contact-profile-modal .hg-modal-close-btn,
    #hg-save-contact-profile-modal .hg-button-secondary {
        background: #fee2c5;
        border-color: #fee2c5;
    }

    #hg-save-contact-profile-modal .hg-modal-close-btn:active,
    #hg-save-contact-profile-modal .hg-button-secondary:active {
        transform: scale(0.97);
        background: #fdd6b0;
        border-color: #fdd6b0;
    }

    #hg-save-contact-loading {
        padding: 16px;
    }

    #hg-save-contact-loading .hg-profile-loading-card {
        width: 100%;
        padding: 24px 20px;
        margin: 0;
    }

    #hg-save-contact-profile-modal .hg-save-contact-flow-info {
        padding: 12px 14px;
        font-size: 13px;
        border-radius: 8px;
        margin-bottom: 14px;
    }

    #hg-save-contact-profile-modal .hg-save-contact-flow-info p {
        font-size: 13px;
    }

    #hg-save-contact-profile-modal .hg-community-summary {
        padding: 10px 14px;
        font-size: 13px;
        border-radius: 8px;
        margin-bottom: 14px;
    }

    #hg-save-contact-profile-modal .hg-community-summary p {
        font-size: 13px;
    }

    #hg-save-contact-profile-modal .hg-small {
        font-size: 12px;
        margin-top: 4px;
    }

}

/* --- VERY SMALL PHONE (max-width: 380px) --- */
@media (max-width: 380px) {

    #hg-save-contact-profile-modal .hg-modal-content {
        border-radius: 12px;
    }

    #hg-save-contact-profile-modal .hg-modal-header {
        padding: 12px 14px;
    }

    #hg-save-contact-profile-modal .hg-modal-header h2 {
        font-size: 15px;
    }

    #hg-save-contact-profile-modal .hg-modal-body {
        padding: 14px 12px 20px;
    }

    #hg-save-contact-profile-modal .hg-input,
    #hg-save-contact-profile-modal .hg-select {
        font-size: 14px;
        padding: 8px 12px;
    }

    #hg-save-contact-profile-modal .hg-modal-actions {
        margin-top: 18px;
        padding-top: 14px;
    }

    #hg-save-contact-profile-modal .hg-modal-actions .hg-button,
    #hg-save-contact-profile-modal .hg-modal-actions .button {
        font-size: 14px;
    }
}

/* --- LANDSCAPE PHONE (max-height: 500px) --- */
@media (max-height: 500px) and (orientation: landscape) {

    #hg-save-contact-profile-modal .hg-modal-content {
        max-height: 96vh;
        border-radius: 12px;
    }

    #hg-save-contact-profile-modal .hg-modal-body {
        padding: 12px 16px 16px;
    }

    #hg-save-contact-profile-modal .hg-form-group {
        margin-bottom: 8px;
    }

    #hg-save-contact-profile-modal .hg-input,
    #hg-save-contact-profile-modal .hg-select {
        height: 34px;
        min-height: 34px;
        padding: 6px 10px;
        font-size: 13px;
    }

    #hg-save-contact-profile-modal .hg-modal-actions {
        margin-top: 12px;
        padding-top: 10px;
    }

    #hg-save-contact-profile-modal .hg-modal-actions .hg-button,
    #hg-save-contact-profile-modal .hg-modal-actions .button {
        font-size: 13px;
    }

    #hg-save-contact-profile-modal .hg-modal-header {
        padding: 10px 14px;
    }

    #hg-save-contact-profile-modal .hg-modal-header h2 {
        font-size: 15px;
    }
}

/* --- TABLET (min-width: 769px) to (max-width: 1024px) --- */
@media (min-width: 769px) and (max-width: 1024px) {

    #hg-save-contact-profile-modal .hg-modal-body {
        padding: 24px;
    }

    #hg-save-contact-profile-modal .hg-modal-actions {
        flex-direction: row;
    }

    #hg-save-contact-profile-modal .hg-modal-actions .hg-button,
    #hg-save-contact-profile-modal .hg-modal-actions .button {
        flex: 1;
        border: 2px solid transparent;
    }

    #hg-save-contact-profile-modal .hg-submit-btn {
        border-color: #001d6e;
    }

    #hg-save-contact-profile-modal .hg-modal-close-btn,
    #hg-save-contact-profile-modal .hg-button-secondary {
        border-color: #fee2c5;
    }
}

/* --- DESKTOP / LAPTOP (min-width: 1025px) --- */
@media (min-width: 1025px) {

    #hg-save-contact-profile-modal .hg-modal-content {
        width: 92%;
        border-radius: 16px;
        box-shadow: 0 25px 80px rgba(0, 29, 110, 0.25);
        border: none;
        overflow: hidden;
    }

    #hg-save-contact-profile-modal .hg-modal-header {
        padding: 22px 28px;
        background: #f8f9fa;
        border-bottom: 2px solid #f0f0f0;
        border-radius: 12px;
    }

    #hg-save-contact-profile-modal .hg-modal-header h2 {
        font-size: 20px;
        color: #001d6e;
        font-weight: 700;
        margin: 0;
    }

    #hg-save-contact-profile-modal .hg-modal-close {
        color: #6c757d;
        font-size: 28px;
        cursor: pointer;
        transition: color 0.3s ease;
        line-height: 1;
        background: none;
        border: none;
        padding: 0;
    }

    #hg-save-contact-profile-modal .hg-modal-close:hover {
        color: #dc3232;
    }

    #hg-save-contact-profile-modal .hg-modal-body {
        padding: 28px 30px 32px;
        max-height: 80vh;
        overflow-y: auto;
    }

    #hg-save-contact-profile-modal .hg-form-group {
        margin-bottom: 18px;
    }

    #hg-save-contact-profile-modal .hg-form-group label {
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 5px;
        color: #001d6e;
        display: block;
    }

    #hg-save-contact-profile-modal .hg-input,
    #hg-save-contact-profile-modal .hg-select,
    #hg-save-contact-profile-modal .hg-textarea {
        width: 100%;
        height: 44px;
        min-height: 44px;
        padding: 10px 14px;
        font-size: 14px;
        border-radius: 8px;
        border: 2px solid #d9e6f8;
        background: #ffffff;
        box-sizing: border-box;
        transition: border-color 0.3s ease;
        font-family: 'Montserrat', sans-serif;
    }

    #hg-save-contact-profile-modal .hg-input:focus,
    #hg-save-contact-profile-modal .hg-select:focus,
    #hg-save-contact-profile-modal .hg-textarea:focus {
        border-color: #001d6e;
        outline: none;
        box-shadow: 0 0 0 3px rgba(0, 29, 110, 0.08);
    }

    #hg-save-contact-profile-modal .hg-textarea {
        height: auto;
        min-height: 90px;
        resize: vertical;
    }

    #hg-save-contact-profile-modal .hg-select {
        -webkit-appearance: none;
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23001d6e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 14px center;
        padding-right: 40px;
        cursor: pointer;
    }

    #hg-save-contact-profile-modal .hg-profile-name-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 14px;
    }

    #hg-save-contact-profile-modal .hg-phone-row > div {
        display: grid;
        grid-template-columns: 100px 1fr 90px auto;
        gap: 8px;
        align-items: center;
    }

    #hg-save-contact-profile-modal .hg-phone-code-select {
        height: 42px;
        min-height: 42px;
        padding: 8px 12px;
        font-size: 13px;
        border-radius: 6px;
        border: 2px solid #d9e6f8;
        background: #ffffff;
    }

    #hg-save-contact-profile-modal .hg-phone-field {
        height: 42px;
        min-height: 42px;
        padding: 8px 12px;
        font-size: 14px;
        border-radius: 6px;
        border: 2px solid #d9e6f8;
        background: #ffffff;
    }

    #hg-save-contact-profile-modal .hg-remove-phone-row {
        height: 42px;
        min-height: 42px;
        min-width: 42px;
        padding: 0;
        font-size: 18px;
        line-height: 1;
        background: #f8d7da;
        color: #721c24;
        border: 1px solid #f5c6cb;
        border-radius: 6px;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    #hg-save-contact-profile-modal .hg-remove-phone-row:hover {
        background: #f5c6cb;
    }

    #hg-save-contact-profile-modal .hg-add-phone-row {
        padding: 8px 16px;
        font-size: 13px;
        font-weight: 600;
        background: #e8f0fe;
        color: #001d6e;
        border: 2px dashed #d9e6f8;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s ease;
        margin-top: 8px;
        width: auto;
    }

    #hg-save-contact-profile-modal .hg-add-phone-row:hover {
        background: #d4e4f7;
        border-color: #7fb5ff;
    }

    #hg-save-contact-profile-modal input[type="checkbox"] {
        width: 18px;
        height: 18px;
        min-width: 18px;
        margin-right: 10px;
        accent-color: #001d6e;
        cursor: pointer;
    }

    #hg-save-contact-profile-modal .hg-form-group label.hg-consent-label {
        display: flex;
        align-items: center;
        gap: 8px;
        cursor: pointer;
        font-size: 14px;
        font-weight: normal;
    }

    #hg-save-contact-profile-modal .hg-modal-actions {
        display: flex;
        flex-direction: row;
        gap: 12px;
        margin-top: 24px;
        padding-top: 20px;
        border-top: 2px solid #f0f0f0;
        justify-content: flex-end;
    }

    #hg-save-contact-profile-modal .hg-modal-actions .hg-button,
    #hg-save-contact-profile-modal .hg-modal-actions .button {
        padding: 0 28px;
        font-size: 15px;
        font-weight: 700;
        border-radius: 10px;
        justify-content: center;
        box-sizing: border-box;
        border: 2px solid transparent;
        cursor: pointer;
        transition: all 0.2s ease;
        display: inline-flex;
        align-items: center;
        min-width: 140px;
    }

    #hg-save-contact-profile-modal .hg-submit-btn {
        background: #001d6e;
        color: #ffffff;
        border-color: #001d6e;
    }

    #hg-save-contact-profile-modal .hg-submit-btn:hover {
        background: #002a8a;
        border-color: #002a8a;
        transform: translateY(-2px);
        box-shadow: 0 4px 16px rgba(0, 29, 110, 0.3);
    }

    #hg-save-contact-profile-modal .hg-modal-close-btn,
    #hg-save-contact-profile-modal .hg-button-secondary {
        background: #fee2c5;
        color: #001d6e;
        border-color: #fee2c5;
    }

    #hg-save-contact-profile-modal .hg-modal-close-btn:hover,
    #hg-save-contact-profile-modal .hg-button-secondary:hover {
        background: #fdd6b0;
        border-color: #fdd6b0;
        transform: translateY(-2px);
        box-shadow: 0 4px 16px rgba(254, 226, 197, 0.4);
    }

    #hg-save-contact-profile-modal .hg-save-contact-flow-info {
        padding: 14px 18px;
        font-size: 14px;
        border-radius: 8px;
        margin-bottom: 16px;
        background: #e8f4fd;
        border-left: 4px solid #001d6e;
    }

    #hg-save-contact-profile-modal .hg-save-contact-flow-info p {
        margin: 0;
        color: #001d6e;
        font-size: 14px;
        line-height: 1.5;
    }

    #hg-save-contact-profile-modal .hg-community-summary {
        padding: 12px 16px;
        font-size: 14px;
        border-radius: 8px;
        margin-bottom: 16px;
        
    }

    #hg-save-contact-profile-modal .hg-community-summary p {
        margin: 0;
        color: #001d6e;
        font-size: 14px;
        line-height: 1.5;
    }

    #hg-save-contact-profile-modal .hg-small {
        display: block;
        margin-top: 4px;
        font-size: 12px;
        color: #6c757d;
        line-height: 1.4;
    }

    #hg-save-contact-profile-modal .hg-phone-warning {
        display: none;
        color: #dc3232;
        font-size: 12px;
        margin-top: 4px;
        font-weight: 500;
    }

    #hg-save-contact-profile-modal .hg-phone-warning:not(:empty) {
        display: block;
    }

    #hg-save-contact-loading .hg-profile-loading-card {
        max-width: 400px;
        padding: 30px 40px;
        border-radius: 16px;
    }
}

/* --- LARGE DESKTOP (min-width: 1200px) --- */
@media (min-width: 1200px) {

    #hg-save-contact-profile-modal .hg-modal-content {
        max-width: 680px;
    }

    #hg-save-contact-profile-modal .hg-modal-body {
        padding: 32px 36px 36px;
    }

    #hg-save-contact-profile-modal .hg-modal-actions .hg-button,
    #hg-save-contact-profile-modal .hg-modal-actions .button {
        min-height: 50px;
        height: 50px;
        padding: 0 32px;
        font-size: 16px;
    }
}


/* State-colored public feedback modal: no static CSS assembled by JavaScript. */
#hg-public-message-overlay.hg-public-message {
    position:fixed; inset:0; z-index:9999999; display:flex; align-items:center; justify-content:center;
    background:rgba(0,0,0,.55); backdrop-filter:blur(4px); padding:14px; box-sizing:border-box;
}
#hg-public-message-overlay .hg-public-message-card {
    background:#fff; border-radius:16px; max-width:480px; width:100%;
    padding:30px 28px; box-shadow:0 20px 60px rgba(0,0,0,.25);
    text-align:center; position:relative; animation:hg-modal-slide .3s ease;
}
#hg-public-message-overlay .hg-public-message-icon { font-size:48px; margin-bottom:12px; }
#hg-public-message-overlay .hg-public-message-title { margin:0 0 8px; color:#001d6e; font-size:20px; }
#hg-public-message-overlay .hg-public-message-text { margin:0 0 20px; color:#5f6f89; font-size:14px; line-height:1.6; }
#hg-public-message-overlay #hg-public-message-close {
    border:0; padding:10px 30px; border-radius:8px; font-size:15px; font-weight:600;
    cursor:pointer; transition:all .2s ease; min-width:120px;
}
#hg-public-message-overlay.hg-public-message--success #hg-public-message-close { background:#28a745; color:#155724; }
#hg-public-message-overlay.hg-public-message--error #hg-public-message-close { background:#dc3545; color:#721c24; }
#hg-public-message-overlay.hg-public-message--warning #hg-public-message-close { background:#ffc107; color:#856404; }
#hg-public-message-overlay.hg-public-message--info #hg-public-message-close { background:#17a2b8; color:#0c5460; }
@media (max-width:768px) {
    #hg-public-message-overlay.hg-public-message { padding:9.5px; }
}

/* PATCH034 — Save Contact profile modal: one close control (header X), centered
   with the same 9.5px viewport gutter on desktop and mobile.  Restrict this
   to the Save Contact modal; other shared profile dialogs keep their layout. */
#hg-save-contact-profile-modal {
    display:flex;
    align-items:center;
    justify-content:center;
    padding:9.5px;
}
#hg-save-contact-profile-modal > .hg-modal-content {
    box-sizing:border-box;
    display:flex;
    flex-direction:column;
    width:calc(100vw - 19px);
    max-width:calc(100vw - 19px);
    max-height:calc(100vh - 19px);
    max-height:calc(100dvh - 19px);
    margin:auto;
    overflow:hidden;
}
#hg-save-contact-profile-modal > .hg-modal-content > .hg-modal-body {
    flex:1 1 auto;
    min-height:0;
    max-height:none;
    overflow-y:auto;
    overscroll-behavior:contain;
}
