/* Responsive Layout */
@media (max-width: 900px) {
    #hcvc-container {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        min-height: 0 !important;
    }

    #hcvc-container .hcvc-sidebar {
        display: flex !important;
        width: 100% !important;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        max-height: none;
        padding: 20px;
        flex-shrink: 0;
        transition: max-height 0.3s ease;
    }

    #hcvc-container .hcvc-sidebar.hcvc-sidebar-is-collapsed {
        max-height: none;
        padding-bottom: 20px;
    }

    #hcvc-container .hcvc-sidebar.hcvc-sidebar-is-collapsed > *:not(.hcvc-mobile-toggle) {
        display: none !important;
    }

    .hcvc-mobile-toggle {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        padding: 12px 16px !important;
        background: #f1f5f9 !important;
        color: #1e293b !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: 8px !important;
        font-size: 15px !important;
        font-weight: 600 !important;
        cursor: pointer;
        margin: 0 !important;
    }

    .hcvc-mobile-toggle .hcvc-toggle-icon {
        transition: transform 0.3s ease;
    }

    #hcvc-container .hcvc-sidebar:not(.hcvc-sidebar-is-collapsed) .hcvc-toggle-icon {
        transform: rotate(180deg);
    }

    #hcvc-container .hcvc-main {
        display: flex !important;
        height: 500px;
        width: 100% !important;
    }

    .hcvc-chart-viewport {
        height: 100%;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .hcvc-chart-container {
        min-width: 800px;
        padding: 0 40px;
    }

    .hcvc-grid-y-labels {
        width: 40px;
    }

    .hcvc-grid-lines {
        left: 40px;
        right: 40px;
    }
}

@media (max-width: 600px) {
    #hcvc-container .hcvc-sidebar {
        max-height: none;
        padding: 15px;
    }

    .hcvc-sidebar-tabs {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .hcvc-main-tab {
        font-size: 13px;
        padding: 10px 4px;
        flex: 1 1 45%;
    }

    .hcvc-avatar-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 5px;
    }

    .hcvc-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px;
    }

    .hcvc-toolbar-left, .hcvc-toolbar-right {
        justify-content: space-between;
        width: 100%;
    }
    
    .hcvc-chart-container {
        min-width: 650px; 
    }

    .hcvc-people-layer {
        gap: 5px;
    }

    .hcvc-person-actions {
        top: -90px; /* Position above the name/height label */
        padding: 3px;
    }

    .hcvc-person-actions button {
        width: 24px;
        height: 24px;
        background-size: 12px;
    }
}

/* Modal Overlay and Content styling for Predictors */
.hcvc-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100000; /* High z-index to show above everything in WP */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.hcvc-modal.hcvc-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.hcvc-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.hcvc-modal-content {
    position: relative;
    background: #ffffff;
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    padding: 24px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 10;
    max-height: 90vh;
    overflow-y: auto;
    animation: hcvcModalScale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1e293b;
    box-sizing: border-box;
}

@media (hover: none) and (pointer: coarse) {
    .hcvc-person .hcvc-person-actions {
        opacity: 1 !important;
        pointer-events: auto !important;
        transform: translateX(-50%) translateY(0) !important;
    }
}

@keyframes hcvcModalScale {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.hcvc-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 12px;
}

.hcvc-modal-header h4 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
}

.hcvc-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    font-weight: 400;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    transition: color 0.2s;
}

.hcvc-modal-close:hover {
    color: #475569;
}

.hcvc-modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.hcvc-modal-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: left;
}

.hcvc-modal-field label {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    margin: 0;
    display: block;
}

.hcvc-modal-field input[type="text"],
.hcvc-modal-field input[type="number"] {
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    color: #0f172a;
    background: #ffffff;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
    box-sizing: border-box;
    height: auto;
}

.hcvc-modal-field input[type="text"]:focus,
.hcvc-modal-field input[type="number"]:focus {
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.hcvc-modal-field .hcvc-height-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hcvc-modal-field .hcvc-height-inputs span {
    font-size: 14px;
    color: #64748b;
    font-weight: 500;
}

.hcvc-modal-field .hcvc-avatar-list,
.hcvc-step .hcvc-avatar-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    max-height: 180px;
    overflow-y: auto;
    padding: 4px;
}

.hcvc-modal-field .hcvc-avatar-item,
.hcvc-step .hcvc-avatar-item {
    aspect-ratio: 1;
    padding: 6px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hcvc-modal-field .hcvc-avatar-item:hover,
.hcvc-step .hcvc-avatar-item:hover {
    background: #f8fafc;
}

.hcvc-modal-field .hcvc-avatar-item.active,
.hcvc-step .hcvc-avatar-item.active {
    border-color: #3b82f6;
    background: #eff6ff;
}

.hcvc-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    border-top: 1px solid #f1f5f9;
    padding-top: 16px;
}

