/**
 * Provider Matching Tool Frontend Styles (v6.2.0)
 * This file styles the multi-step form and results display.
 */

/** --- 1. Main Form Container & Variables --- */
#pmt-matching-tool-container {
    --primary-color: #5f0988;
    --primary-color-dark: #4a076a;
    --secondary-color: #f0e4f7;
    --border-color: #e0e0e0;
    --text-color: #333;
    --text-color-light: #666;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --border-radius: 8px;
    --box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);

    font-family: var(--font-family);
    background-color: #ffffff;
    max-width: 700px;
    margin: 40px auto;
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

/* --- Accessibility: Add visible focus ring for keyboard navigation --- */
button:focus-visible, a:focus-visible, input:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--secondary-color);
}

/* Global rule to remove underlines from all links */
#pmt-matching-tool-container a {
    text-decoration: none;
}

/* Decorative top border gradient */
#pmt-matching-tool-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #c72d82 100%);
}

/** --- New Header Styles --- */
.pmt-tool-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping on small screens */
    gap: 15px;
    margin-bottom: 30px;
    padding-bottom: 20px;
}

.pmt-header-logo {
    height: 40px;
    width: auto;
}

.pmt-header-title {
    font-size: 1.5em;
    margin: 0;
}

/** --- 2. Typography & Layout --- */
.pmt-field-group {
    margin-bottom: 24px;
}

.pmt-label {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 8px;
    display: block;
}

/** --- 3. Checkboxes & Radios --- */
.pmt-radio-group, .pmt-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
    padding-top: 8px;
}

.pmt-checkbox-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

/* Style assessment radios to be single-column for clarity */
#pmt-assessment-group .pmt-radio-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

.pmt-radio-group label, .pmt-checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    cursor: pointer;
}

input[type="radio"], input[type="checkbox"] {
    accent-color: var(--primary-color);
    height: 1.1em;
    width: 1.1em;
    cursor: pointer;
}

