/* Frontend Styles for Simple Post Form */

.spf-form-container {
    max-width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

/* Ensure all child elements use border-box */
.spf-form-container *,
.spf-form-container *::before,
.spf-form-container *::after {
    box-sizing: border-box;
}

.spf-form-title {
    margin: 0 0 20px;
    font-size: 28px;
    font-weight: 600;
    color: #1d2327;
}

.spf-form {
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

/* Form Fields */
.spf-form-fields-wrapper {
    margin-bottom: 25px;
}

.spf-form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.spf-form-field {
    flex: 1;
}

.spf-field-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #1d2327;
    font-size: 14px;
}

.spf-required {
    color: #d63638;
    margin-left: 3px;
}

.spf-form input[type="text"],
.spf-form input[type="email"],
.spf-form input[type="tel"],
.spf-form input[type="number"],
.spf-form textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    font-family: inherit;
    transition: all 0.3s;
    box-sizing: border-box;
    background: #fff;
    color: #333;
}

.spf-form input:focus,
.spf-form textarea:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
}

.spf-form textarea {
    resize: vertical;
    min-height: 120px;
}

.spf-field-error {
    border-color: #d63638 !important;
    box-shadow: 0 0 0 1px #d63638 !important;
}

/* Messages */
.spf-form-messages {
    margin: 20px 0;
    padding: 15px 20px;
    border-radius: 4px;
    font-size: 15px;
    display: none;
}

.spf-form-messages:not(:empty) {
    display: block;
}

.spf-form-messages.spf-success {
    background: #d1e7dd;
    color: #0a3622;
    border: 1px solid #a3cfbb;
}

.spf-form-messages.spf-error {
    background: #f8d7da;
    color: #58151c;
    border: 1px solid #f1aeb5;
}

/* Submit Button */
.spf-form-submit {
    margin-top: 20px;
}

.spf-submit-button {
    padding: 15px 40px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: none;
}

.spf-submit-button:hover {
    background: #005177;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.spf-submit-button:active {
    transform: translateY(0);
}

.spf-submit-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .spf-form {
        padding: 20px;
    }
    
    .spf-form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .spf-form-field {
        width: 100% !important;
        flex: none !important;
    }
    
    /* Force all fields to full width on mobile */
    .spf-form-field[style*="width"] {
        width: 100% !important;
    }
    
    .spf-form-title {
        font-size: 24px;
    }
    
    .spf-submit-button {
        width: 100%;
        padding: 12px 30px;
    }
}

@media (max-width: 480px) {
    .spf-form {
        padding: 15px;
    }
    
    .spf-form-container {
        padding: 0 10px;
    }
    
    .spf-form input[type="text"],
    .spf-form input[type="email"],
    .spf-form input[type="tel"],
    .spf-form input[type="number"],
    .spf-form textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 10px 12px;
    }
    
    .spf-form-title {
        font-size: 20px;
    }
}

/* Loading State */
.spf-form.spf-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Accessibility */
.spf-form input:focus-visible,
.spf-form textarea:focus-visible,
.spf-submit-button:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Custom Animations */
@keyframes spf-fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.spf-form-messages {
    animation: spf-fadeIn 0.3s ease-out;
}

/* Modal Styles */
.spf-modal-trigger {
    padding: 15px 40px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
    text-decoration: none;
}

.spf-modal-trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.spf-modal-trigger:active {
    transform: translateY(0);
}

.spf-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.spf-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1;
}

.spf-modal-content {
    position: relative;
    width: 600px;
    max-width: 90%;
    background: #fff;
    border-radius: 8px;
    padding: 40px;
    margin: auto;
    z-index: 2;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: spf-modalSlideIn 0.3s ease-out;
}

.spf-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 5px 10px;
    transition: all 0.2s;
    z-index: 3;
}

.spf-modal-close:hover {
    color: #000;
    transform: rotate(90deg);
}

.spf-modal .spf-form {
    box-shadow: none;
    padding: 0;
}

body.spf-modal-open {
    overflow: hidden;
}

/* Modal Animations */
@keyframes spf-modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modal Responsive */
@media (max-width: 768px) {
    .spf-modal {
        padding: 15px;
    }
    
    .spf-modal-content {
        width: 95%;
        max-width: 95%;
        padding: 30px 20px;
        margin: auto;
    }
    
    /* Force modal to use full width on tablets */
    .spf-modal-content[style*="width"] {
        width: 95% !important;
    }
    
    .spf-modal-close {
        top: 10px;
        right: 10px;
        font-size: 28px;
    }
    
    /* Ensure modal fields are full width */
    .spf-modal .spf-form-field {
        width: 100% !important;
    }
}

@media (max-width: 480px) {
    .spf-modal {
        padding: 10px;
        align-items: flex-start;
        padding-top: 40px;
    }
    
    .spf-modal-content {
        width: 98%;
        max-width: 98%;
        padding: 20px 15px;
        margin: 0 auto;
        border-radius: 4px;
    }
    
    /* Force modal to nearly full width on mobile */
    .spf-modal-content[style*="width"],
    .spf-modal-content[style*="max-width"] {
        width: 98% !important;
        max-width: 98% !important;
    }
    
    .spf-modal-trigger {
        width: 100%;
        text-align: center;
        padding: 12px 30px;
    }
    
    .spf-modal-close {
        font-size: 24px;
        padding: 3px 8px;
    }
    
    /* Better touch targets for mobile */
    .spf-modal .spf-form input[type="text"],
    .spf-modal .spf-form input[type="email"],
    .spf-modal .spf-form input[type="tel"],
    .spf-modal .spf-form input[type="number"],
    .spf-modal .spf-form textarea {
        min-height: 44px; /* iOS recommended touch target */
    }
}

/* Extra small devices (320px and below) */
@media (max-width: 360px) {
    .spf-form {
        padding: 12px;
    }
    
    .spf-form-container {
        padding: 0 5px;
    }
    
    .spf-modal-content {
        margin: 5px auto;
        padding: 15px 10px;
    }
    
    .spf-form-title {
        font-size: 18px;
        margin-bottom: 15px;
    }
    
    .spf-field-label {
        font-size: 13px;
    }
    
    .spf-submit-button {
        padding: 10px 20px;
        font-size: 14px;
    }
}

/* Debug Mode Styling */
.spf-form .description {
    margin: 5px 0 0;
    font-size: 13px;
    line-height: 1.5;
    font-weight: normal;
}

/* Honeypot field in debug mode */
input[id*="_honeypot"][style*="position: absolute"] {
    /* Ensure truly hidden honeypot fields don't affect layout */
    position: absolute !important;
    left: -9999px !important;
}

/* Debug mode visible honeypot styling */
.spf-form input[id*="_honeypot"]:not([style*="position: absolute"]) {
    border: 2px dashed #d63638;
    background: #fff8e5;
}

.spf-form input[id*="_honeypot"]:not([style*="position: absolute"]):focus {
    border-color: #d63638;
    box-shadow: 0 0 0 2px rgba(214, 54, 56, 0.2);
}
