/* ============================================================================
   HIRE TALENT MODAL CSS - Complete Styling System (Safari Compatible)
   ============================================================================ */

/* Modal Overlay */
.htm-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999999;
    display: flex;
    align-items: center; /* Center vertically */
    justify-content: center;
    padding: 2rem; /* Equal padding all around for blur space */
    overflow-y: auto; /* Overlay scrolls if modal is too tall */
    -webkit-overflow-scrolling: touch;
}

.htm-modal-overlay.htm-modal-open {
    display: flex !important;
}

/* Modal Container */
.htm-modal-container {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 48rem;
    width: 100%;
    max-height: calc(100vh - 4rem); /* Leave space for top and bottom padding */
    overflow-y: scroll; /* Use scroll for consistent behavior */
    -webkit-overflow-scrolling: touch;
    animation: htm-modal-slide-up 0.3s ease-out;
    position: relative;
    margin: auto; /* Center in the flex container */
}

/* When showing success screen, adjust container */
.htm-modal-container:has(.htm-success-screen[style*="display: block"]) {
    min-height: auto;
}

@keyframes htm-modal-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modal Header */
.htm-modal-header {
    background: linear-gradient(135deg, #235383 0%, #2d6aa8 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 1rem 1rem 0 0;
    position: relative;
}

.htm-modal-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    line-height: 1;
    padding: 0;
}

.htm-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.htm-modal-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
    font-weight: 700;
    padding-right: 3rem;
}

.htm-modal-subtitle {
    margin: 0;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.9);
}

/* Modal Body */
.htm-modal-body {
    padding: 1.5rem;
    padding-top: 1.5rem;
}

/* Form Elements */
.htm-form {
    display: block;
}

.htm-form-group {
    margin-bottom: 1.25rem;
}

.htm-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.htm-form-row .htm-form-group {
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .htm-form-row {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
}

.htm-label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    color: #374151;
    margin-bottom: 0.5rem;
}

.htm-required {
    color: #dc2626;
}

/* Base Input Styles */
.htm-input,
.htm-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: all 0.2s;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: white;
}

/* Prevent iOS zoom on focus - CRITICAL FIX */
@supports (-webkit-touch-callout: none) {
    .htm-input,
    .htm-textarea,
    select.htm-input {
        font-size: 16px !important; /* iOS won't zoom if font-size >= 16px */
    }
}

/* Also apply to mobile devices in general */
@media (max-width: 768px) {
    .htm-input,
    .htm-textarea,
    select.htm-input {
        font-size: 16px !important; /* Prevent zoom on mobile */
        min-height: 44px; /* iOS recommended touch target */
    }
}

/* Safari-Specific Select Dropdown Styling */
select.htm-input {
    /* Remove default appearance for consistent cross-browser styling */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    
    /* Add custom dropdown arrow */
    background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8"><path fill="%23374151" d="M1.41 0L6 4.59L10.59 0L12 1.41l-6 6l-6-6z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 12px;
    
    /* Ensure text doesn't overlap with arrow */
    padding-right: 2.5rem;
    
    /* Safari-specific cursor */
    cursor: pointer;
    
    /* Prevent text from being cut off in Safari */
    line-height: 1.5;
}

/* Firefox-specific select styling */
@-moz-document url-prefix() {
    select.htm-input {
        padding-right: 2.5rem;
    }
}

/* Focus States */
.htm-input:focus,
.htm-textarea:focus {
    outline: none;
    border-color: #235383;
    box-shadow: 0 0 0 3px rgba(35, 83, 131, 0.1);
}

/* Safari-specific focus fix for selects */
select.htm-input:focus {
    outline: none;
    border-color: #235383;
    box-shadow: 0 0 0 3px rgba(35, 83, 131, 0.1);
}

.htm-textarea {
    resize: vertical;
    font-family: inherit;
    min-height: 100px;
}

/* Select Option Styling for Better Readability */
select.htm-input option {
    padding: 0.5rem;
    background-color: white;
    color: #374151;
}

/* Position Display (non-editable field) */
.htm-position-display {
    background: #E8F0F8;
    border: 1px solid #235383;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    color: #235383;
    font-weight: 600;
}

/* Form Buttons */
.htm-form-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

@media (max-width: 480px) {
    .htm-form-buttons {
        flex-direction: column;
    }
}

.htm-btn {
    flex: 1;
    padding: 0.875rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.htm-btn-primary {
    background: #235383;
    color: white;
    box-shadow: 0 4px 12px rgba(35, 83, 131, 0.3);
}

.htm-btn-primary:hover {
    background: #1a3f63;
    box-shadow: 0 6px 16px rgba(35, 83, 131, 0.4);
}

.htm-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.htm-btn-secondary {
    background: white;
    color: #374151;
    border: 2px solid #d1d5db;
}

.htm-btn-secondary:hover {
    background: #f9fafb;
}

.htm-btn-loader {
    display: none;
    margin-right: 6px;
}

.htm-btn.htm-loading .htm-btn-loader {
    display: inline-flex;
    align-items: center;
}

/* Spinner */
.htm-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: htm-spin 0.6s linear infinite;
}