/** --- 4. Buttons --- */
.pmt-navigation {
    display: flex;
    justify-content: flex-end;
    gap: 20px;
    margin-top: 30px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.pmt-next-btn, .pmt-submit-btn, .pmt-prev-btn {
    padding: 14px 24px;
    font-size: 1.0em;
    font-weight: 600;
    border-radius: var(--border-radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.pmt-next-btn, .pmt-submit-btn {
    background: var(--primary-color);
    color: white;
}
.pmt-next-btn:hover, .pmt-submit-btn:hover {
    background: var(--primary-color-dark);
}

.pmt-prev-btn {
    background: #fff;
    color: var(--text-color-light);
    border-color: var(--border-color);
    margin-right: auto;
}
.pmt-prev-btn:hover {
    background-color: #f8f9fa;
    border-color: #c6c9ce;
}

/** --- 5. Results --- */
#pmt-results {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.pmt-results-wrapper {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
}

/* --- Individual Provider Card --- */
.pmt-provider-card {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    background: #fff;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.pmt-provider-card:hover {
    border-color: #ccc;
    box-shadow: var(--box-shadow);
}

.pmt-provider-card-header {
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

.pmt-provider-image, .pmt-provider-image-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0; /* Prevent image from shrinking */
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.pmt-provider-image-placeholder {
    background-color: #f0f0f0;
    border: 1px solid var(--border-color);
}

.pmt-provider-info {
    flex-grow: 1;
}

.pmt-provider-name { /* Provider's name */
    font-size: 1.2em;
    color: var(--text-color);
    font-weight: 700;
    margin-bottom: 2px; /* Reduces space below the provider's name */
}

.pmt-provider-designation { /* Provider's designation/title */
    margin: 0 0 8px 0;
    font-size: 1.1em;
    font-weight: 500;
    color: var(--primary-color);
}

.pmt-provider-specialties {
    font-size: 0.9em;
    color: var(--text-color-light);
    margin: 0;
    line-height: 1.5;
}

.pmt-provider-meta-info {
    margin: 8px 0 12px 0;
    font-size: 0.9em;
}

.pmt-provider-ages,
.pmt-provider-locations {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 0.9em;
    color: var(--text-color-light);
    margin-bottom: 4px;
}

.pmt-provider-ages strong,
.pmt-provider-locations strong {
    font-weight: 600;
    color: var(--text-color);
    flex-shrink: 0;
}

.pmt-provider-ages {
    font-size: 0.9em;
    color: var(--text-color-light);
    margin: 8px 0;
}

.pmt-card-ages {
    font-size: 0.95em;
    color: var(--text-color-light);
    margin: 0 0 16px 0;
    text-align: center;
    line-height: 1.5;
}

.pmt-provider-bio {
    font-size: 0.95em;
    line-height: 1.6;
    color: var(--text-color-light);
}

.pmt-card-meta-info {
    width: 100%;
    margin: 0 auto 16px;
    text-align: left;
    font-size: 0.95em;
}
.pmt-card-ages,
.pmt-card-locations {
    display: flex;
    align-items: baseline;
    gap: 8px;
    color: var(--text-color-light);
    line-height: 1.6;
    margin-bottom: 4px;
}
.pmt-card-ages strong,
.pmt-card-locations strong {
    font-weight: 600;
    color: var(--text-color);
    flex-shrink: 0;
}

.pmt-card-locations {
    font-size: 0.9em;
    color: var(--text-color-light);
    margin: 16px 0;
    text-align: left;
}

.pmt-location-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-start;
}
.pmt-location-pill {
    background-color: var(--secondary-color);
    color: var(--primary-color-dark);
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 0.85em;
    font-weight: 600;
    line-height: 1.4;
}

.pmt-provider-actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 15px;
    flex-wrap: wrap; /* Allow buttons to stack on small screens */
}

.pmt-result-actions a {
    text-decoration: none;
}

.pmt-button-primary, .pmt-button-secondary {
    display: inline-block;
    padding: 10px 20px;
    border-radius: var(--border-radius);
    font-size: 0.9em;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.pmt-button-primary {
    background-color: var(--primary-color);
    color: #fff;
    border: 1px solid var(--primary-color);
}
.pmt-button-primary:hover {
    background-color: var(--primary-color-dark);
    border-color: var(--primary-color-dark);
}

.pmt-button-secondary {
    background-color: #f0f0f0;
    color: var(--text-color);
    border: 1px solid #ccc;
}
.pmt-button-secondary:hover {
    background-color: #e0e0e0;
    border-color: #bbb;
}

/** --- 6. Result Explanation Styling --- */
.pmt-result-explanation {
    margin: 12px 0;
    padding: 10px 14px;
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    font-size: 0.9em;
    color: #856404;
}

.pmt-result-explanation strong {
    color: #533f03;
    font-weight: 600;
}

.pmt-result-explanation em {
    font-style: italic;
    color: #856404;
}

/* --- Style for Perfect Match Explanation --- */
.pmt-result-explanation.perfect-match {
    background-color: #d4edda; /* Light green */
    border-color: #c3e6cb;
    color: #155724; /* Dark green */
}

.pmt-result-explanation.perfect-match strong {
    color: #0b2e13;
    font-weight: 600;
}

.pmt-result-explanation.perfect-match em {
    font-style: italic;
    color: #155724;
}

/* --- 6. Pathway Specific Styles --- */
.pmt-pathway-result {
    margin-bottom: 20px;
}
.pmt-pathway-result h3 {
    font-size: 1.4em;
}
.pmt-pathway-result h5 {
    margin-top: 30px;
    font-size: 1.1em;
}

.pmt-pathway-contact-cta {
    margin-top: 25px;
    padding-top: 25px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

/** --- 12. Standalone Provider Card Styles (v10.0) --- */
.pmt-standalone-card {
    font-family: var(--font-family);
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    max-width: 350px;
    margin: 20px auto;
    text-align: center;
    padding: 24px;
    display: flex;
    flex-direction: column;
    /* Make the card itself a flex container to control its children */
    display: flex;
    flex-direction: column;
    align-items: center;
}
.pmt-card-image {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 16px;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.pmt-card-name {
    font-size: 1.4em;
    color: var(--text-color);
    font-weight: 700;
    margin: 0 0 4px 0;
}
.pmt-card-designation {
    font-size: 1.0em;
    color: var(--primary-color);
    margin: 0 0 12px 0;
    font-weight: 500;
}
.pmt-card-tagline {
    font-size: 0.95em;
    font-style: italic;
    color: var(--text-color-light);
    margin: 0 0 16px 0;
}
.pmt-card-bio {
    font-size: 0.9em;
    line-height: 1.6;
    color: var(--text-color-light);
    margin-bottom: 20px;
}
.pmt-card-status-pill {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 99px;
    font-size: 0.85em;
    font-weight: 600;
    margin-bottom: 20px;
}
.pmt-card-status-pill.accepting {
    background-color: #d4edda; color: #155724;
}
.pmt-card-status-pill.waitlisting {
    background-color: #fff3cd; color: #856404;
}
.pmt-card-status-pill.unavailable {
    background-color: #f8d7da; color: #721c24;
}
.pmt-card-actions {
    display: flex;
    gap: 12px;
    width: 100%;
    justify-content: center;
    margin-top: auto; /* Pushes the buttons to the bottom of the card */
}
.pmt-card-button {
    flex-grow: 1;
    text-decoration: none;
}
.pmt-pathway-contact-cta .pmt-button-primary {
    padding: 14px 28px;
    font-size: 1.1em;
}

.pmt-results-header {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.pmt-retry-btn {
    padding: 14px 24px;
    font-size: 1.0em;
    font-weight: 600;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    background: #fff;
    color: var(--text-color-light);
    border: 1px solid var(--border-color);
}
.pmt-retry-btn:hover {
    background-color: #f8f9fa;
    border-color: #c6c9ce;
}

/** --- 12. Standalone Provider Card Styles (v10.0) --- */
.pmt-standalone-card {
    font-family: var(--font-family);
    background-color: #fff;
    box-shadow: var(--box-shadow);
    width: 100%; /* Ensure it's responsive inside containers */
    max-width: 350px !important; /* Use !important to override theme width */
    margin: 20px auto !important; /* Use !important to force centering */
    min-width: 280px;
    text-align: center;
    padding: 24px;
    padding-top: 30px;
    /* Apply all borders to ensure they override theme resets */
    border: 1px solid var(--border-color);
    border-top: 6px solid var(--primary-color);
    border-radius: var(--border-radius);
    position: relative;
    display: block; /* Ensure it behaves as a block, not flex/grid from theme */
}

.pmt-card-image {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 16px;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.pmt-card-content {
    /* Make the content area a flex container that grows */
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-grow: 1; /* This is the key: it forces this element to take up available space */
    height: 100%;
    width: 100%; /* Ensure content area fills card width */
}

/** --- 7. Form Validation & Errors --- */
.pmt-field-group.has-error .pmt-label {
    color: #dc3232;
}

.pmt-error-message {
    display: block;
    color: #dc3232;
    font-size: 0.9em;
    font-weight: 500;
    margin-top: 8px;
    margin-bottom: -12px; /* Pull content below up slightly */
    background-color: #fef7f7;
    padding: 8px 12px;
    border-radius: 4px;
}
/** --- 8. Info Cards & Footer --- */
.pmt-info-card {
    background-color: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 24px;
    border-left: 4px solid var(--primary-color);
}

.pmt-info-card:focus-visible {
    outline: none; /* Disable focus ring on non-interactive element */
    box-shadow: none;
}

.pmt-info-card p {
    margin-bottom: 12px;
    line-height: 1.6;
}

.pmt-info-card p:last-child {
    margin-bottom: 0;
}

.pmt-info-card h3,
.pmt-info-card h4,
.pmt-info-card h5 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 12px;
}

.pmt-info-card ul,
.pmt-info-card ol {
    margin-bottom: 12px;
    padding-left: 20px;
}

.pmt-info-card li {
    margin-bottom: 6px;
    line-height: 1.5;
}

.pmt-results-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 40px;
    margin-top: 48px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.pmt-footer-main-action {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 25px;
    border-bottom: 1px solid #eee;
}

.pmt-results-footer h4 {
    font-size: 1.2em;
    color: var(--primary-color);
    font-weight: 700;
    margin: 0;
}

/* --- 11. Popup Modal Styles --- */
#pmt-popup-modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#pmt-popup-modal-container.pmt-modal-hidden {
    opacity: 0;
    visibility: hidden;
}

.pmt-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    cursor: pointer;
}

.pmt-modal-content {
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1001;
}

/* Make the existing form container work inside the modal */
.pmt-modal-content #pmt-matching-tool-container {
    max-width: 700px;
    margin: 20px; /* Add some space from screen edges */
}

.pmt-modal-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2.5rem;
    line-height: 1;
    color: #aaa;
    cursor: pointer;
    padding: 0;
    z-index: 1002;
    transition: color 0.2s ease;
}

.pmt-modal-close-btn:hover {
    color: #333;
}

/* Style for the trigger button */
button.pmt-popup-trigger {
    background-color: var(--primary-color);
    color: #ffffff;
    padding: 14px 24px;
    font-size: 1.0em;
    font-weight: 600;
    border-radius: var(--border-radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-decoration: none; /* Add this to prevent underlines */
}

button.pmt-popup-trigger:hover {
    background-color: var(--primary-color-dark);
    color: #ffffff; /* Ensure text color stays white on hover */
}

.pmt-results-footer p {
    margin: 0;
    line-height: 1.6;
    color: var(--text-color-light);
    max-width: 500px; /* Improve readability */
}

.pmt-contact-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin: 8px 0;
}

.pmt-contact-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-color-light);
    font-size: 1rem;
    font-weight: 500;
    transition: color 0.2s ease;
    text-decoration: none; /* Ensure no underline */
}

