/* ==========================================================================
   Genealogic Contacts Feature Styles
   Snippets 40 (Contacts CRM), 42 (Inquiry Form), 50 (Pro Overlay)
   Unified SaaS Design v6.0
   ========================================================================== */

:root {
    --glp-brand: #D74709;
    --glp-brand-light: #ff7b3a;
    --glp-text: #1a1a2e;
    --glp-text-muted: #8492a6;
    --glp-border: #e8ecf1;
    --glp-bg: #f8f9fb;
    --glp-card: #ffffff;
    --glp-radius: 10px;
    --glp-shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --glp-shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --glp-shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
}

/* ==========================================================================
   SNIPPET 40: Contacts CRM Page ([genealogic_contacts])
   ========================================================================== */

/* --- Layout & Header --- */
.genealogic-crm-page {
    font-family: "Plus Jakarta Sans", -apple-system, sans-serif;
    background: transparent;
    padding: 0;
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

.crm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--glp-border);
}

.crm-header h2 {
    margin: 0;
    font-size: 22px;
    color: var(--glp-text);
    font-weight: 700;
}

.glp-btn-main {
    background-color: var(--glp-brand) !important;
    color: #fff !important;
    padding: 10px 22px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    border: none;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
}

.glp-btn-main:hover {
    background-color: #c03d06 !important;
    color: #fff !important;
    box-shadow: var(--glp-shadow-sm);
}

/* --- Toolbar: Search & Bulk Actions --- */
.crm-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 16px;
}

.crm-search-box {
    flex: 1;
    max-width: 400px;
    display: flex;
    align-items: center;
    background: var(--glp-card);
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--glp-border);
    transition: all 0.15s;
}

.crm-search-box:focus-within {
    border-color: var(--glp-brand);
    box-shadow: 0 0 0 3px rgba(215, 71, 9, 0.08);
}

.crm-search-box i {
    color: var(--glp-text-muted);
    margin-right: 10px;
    font-size: 13px;
}

.crm-search-box input {
    border: none;
    background: transparent;
    width: 100%;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    color: var(--glp-text);
    padding: 0;
}

.crm-bulk-actions {
    display: none;
    align-items: center;
    gap: 8px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to   { opacity: 1; transform: translateY(0); }
}

.bulk-count {
    font-weight: 700;
    color: var(--glp-brand);
    font-size: 12px;
    background: rgba(215, 71, 9, 0.08);
    padding: 5px 12px;
    border-radius: 20px;
}

.btn-bulk-action {
    background: var(--glp-bg);
    border: 1px solid var(--glp-border);
    padding: 7px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    color: var(--glp-text-muted);
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-family: inherit;
}

.btn-bulk-action:hover {
    background: var(--glp-card);
    color: var(--glp-text);
    border-color: #d0d5dd;
}

.btn-bulk-delete {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.06);
    border-color: rgba(239, 68, 68, 0.15);
}

.btn-bulk-delete:hover {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
}

/* --- Contact Cards Grid --- */
.crm-contacts-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.crm-contact-card {
    background: var(--glp-card);
    border: 1px solid var(--glp-border);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.15s;
    position: relative;
}

.crm-contact-card:hover {
    border-color: #d0d5dd;
    box-shadow: var(--glp-shadow-sm);
}

.crm-contact-card.selected {
    border-color: var(--glp-brand);
    background: rgba(215, 71, 9, 0.02);
}

.contact-selector {
    margin-right: 16px;
    flex-shrink: 0;
    cursor: pointer;
}

.contact-selector-box {
    width: 20px;
    height: 20px;
    border: 2px solid var(--glp-border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    color: white;
}

.crm-contact-card.selected .contact-selector-box {
    background: var(--glp-brand);
    border-color: var(--glp-brand);
}

/* Avatar wrapper — fixed-size box so Elementor/flex can't stretch it */
.contact-avatar-wrap {
    width: 44px;
    height: 44px;
    min-width: 44px;
    max-width: 44px;
    min-height: 44px;
    max-height: 44px;
    margin-right: 16px;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 12px;
    border: 2px solid var(--glp-border);
}

.contact-avatar-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.contact-info-main {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    overflow: hidden;
}

.contact-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--glp-text);
    margin: 0;
}