.hcvc-modal-footer button {
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.hcvc-btn-secondary {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #475569;
}

.hcvc-btn-secondary:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.hcvc-modal .hcvc-color-swatch,
.hcvc-step .hcvc-color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s;
}

.hcvc-modal .hcvc-color-swatch.active,
.hcvc-step .hcvc-color-swatch.active {
    border-color: #3b82f6;
    transform: scale(1.1);
}

/* ===================================================================
   RESPONSIVE OVERRIDES – Predictors (Child & Parent)
   =================================================================== */

/* --- Tablet: 601px – 900px --- */
@media (max-width: 900px) {
    /* Both predictor wrappers stack vertically */
    .hcvc-predictor-wrapper,
    .hcvc-pp-wrapper {
        flex-direction: column !important;
        height: auto !important;
    }

    /* Form sidebars go full-width */
    .hcvc-predictor-form,
    .hcvc-pp-form {
        flex: none !important;
        width: 100% !important;
    }

    /* Chart areas get a fixed height */
    .hcvc-predictor-chart,
    .hcvc-pp-chart {
        height: var(--hcvc-chart-height-mobile, 500px);
        width: 100% !important;
    }

    /* Toolbar: let items wrap and center */
    .hcvc-predictor-chart .hcvc-toolbar,
    .hcvc-pp-chart .hcvc-toolbar {
        flex-wrap: wrap;
        gap: 8px;
    }

    .hcvc-predictor-chart .hcvc-toolbar-right,
    .hcvc-pp-chart .hcvc-toolbar-right {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        margin-left: 0 !important;
        width: 100%;
    }

    /* Zoom slider wider on tablet */
    #hcvc-pred-zoom-slider,
    #hcvc-pp-zoom-slider {
        width: 120px !important;
    }
}

/* --- Mobile: ≤ 600px --- */
@media (max-width: 600px) {

    /* ---- Predictor form input groups: override inline flex-direction: row ---- */
    .hcvc-predictor-form .hcvc-input-group[style*="flex-direction: row"],
    .hcvc-pp-form .hcvc-input-group[style*="flex-direction: row"] {
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
    }

    /* Labels inside stacked groups should fill width */
    .hcvc-predictor-form .hcvc-input-group label,
    .hcvc-pp-form .hcvc-input-group label {
        min-width: auto !important;
        width: 100% !important;
        margin-bottom: 4px !important;
    }

    /* Height input groups fill width */
    .hcvc-predictor-form .hcvc-height-inputs,
    .hcvc-pp-form .hcvc-height-inputs {
        width: 100% !important;
        flex: none !important;
    }

    /* Gender toggle fills width */
    .hcvc-predictor-form .hcvc-gender-toggle,
    .hcvc-pp-form .hcvc-gender-toggle {
        width: 100% !important;
        flex: none !important;
    }

    /* Unit toggle fills width */
    .hcvc-predictor-form .hcvc-unit-toggle,
    .hcvc-pp-form .hcvc-unit-toggle {
        flex-direction: row !important;
        width: 100% !important;
    }

    /* Predictor form padding */
    .hcvc-predictor-form,
    .hcvc-pp-form {
        padding: 15px !important;
    }

    /* Button row at bottom stacks or wraps */
    .hcvc-predictor-form > .hcvc-step > div:last-child,
    .hcvc-pp-form > .hcvc-step > div:last-child {
        flex-wrap: wrap !important;
    }

    /* ---- Edit Panel inside predictor sidebar ---- */
    #hcvc-pred-edit-fields,
    #hcvc-pp-edit-fields {
        padding: 12px 0 !important;
    }

    /* Avatar list in edit panel: grid instead of horizontal scroll */
    #hcvc-pred-edit-avatar-list,
    #hcvc-pp-edit-avatar-list {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 6px !important;
        overflow-x: visible !important;
        max-height: 160px;
        overflow-y: auto;
    }

    /* Color swatches in edit panel wrap tightly */
    #hcvc-pred-edit-fields .hcvc-color-palette,
    #hcvc-pp-edit-fields .hcvc-color-palette {
        gap: 6px !important;
    }

    /* Body type toggle: smaller text, wraps */
    .hcvc-body-type-toggle {
        flex-wrap: wrap !important;
    }

    .hcvc-body-type-toggle .hcvc-btn {
        font-size: 10px !important;
        padding: 5px 3px !important;
        min-width: 0 !important;
    }

    /* ---- Toolbar on mobile ---- */
    .hcvc-predictor-chart .hcvc-toolbar,
    .hcvc-pp-chart .hcvc-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 10px !important;
        gap: 8px;
    }

    .hcvc-predictor-chart .hcvc-toolbar-right,
    .hcvc-pp-chart .hcvc-toolbar-right {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 6px !important;
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* Zoom slider narrower on mobile */
    #hcvc-pred-zoom-slider,
    #hcvc-pp-zoom-slider {
        width: 80px !important;
    }

    /* Share button full width on mobile */
    .hcvc-predictor-chart .hcvc-btn-share,
    .hcvc-pp-chart .hcvc-btn-share {
        width: 100% !important;
        text-align: center !important;
        justify-content: center !important;
    }

    /* ---- Chart area on mobile ---- */
    .hcvc-predictor-chart,
    .hcvc-pp-chart {
        height: var(--hcvc-chart-height-mobile, 400px);
    }

    /* ---- Person labels: smaller text on mobile ---- */
    .hcvc-label-name {
        font-size: 12px !important;
    }

    .hcvc-label-height {
        font-size: 10px !important;
    }

    /* Person actions: always visible on mobile (no hover on touch) */
    .hcvc-person .hcvc-person-actions {
        opacity: 1 !important;
        pointer-events: auto !important;
        transform: translateX(-50%) translateY(0) !important;
        top: -85px !important;
    }

    .hcvc-person-actions button {
        width: 24px !important;
        height: 24px !important;
    }
}