.pmt-contact-link svg {
    stroke: currentColor; /* Ensure icon color matches text color */
    width: 20px; /* Tweak icon size for better balance */
    height: 20px;
}

.pmt-contact-link:hover {
    color: var(--primary-color-dark);
    text-decoration: none;
}


/** --- 9. Load More Button --- */
.pmt-load-more-container {
    text-align: center;
    margin-top: 32px;
    margin-bottom: 16px;
}

.pmt-load-more-btn {
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    padding: 14px 32px;
    font-size: 1.0em;
    font-weight: 600;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    box-shadow: 0 2px 8px rgba(95, 9, 136, 0.2);
}

.pmt-load-more-btn:hover {
    background-color: var(--primary-color-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(95, 9, 136, 0.3);
}

/** --- 10. Responsive Adjustments --- */
@media (max-width: 600px) {
    #pmt-matching-tool-container {
        padding: 20px;
        margin: 20px auto;
    }
    .pmt-tool-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* --- Validation Error Shake Animation --- */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* --- Provider Gallery Styles --- */
.pmt-provider-gallery-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    margin: 20px 0;
}

/* Ensure standalone cards within the gallery behave correctly */
.pmt-provider-gallery-wrapper .pmt-standalone-card {
    margin: 0 !important; /* Override the auto margins to allow grid alignment */
    width: 100%; /* Make the card fill the grid cell */
    max-width: none !important; /* Remove max-width to allow stretching */
    box-sizing: border-box; /* Ensure padding is included in the width calculation */
}