.contact-details {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    font-size: 13px;
    color: var(--glp-text-muted);
}

.contact-details span {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-details i {
    color: var(--glp-text-muted);
    font-size: 12px;
}

.contact-source-badge {
    background: var(--glp-bg);
    color: var(--glp-text-muted);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid var(--glp-border);
}

.contact-location-badge {
    display: flex !important;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--glp-text-muted);
}

.contact-location-badge .flag-emoji {
    font-size: 16px;
    line-height: 1;
}

.edit-contact-btn {
    background: var(--glp-bg);
    color: var(--glp-text);
    border: 1px solid var(--glp-border);
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    flex-shrink: 0;
    font-family: inherit;
}

.edit-contact-btn:hover {
    background: var(--glp-card);
    border-color: #d0d5dd;
    box-shadow: var(--glp-shadow-sm);
}

/* --- Side Panel (Edit / Add Contact) --- */
#contact-side-panel-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    z-index: 10000;
    backdrop-filter: blur(4px);
}

#contact-side-panel {
    display: none;
    position: fixed;
    top: 0;
    right: -560px;
    width: 100%;
    max-width: 500px;
    height: 100%;
    background: var(--glp-card);
    box-shadow: -8px 0 40px rgba(0,0,0,0.08);
    z-index: 10001;
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    flex-direction: column;
}

#contact-side-panel.is-open {
    right: 0;
    display: flex;
}

.panel-header {
    padding: 20px 28px;
    border-bottom: 1px solid var(--glp-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--glp-card);
    z-index: 10;
    flex-shrink: 0;
}

.panel-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--glp-text);
}

.panel-header .close-panel-btn {
    background: transparent !important;
    color: var(--glp-text-muted);
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: all 0.15s;
    outline: none;
    box-shadow: none;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.panel-header .close-panel-btn:hover {
    color: var(--glp-text);
    background: var(--glp-bg) !important;
}

.panel-body {
    padding: 24px 28px;
    overflow-y: auto;
    flex: 1;
    position: relative;
    background: var(--glp-bg);
}

/* Profile Banner in Side Panel */
.contact-profile-banner {
    margin: -24px -28px 20px -28px;
    height: 150px;
    position: relative;
    background: var(--glp-bg);
    overflow: hidden;
    display: none;
}

.contact-profile-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    filter: blur(10px);
    opacity: 0.5;
    z-index: 1;
}

.contact-profile-content {
    position: relative;
    z-index: 2;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(215, 71, 9, 0.3);
}

.contact-profile-image {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 3px solid var(--glp-card);
    box-shadow: var(--glp-shadow-md);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    background: var(--glp-card);
}

.contact-profile-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-icon-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.camera-icon-overlay i {
    color: #fff;
    font-size: 22px;
}

.contact-profile-image:hover .camera-icon-overlay {
    opacity: 1;
}

.upload-progress-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 50%;
}

.loading-bar-inner {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background-color: var(--glp-brand);
    transition: height 0.3s ease;
}

.loading-percentage {
    position: relative;
    color: #fff;
    font-weight: 700;
    z-index: 11;
    font-size: 12px;
}

/* Panel Form */
.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.panel-form .form-group {
    margin-bottom: 18px;
}

.panel-form .form-group label {
    display: block;
    margin-bottom: 7px;
    font-weight: 600;
    font-size: 13px;
    color: var(--glp-text);
    letter-spacing: 0.1px;
}

.panel-form .form-group input[type="text"],
.panel-form .form-group input[type="email"],
.panel-form .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--glp-border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
    outline: none;
    transition: all 0.15s;
    background: var(--glp-card);
    color: var(--glp-text);
}

.panel-form .form-group input:focus,
.panel-form .form-group textarea:focus {
    border-color: var(--glp-brand);
    outline: none;
    box-shadow: 0 0 0 3px rgba(215, 71, 9, 0.08);
}