/* ===================================================================
   RESPONSIVE OVERRIDES – Main Height Comparison Chart (container)
   =================================================================== */

@media (max-width: 900px) {
    .hcvc-container {
        height: auto !important;
    }

    /* Avatar grid in sidebar edit: responsive */
    .hcvc-step .hcvc-avatar-list {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media (max-width: 600px) {
    .hcvc-container {
        border-radius: 8px;
    }

    /* Main sidebar input groups stack */
    .hcvc-sidebar .hcvc-input-group {
        flex-direction: column !important;
    }

    .hcvc-sidebar {
        padding: 15px !important;
    }

    /* Avatar grid: 3 columns on mobile */
    .hcvc-step .hcvc-avatar-list {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px !important;
    }

    /* Celebrity category grid: single column on very small screens */
    .hcvc-celeb-category-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ===================================================================
   RESPONSIVE OVERRIDES – Height Converter
   =================================================================== */
@media (max-width: 600px) {
    .hcvc-hc-container {
        padding: 20px 15px !important;
        border-radius: 10px !important;
    }

    .hcvc-hc-container h2 {
        font-size: 22px !important;
    }

    /* Sections need less padding on mobile */
    .hcvc-hc-section {
        padding: 18px !important;
    }

    .hcvc-hc-section h3 {
        font-size: 16px !important;
    }

    /* Stack the input row vertically on mobile */
    .hcvc-hc-row {
        flex-direction: column !important;
        gap: 10px !important;
    }

    /* Make input wrappers full width */
    .hcvc-hc-input-wrapper {
        width: 100% !important;
    }

    .hcvc-hc-input-wrapper input[type="number"] {
        flex: 1 !important;
        width: auto !important;
        min-width: 0 !important;
    }

    /* Buttons full width on mobile */
    .hcvc-hc-btn {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Result cards: 2 columns already set in PHP, but values smaller */
    .hcvc-hc-result-value {
        font-size: 20px !important;
    }
}

/* Responsive Overrides — Height Comparison & Tips Box */
@media (max-width: 900px) {
    .hcvc-tips-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 12px !important;
    }
    
    .hcvc-tips-icon-wrap {
        width: 38px !important;
        height: 38px !important;
        border-radius: 10px !important;
    }
    
    .hcvc-tips-icon {
        font-size: 18px !important;
        width: 18px !important;
        height: 18px !important;
    }
}

@media (max-width: 600px) {
    .hcvc-tips-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    
    .hcvc-tips-header {
        align-items: flex-start !important;
        gap: 12px !important;
    }
    
    .hcvc-tip-item {
        padding: 12px !important;
        border-radius: 10px !important;
    }
    
    .hcvc-tip-icon-header h5 {
        font-size: 12px !important;
    }
    
    .hcvc-tip-item p {
        font-size: 11px !important;
    }
    
    .hcvc-tips-footer {
        justify-content: center !important;
        margin-top: 10px !important;
    }
    
    .hcvc-tips-cta-btn {
        width: 100% !important;
        justify-content: center !important;
        padding: 12px !important;
        font-size: 13px !important;
        border-radius: 8px !important;
    }

    .hcvc-tips-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
    }

    .hcvc-tips-header-left {
        width: 100% !important;
    }

    .hcvc-toggle-tips-btn {
        width: 100% !important;
        justify-content: center !important;
        padding: 10px 16px !important;
        border-radius: 10px !important;
    }
}

