
/* Default Styling */
.bnr-newsletter-form {
    width: 100%;
    max-width: 400px;
    margin: 20px auto;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

/* Width variations */
.bnr-newsletter-form.bnr-full-width {
    max-width: 100%;
}

.bnr-newsletter-form.bnr-inherit-width {
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
}

/* Form alignment classes */
.bnr-newsletter-form.bnr-align-left {
    margin-left: 0;
    margin-right: auto;
}

.bnr-newsletter-form.bnr-align-center {
    margin-left: auto;
    margin-right: auto;
}

.bnr-newsletter-form.bnr-align-right {
    margin-left: auto;
    margin-right: 0;
}

/* Container-based alignment - let parent container control alignment */
.alignleft .bnr-newsletter-form:not(.bnr-align-center):not(.bnr-align-right),
.text-left .bnr-newsletter-form:not(.bnr-align-center):not(.bnr-align-right),
.has-text-align-left .bnr-newsletter-form:not(.bnr-align-center):not(.bnr-align-right) {
    margin-left: 0;
    margin-right: auto;
}

.alignright .bnr-newsletter-form:not(.bnr-align-left):not(.bnr-align-center),
.text-right .bnr-newsletter-form:not(.bnr-align-left):not(.bnr-align-center),
.has-text-align-right .bnr-newsletter-form:not(.bnr-align-left):not(.bnr-align-center) {
    margin-left: auto;
    margin-right: 0;
}

.aligncenter .bnr-newsletter-form:not(.bnr-align-left):not(.bnr-align-right),
.text-center .bnr-newsletter-form:not(.bnr-align-left):not(.bnr-align-right),
.has-text-align-center .bnr-newsletter-form:not(.bnr-align-left):not(.bnr-align-right) {
    margin-left: auto;
    margin-right: auto;
}

/* Full width containers */
.alignfull .bnr-newsletter-form,
.alignwide .bnr-newsletter-form {
    max-width: 100%;
}

/* When inside columns or specific containers */
.wp-block-column .bnr-newsletter-form,
.widget .bnr-newsletter-form,
.sidebar .bnr-newsletter-form {
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.bnr-newsletter-form h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
}

.bnr-form-group {
    margin-bottom: 15px;
}

.bnr-email-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    box-sizing: border-box;
}

.bnr-submit-btn {
    width: 100%;
    padding: 12px;
    background: var(--bnr-button-color, #0073aa);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.bnr-submit-btn:hover {
    background: var(--bnr-button-hover-color, #005a87);
}

.bnr-submit-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Inline Layout */
.bnr-inline-layout .bnr-form-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.bnr-inline-layout .bnr-email-group {
    flex: 1;
    margin-bottom: 0;
}

.bnr-inline-layout .bnr-submit-group {
    margin-bottom: 0;
}

.bnr-inline-layout .bnr-submit-btn {
    width: auto;
    white-space: nowrap;
}

.bnr-inline-layout .bnr-recaptcha-inline {
    margin-top: 15px;
}

/* Alignment inheritance for form elements */
.text-center .bnr-form-wrapper,
.has-text-align-center .bnr-form-wrapper,
.aligncenter .bnr-form-wrapper,
.bnr-align-center .bnr-form-wrapper {
    justify-content: center;
}

.text-center .bnr-email-input,
.has-text-align-center .bnr-email-input,
.aligncenter .bnr-email-input,
.bnr-align-center .bnr-email-input {
    text-align: center;
}

.text-right .bnr-form-wrapper,
.has-text-align-right .bnr-form-wrapper,
.alignright .bnr-form-wrapper,
.bnr-align-right .bnr-form-wrapper {
    justify-content: flex-end;
}

.text-right .bnr-email-input,
.has-text-align-right .bnr-email-input,
.alignright .bnr-email-input,
.bnr-align-right .bnr-email-input {
    text-align: right;
}

/* No Background */
.bnr-no-background {
    background: none !important;
    padding: 0;
    box-shadow: none;
}

/* Theme Styles Override */
.bnr-theme-styles {
    background: none;
    padding: 0;
    box-shadow: none;
    max-width: none;
}

.bnr-theme-styles .bnr-email-input {
    /* Reset to inherit theme styles */
    padding: inherit;
    border: inherit;
    border-radius: inherit;
    font-size: inherit;
}

.bnr-theme-styles .bnr-submit-btn {
    /* Reset to inherit theme button styles */
    padding: inherit;
    border: inherit;
    border-radius: inherit;
    font-size: inherit;
}

/* Message Styling */
.bnr-message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 4px;
    text-align: center;
}

.bnr-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.bnr-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.g-recaptcha {
    margin-bottom: 15px;
}

/* Responsive */
@media (max-width: 480px) {
    .bnr-newsletter-form {
        padding: 15px;
    }
    
    .bnr-inline-layout .bnr-form-wrapper {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    /* Default: full width button on mobile for inline layout */
    .bnr-inline-layout .bnr-submit-btn {
        width: 100%;
    }
    
    /* Center alignment for stacked elements */
    .text-center .bnr-form-wrapper,
    .has-text-align-center .bnr-form-wrapper,
    .aligncenter .bnr-form-wrapper,
    .bnr-align-center .bnr-form-wrapper {
        align-items: center;
    }
    
    .text-center .bnr-inline-layout .bnr-submit-btn,
    .has-text-align-center .bnr-inline-layout .bnr-submit-btn,
    .aligncenter .bnr-inline-layout .bnr-submit-btn,
    .bnr-align-center .bnr-inline-layout .bnr-submit-btn {
        width: auto;
        display: block;
        margin-left: auto;
        margin-right: auto;
    }
    
    /* Right alignment for stacked elements */
    .text-right .bnr-form-wrapper,
    .has-text-align-right .bnr-form-wrapper,
    .alignright .bnr-form-wrapper,
    .bnr-align-right .bnr-form-wrapper {
        align-items: flex-end;
    }
    
    .text-right .bnr-inline-layout .bnr-submit-btn,
    .has-text-align-right .bnr-inline-layout .bnr-submit-btn,
    .alignright .bnr-inline-layout .bnr-submit-btn,
    .bnr-align-right .bnr-inline-layout .bnr-submit-btn {
        width: auto;
        display: block;
        margin-left: auto;
        margin-right: 0;
    }
    
    /* Left alignment for stacked elements */
    .text-left .bnr-form-wrapper,
    .has-text-align-left .bnr-form-wrapper,
    .alignleft .bnr-form-wrapper,
    .bnr-align-left .bnr-form-wrapper {
        align-items: flex-start;
    }
    
    .text-left .bnr-inline-layout .bnr-submit-btn,
    .has-text-align-left .bnr-inline-layout .bnr-submit-btn,
    .alignleft .bnr-inline-layout .bnr-submit-btn,
    .bnr-align-left .bnr-inline-layout .bnr-submit-btn {
        width: auto;
        display: block;
        margin-left: 0;
        margin-right: auto;
    }
    
    /* Ensure email input text alignment matches container */
    .text-center .bnr-email-input,
    .has-text-align-center .bnr-email-input,
    .aligncenter .bnr-email-input,
    .bnr-align-center .bnr-email-input {
        text-align: center;
    }
    
    .text-right .bnr-email-input,
    .has-text-align-right .bnr-email-input,
    .alignright .bnr-email-input,
    .bnr-align-right .bnr-email-input {
        text-align: right;
    }
}

/* Widget Styles */
.widget .bnr-newsletter-form {
    max-width: 100%;
    margin: 0;
}