.panel-form .form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.panel-footer {
    padding: 16px 28px;
    border-top: 1px solid var(--glp-border);
    background: var(--glp-card);
    display: flex;
    justify-content: flex-end;
    z-index: 10;
    flex-shrink: 0;
    gap: 12px;
}

#contact-form-message {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: 8px;
    display: none;
    font-weight: 500;
    font-size: 13px;
    text-align: center;
}

#contact-form-message.success {
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.2);
    color: #16a34a;
}

#contact-form-message.error {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #dc2626;
}

/* Deals Section in Panel */
.panel-deals-section {
    display: none;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--glp-border);
}

.panel-deals-section h4 {
    margin: 0 0 16px 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--glp-text);
}

.deals-list {
    list-style: none;
    padding: 0;
    margin: 0 0 16px 0;
}

.deals-list li {
    padding: 12px 14px;
    background: var(--glp-card);
    border: 1px solid var(--glp-border);
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.deals-list li a {
    font-weight: 600;
    color: var(--glp-text);
    text-decoration: none;
    font-size: 13px;
    display: block;
    margin-bottom: 2px;
}

.deals-list li a:hover {
    color: var(--glp-brand);
}

.deals-list li .deal-stage {
    font-size: 12px;
    color: var(--glp-brand);
    font-weight: 500;
}

.deals-list .no-deals {
    font-size: 13px;
    color: var(--glp-text-muted);
    background: transparent;
    border: none;
    padding: 0;
}

#create-new-deal-btn {
    background: transparent;
    border: 1.5px dashed var(--glp-border);
    color: var(--glp-text-muted);
    border-radius: 8px;
    padding: 12px;
    width: 100%;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.15s;
    font-family: inherit;
}

#create-new-deal-btn:hover {
    border-color: var(--glp-brand);
    color: var(--glp-brand);
    background: rgba(215, 71, 9, 0.03);
}

/* --- Cropper Popup --- */
#contact-upload-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    z-index: 10005;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.upload-popup-content {
    background: var(--glp-card);
    padding: 24px;
    border-radius: 16px;
    width: 90%;
    max-width: 450px;
    box-sizing: border-box;
    position: relative;
    font-family: "Plus Jakarta Sans", -apple-system, sans-serif;
    box-shadow: var(--glp-shadow-lg);
}

.upload-popup-content h2 {
    margin-top: 0;
    font-size: 18px;
    margin-bottom: 16px;
    color: var(--glp-text);
}

.close-upload-popup {
    position: absolute;
    top: 16px;
    right: 20px;
    cursor: pointer;
    font-size: 22px;
    background: none;
    border: none;
    color: var(--glp-text-muted);
    transition: all 0.15s;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.close-upload-popup:hover {
    color: var(--glp-text);
    background: var(--glp-bg);
}

.crop-container {
    width: 100%;
    max-height: 350px;
    overflow: hidden;
    margin-bottom: 16px;
    border-radius: 8px;
    background: var(--glp-bg);
}

.crop-container img {
    max-width: 100%;
    display: block;
}

.upload-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.upload-buttons button {
    background: var(--glp-bg);
    color: var(--glp-text);
    border: 1px solid var(--glp-border);
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.15s;
    font-size: 13px;
    font-family: inherit;
}

.upload-buttons button:hover {
    background: var(--glp-card);
    border-color: #d0d5dd;
}

.upload-buttons #save-contact-crop-btn {
    background: var(--glp-brand);
    color: #fff;
    border-color: var(--glp-brand);
}

.upload-buttons #save-contact-crop-btn:hover {
    background: #c03d06;
}

/* ==========================================================================
   SNIPPET 42: Inquiry Form (Popup & Landing Page)
   ========================================================================== */

/* --- Popup Overlay & Modal (Internal) --- */
/* --- Inquiry Popup: uses glp-wizard-* classes from global CSS --- */
/* Popup-as-modal (shown centered over overlay) */
#inquiry-popup-modal.inquiry-popup-standalone {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 30px auto;
    z-index: 999991;
    width: 90%;
    max-width: 550px;
    max-height: calc(100vh - 60px);
    height: fit-content;
}