@keyframes htm-spin {
    to { transform: rotate(360deg); }
}

/* Privacy Note */
.htm-privacy-note {
    text-align: center;
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 1rem;
    margin-bottom: 0;
}

/* Form Messages */
.htm-form-message {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.htm-form-message.htm-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.htm-form-message.htm-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* Success Screen */
.htm-success-screen {
    text-align: center;
    padding: 60px 40px;
    background: white;
}

.htm-success-icon {
    width: 80px;
    height: 80px;
    color: #235383;
    margin: 0 auto 16px;
    opacity: 0;
    display: block;
}

.htm-success-screen.htm-show-animation .htm-success-icon {
    animation: htm-success-icon-bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.htm-success-title {
    font-size: 19px;
    font-weight: 400;
    color: #235383;
    margin: 0 0 8px 0;
    opacity: 0;
}

.htm-success-screen.htm-show-animation .htm-success-title {
    animation: htm-success-fade-in 0.5s ease-out 0.3s forwards;
}

.htm-success-text {
    color: #6b7280;
    margin: 0;
    line-height: 1.875;
    opacity: 0;
}

.htm-success-screen.htm-show-animation .htm-success-text {
    animation: htm-success-fade-in 0.5s ease-out 0.4s forwards;
}

.htm-success-screen .htm-btn {
    opacity: 0;
    margin-top: 0;
    display: none;
}

.htm-success-screen.htm-show-animation .htm-btn {
    animation: htm-success-fade-in 0.5s ease-out 0.5s forwards;
}

@keyframes htm-success-icon-bounce {
    0% {
        transform: scale(0) translateY(20px);
        opacity: 0;
    }
    50% {
        transform: scale(1.1) translateY(-5px);
        opacity: 1;
    }
    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

@keyframes htm-success-fade-in {
    from {
        transform: translateY(10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Mobile Responsive - Floating Card Style (matches job plugin) */
@media (max-width: 768px) {
    .htm-modal-overlay {
        padding: 16px; /* Keep padding for blur visibility */
        align-items: flex-start; /* Start at top so tall modals scroll properly */
        justify-content: center;
        overflow-y: auto; /* ONLY the overlay scrolls */
        -webkit-overflow-scrolling: touch;
    }
    
    .htm-modal-container {
        border-radius: 16px; /* Keep rounded corners */
        margin: 16px auto; /* Vertical margin for spacing */
        min-height: auto; /* Natural height, not full screen */
        max-height: none; /* No max height - let it grow */
        height: auto;
        width: 100%;
        overflow: visible; /* NO scroll on container - unified scroll */
        background: white;
    }
    
    .htm-modal-header {
        border-radius: 16px 16px 0 0; /* Rounded top corners */
        position: relative;
        background: linear-gradient(135deg, #235383 0%, #2d6aa8 100%);
    }
    
    .htm-modal-body {
        padding: 1rem;
        padding-bottom: 1.5rem; /* Extra bottom padding for buttons */
        overflow: visible;
        background: white;
        min-height: auto;
        border-radius: 0 0 16px 16px; /* Rounded bottom corners */
    }
    
    /* Mobile success screen adjustments */
    .htm-success-screen {
        padding: 40px 24px;
        min-height: auto;
    }
    
    .htm-success-icon {
        width: 64px;
        height: 64px;
        margin: 0 auto 12px;
    }
    
    .htm-success-title {
        font-size: 19px;
        font-weight: 400;
    }
    
    .htm-success-text {
        font-size: 0.9375rem;
    }
    
    /* Ensure select dropdowns are fully visible on mobile */
    select.htm-input {
        min-height: 48px;
    }
}

/* Tablet specific adjustments (between mobile and desktop) */
@media (min-width: 481px) and (max-width: 768px) {
    .htm-success-screen {
        padding: 50px 32px;
    }
    
    .htm-success-icon {
        width: 72px;
        height: 72px;
        margin: 0 auto 14px;
    }
    
    .htm-success-title {
        font-size: 19px;
        font-weight: 400;
    }
}

/* Prevent body scroll when modal is open */
body.htm-modal-active {
    overflow: hidden;
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari select dropdown fix */
    select.htm-input {
        min-height: 44px;
        font-size: 16px;
    }
    
    /* Prevent iOS Safari from adding its own styling */
    select.htm-input::-webkit-contacts-auto-fill-button {
        visibility: hidden;
        pointer-events: none;
        position: absolute;
    }
}
