/* ─── Form Builder: CSS Variable Driven ───────────────────── */

.beehiiv-form-wrapper {
    background: var(--bf-bg, #ffffff);
    color: var(--bf-text, #333333);
    font-family: var(--bf-font, inherit);
    font-size: var(--bf-font-size, 16px);
    padding: var(--bf-padding, 24px);
    border-radius: var(--bf-radius, 6px);
    border: 1px solid var(--bf-border, #cccccc);
    margin: 1.5em 0;
    position: relative;
    box-sizing: border-box;
}

.beehiiv-form-title {
    margin: 0 0 0.25em;
    font-size: 1.35em;
    color: var(--bf-text, #333);
}

.beehiiv-form-description {
    margin: 0 0 1em;
    opacity: 0.8;
    font-size: 0.92em;
    line-height: 1.5;
}

.beehiiv-form-footer {
    margin: 0.75em 0 0;
    font-size: 0.8em;
    opacity: 0.6;
}

/* ─── Field Layout ────────────────────────────────────────── */

.beehiiv-form-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}

.beehiiv-fields-stacked {
    flex-direction: column;
}

.beehiiv-fields-inline {
    flex-direction: row;
    flex-wrap: nowrap;
}

.beehiiv-fields-two-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.beehiiv-field-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.beehiiv-field-full {
    width: 100%;
    flex: 1 1 100%;
}

.beehiiv-field-half {
    flex: 1 1 calc(50% - 5px);
    min-width: 140px;
}

.beehiiv-fields-inline .beehiiv-field-wrap {
    flex: 1 1 auto;
}

.beehiiv-fields-inline .beehiiv-field-button {
    flex: 0 0 auto;
}

.beehiiv-field-label {
    font-size: 0.85em;
    font-weight: 600;
    color: var(--bf-text, #333);
}

.beehiiv-required {
    color: #dc2626;
}

.beehiiv-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
    cursor: pointer;
}

/* ─── Input & Button Styles ───────────────────────────────── */

.beehiiv-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 1em;
    font-family: var(--bf-font, inherit);
    color: var(--bf-text, #333);
    background: #fff;
    border: 1px solid var(--bf-border, #ccc);
    border-radius: var(--bf-input-radius, 6px);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.beehiiv-input:focus {
    border-color: var(--bf-accent, #4f46e5);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

select.beehiiv-input {
    appearance: auto;
}

.beehiiv-submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 24px;
    font-size: 1em;
    font-weight: 600;
    font-family: var(--bf-font, inherit);
    color: var(--bf-btn-text, #ffffff);
    background: var(--bf-btn, #4f46e5);
    border: none;
    border-radius: var(--bf-btn-radius, 6px);
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    white-space: nowrap;
    min-height: 42px;
}

.beehiiv-submit-btn:hover {
    opacity: 0.9;
}

.beehiiv-submit-btn:active {
    transform: scale(0.98);
}

.beehiiv-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.beehiiv-form-message {
    margin-top: 8px;
    font-size: 0.9em;
    min-height: 1.2em;
}

.beehiiv-form-message.success {
    color: #16a34a;
}

.beehiiv-form-message.error {
    color: #dc2626;
}

/* ─── Popup & Slide-in ────────────────────────────────────── */

.beehiiv-popup-container {
    position: fixed;
    z-index: 999999;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.beehiiv-popup-container.beehiiv-overlay-active::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
}

/* Slide-in positioning */
.beehiiv-popup-container .beehiiv-display-slide-in {
    position: fixed;
}

.beehiiv-popup-container .beehiiv-pos-center {
    /* default: centered by flex parent */
}

.beehiiv-popup-container .beehiiv-pos-bottom-right,
.beehiiv-popup-container[data-display-type="slide-in"] .beehiiv-pos-bottom-right {
    position: fixed;
    bottom: 20px;
    right: 20px;
    top: auto;
    left: auto;
}

.beehiiv-popup-container .beehiiv-pos-bottom-left {
    position: fixed;
    bottom: 20px;
    left: 20px;
    top: auto;
    right: auto;
}

.beehiiv-popup-container .beehiiv-pos-top-right {
    position: fixed;
    top: 20px;
    right: 20px;
    bottom: auto;
    left: auto;
}

.beehiiv-popup-container .beehiiv-pos-top-left {
    position: fixed;
    top: 20px;
    left: 20px;
    bottom: auto;
    right: auto;
}

/* Close button */
.beehiiv-close-btn {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: var(--bf-text, #333);
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
    padding: 4px 8px;
}

.beehiiv-close-btn:hover {
    opacity: 1;
}

/* Animations */
.beehiiv-anim-fade {
    animation: beehiivFadeIn 0.3s ease;
}

.beehiiv-anim-slide-up {
    animation: beehiivSlideUp 0.4s ease;
}

.beehiiv-anim-slide-right {
    animation: beehiivSlideRight 0.4s ease;
}

@keyframes beehiivFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes beehiivSlideUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes beehiivSlideRight {
    from { opacity: 0; transform: translateX(-30px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ─── Responsive ──────────────────────────────────────────── */

@media (max-width: 600px) {
    .beehiiv-fields-inline {
        flex-direction: column;
    }

    .beehiiv-fields-two-column {
        grid-template-columns: 1fr;
    }

    .beehiiv-field-half {
        flex: 1 1 100%;
    }

    .beehiiv-popup-container .beehiiv-form-wrapper {
        margin: 16px;
        max-width: calc(100vw - 32px) !important;
    }
}

/* ─── Newsletter Archive Grid ─────────────────────────────── */

.beehiiv-archive-grid {
    display: grid;
    gap: 24px;
    margin: 1.5em 0;
}

.beehiiv-columns-1 { grid-template-columns: 1fr; }
.beehiiv-columns-2 { grid-template-columns: repeat(2, 1fr); }
.beehiiv-columns-3 { grid-template-columns: repeat(3, 1fr); }
.beehiiv-columns-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .beehiiv-columns-2,
    .beehiiv-columns-3,
    .beehiiv-columns-4 {
        grid-template-columns: 1fr;
    }
}

.beehiiv-archive-item {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    transition: box-shadow 0.2s;
}

.beehiiv-archive-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.beehiiv-archive-thumb img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.beehiiv-archive-content {
    padding: 16px;
}

.beehiiv-archive-title {
    margin: 0 0 6px;
    font-size: 1.1em;
    line-height: 1.3;
}

.beehiiv-archive-title a {
    color: inherit;
    text-decoration: none;
}

.beehiiv-archive-title a:hover {
    text-decoration: underline;
}

.beehiiv-archive-date {
    display: block;
    font-size: 0.8em;
    color: #888;
    margin-bottom: 6px;
}

.beehiiv-archive-excerpt {
    font-size: 0.9em;
    color: #555;
    margin: 0;
    line-height: 1.5;
}

.beehiiv-archive-empty {
    color: #888;
    font-style: italic;
}