/* --- Landing Page overrides --- */
body.genealogic-embed-form {
    background: var(--glp-bg);
    font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 20px;
    height: 100%;
    margin: 0;
}

body.genealogic-embed-form html {
    height: 100%;
    margin: 0;
    padding: 0;
}

body.genealogic-embed-form #inquiry-popup-modal {
    position: relative;
    display: flex;
    top: auto;
    left: auto;
    transform: none;
    width: 100%;
    max-width: 550px;
}

body.genealogic-embed-form .glp-wizard-close {
    display: none;
}

/* --- Form Messages --- */
#inquiry-form-message {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: 8px;
    display: none;
    font-size: 13px;
    text-align: center;
    font-weight: 500;
}

#inquiry-form-message.success {
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.2);
    color: #16a34a;
}

#inquiry-form-message.error {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #dc2626;
}

/* --- Success Screen --- */
.inquiry-success-message {
    text-align: center;
    padding: 40px 24px;
    min-height: 400px;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.inquiry-success-icon {
    width: 72px;
    height: 72px;
    background: rgba(34, 197, 94, 0.08);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    animation: zoomIn 0.3s ease-out;
}

.inquiry-success-icon svg {
    width: 36px;
    height: 36px;
    stroke: #16a34a;
    stroke-width: 3;
}

.inquiry-success-message h3 {
    font-size: 20px;
    color: var(--glp-text);
    margin: 0 0 8px 0;
    font-weight: 700;
}

.inquiry-success-message p {
    font-size: 14px;
    color: var(--glp-text-muted);
    margin: 0;
    line-height: 1.5;
}

@keyframes zoomIn {
    from { transform: scale(0.5); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

/* WhatsApp Button */
.inquiry-wa-btn {
    background-color: #25D366;
    color: #fff;
    padding: 12px 28px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 14px;
    margin-top: 24px;
    transition: all 0.15s;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.2);
}

.inquiry-wa-btn:hover {
    background-color: #128C7E;
    color: #fff;
}

.inquiry-wa-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ==========================================================================
   SNIPPET 50: Pro Feature Overlay (Contacts / Deals blocking)
   ========================================================================== */

.pro-feature-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.5);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.pro-feature-overlay.is-active {
    display: flex;
}

.pro-feature-box {
    background: var(--glp-card);
    padding: 32px;
    border-radius: 16px;
    box-shadow: var(--glp-shadow-lg);
    text-align: center;
    max-width: 400px;
    border: 1px solid var(--glp-border);
    z-index: 99999;
    font-family: "Plus Jakarta Sans", -apple-system, sans-serif;
}

.pro-feature-button {
    background: var(--glp-text);
    color: #fff;
    border-radius: 8px;
    padding: 12px 24px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    display: inline-block;
    margin-top: 16px;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.pro-feature-button:hover {
    background: var(--glp-brand);
    color: #fff;
}

/* Menu z-index overrides so menus stay above the overlay */
#menu-lateral,
#menu-superior {
    z-index: 99999 !important;
    transform: translateZ(0);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 600px) {
    .crm-toolbar {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .crm-search-box {
        max-width: 100%;
    }

    .crm-bulk-actions {
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    .crm-contact-card {
        flex-wrap: wrap;
        align-items: flex-start;
        padding: 14px 16px;
    }

    .contact-avatar-list {
        margin-right: 12px;
        width: 40px;
        height: 40px;
    }

    .contact-info-main {
        min-width: 100%;
        margin-top: 10px;
        margin-bottom: 10px;
    }

    .edit-contact-btn {
        width: 100%;
        text-align: center;
    }

    .contact-details {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    #contact-side-panel {
        max-width: 100%;
    }

    .panel-header {
        padding: 16px 20px;
    }

    .panel-body {
        padding: 20px 16px;
    }

    .panel-footer {
        padding: 14px 20px;
    }
}
