/* ==========================================================================
   Empty State — placeholder shown when a list or section has no data
   --------------------------------------------------------------------------
   BEM block: .app-empty-state
   Variants:  --page  (full-page, centred)
              --section (inline, inside a form/card)

   Markup:
   <div class="app-empty-state app-empty-state--page">
       <img class="app-empty-state__image" src="..." alt="" />
       <h2 class="app-empty-state__title">No items yet</h2>
       <p class="app-empty-state__desc">Create your first item to get started.</p>
       <div class="app-empty-state__actions">
           <button class="app-btn app-btn--sm">Create item</button>
       </div>
   </div>
   ========================================================================== */

/* ========== 1. BASE ========== */

.app-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    max-width: 520px;
    margin-inline: auto;
    padding: var(--spacing-3xl) var(--spacing-xl);
    font-family: var(--font-family-primary);
}

/* ========== 2. VARIANTS ========== */

.app-empty-state--page {
    /* 520px left the copy at roughly 37 characters a line, half a comfortable measure, and the
       longer welcome texts ran to 13 lines because of it. The sectioned variant overrides this. */
    max-width: 40rem;
    min-height: calc(100vh - 25rem);
    justify-content: center;
}

.app-empty-state--section {
    min-height: 200px;
    padding: var(--spacing-2xl) var(--spacing-xl);
    border: 1px dashed var(--border-secondary);
    border-radius: var(--radius-lg);
}

/* Types emitted by components/empty_state.htm — the value comes from EmptyState.php */
.app-empty-state--edit_section,
.app-empty-state--modal {
    min-height: 200px;
    padding: var(--spacing-2xl) var(--spacing-xl);
}

.app-empty-state--card {
    background: var(--bg-primary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.06));
    max-width: 520px;
    margin: var(--spacing-3xl) auto;
}

/* A sectioned empty state: each paragraph is followed by the button that acts on it, so the
   sections need the air a button row would otherwise sit in on its own. */
/* Two next steps that are done in parallel read as two columns rather than a queue. */
.app-empty-state__sections {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: var(--spacing-4xl);
    width: 100%;
    margin-top: var(--spacing-4xl);
}

.app-empty-state__section {
    display: flex;
    flex-direction: column;
    /* Left-aligned: two columns of running copy read as columns, not as two more centred
       blocks under the centred title. The title and the lead paragraph stay centred. */
    align-items: flex-start;
    text-align: left;
    flex: 1 1 16rem;
    min-width: 0;
}

/* Side by side the columns need more room than the 520px a single stack of copy wants. */
.app-empty-state:has(.app-empty-state__sections) {
    max-width: 60rem;
}

/* Alone, a section is not a column among others - it is the whole empty state, and it centres
   under the title like the rest of the box. */
.app-empty-state__section:only-child {
    align-items: center;
    text-align: center;
    flex: 0 1 auto;
}

.app-empty-state:has(.app-empty-state__section:only-child) {
    max-width: 40rem;
}

.app-empty-state__section > .app-empty-state__desc {
    margin-bottom: 0;
}

.app-empty-state__section .app-empty-state__actions {
    margin-top: var(--spacing-md);
}

/* ========== 3. IMAGE ========== */

.app-empty-state__image {
    width: 100%;
    max-width: 12.5rem;
    height: auto;
    margin-bottom: var(--spacing-xl);
    opacity: 0.75;
    user-select: none;
    pointer-events: none;
}

/* ========== 4. TITLE ========== */

.app-empty-state__title {
    margin: 0 0 var(--spacing-sm);
    color: var(--text-primary);
    font-weight: var(--font-weight-black);
}

/* A page-level empty state is the whole screen, so its title carries the page, not a section.
   At the body-lg the templates set it was the same size as the text under it. The rule outranks
   the `text-body-lg font-semibold` those templates also carry, so none of them need editing. */
.app-empty-state--page .app-empty-state__title {
    font-size: var(--font-display-md-size);
    line-height: var(--font-display-md-line-height);
    letter-spacing: var(--font-display-md-letter-spacing);
    font-weight: var(--font-weight-black);
}

/* The lead paragraph, the one directly under the title. Section copy stays at body size. */
.app-empty-state--page > .app-empty-state__desc {
    font-size: var(--font-body-lg-size);
    line-height: var(--font-body-lg-line-height);
}

/* Error state. Seven call sites pass 'error' as the icon class, and the legacy rule that acted on
   it was `.empty_state_image.error svg` — it needed both the old class name and an inline <svg> to
   tint. The image is now an <img>, which CSS cannot recolour through fill/color, so the state is
   carried by the heading instead. Without this a failed Sendgrid or mailserver call renders
   identically to a success screen. */
.app-empty-state:has(.app-empty-state__image.error) .app-empty-state__title {
    color: var(--color-error);
}

/* ========== 5. DESCRIPTION ========== */

.app-empty-state__desc {
    margin: 0 0 var(--spacing-xl);
    font-size: var(--font-body-md-size);
    font-weight: var(--font-weight-regular);
    color: var(--text-secondary);
    line-height: var(--font-body-md-line-height);
}

/* Descendant styles — normalize HTML from language strings */
.app-empty-state__desc h3 {
    font-size: var(--font-body-lg-size);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin: var(--spacing-lg) 0 var(--spacing-xs);
    line-height: var(--font-body-lg-line-height);
}

.app-empty-state__desc p {
    margin: 0 0 var(--spacing-sm);
}

.app-empty-state__desc a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.app-empty-state__desc a:hover {
    color: var(--accent-hover, var(--accent));
}

.app-empty-state__desc strong,
.app-empty-state__desc b {
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

/* ========== 6. ACTIONS ========== */

.app-empty-state__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    justify-content: center;
}

.app-empty-state__actions--dropzone {
    width: 100%;
    max-width: 520px;
    margin-top: var(--spacing-md);
}

.app-empty-state__actions--dropzone .drop_zone_container {
    position: relative;
    width: 100%;
}
