/* ---------------------------
 * Heading Analyzer – główny wrapper
 * -------------------------- */

.headingcheck-wrapper {
    box-sizing: border-box;
    margin: 0 auto 2rem;
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ---------------------------
 * Pola i etykiety
 * -------------------------- */

.headingcheck-wrapper label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.95rem;
    font-weight: 500;
}

.headingcheck-help {
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: #6b7280;
}

.headingcheck-field {
    width: 100%;
}

/* pola liniowe (keyword + url obok siebie na desktopie) */
.headingcheck-field-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
}

.headingcheck-field-inline-item {
    flex: 1 1 260px;
}

/* ---------------------------
 * Pola input / textarea
 * -------------------------- */

.headingcheck-wrapper input[type="text"],
.headingcheck-wrapper textarea {
    box-sizing: border-box;
    width: 100%;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--e-global-color-uicore_body, #d1d5db);
    background: var(--e-global-color-uicore_white, #ffffff);
    font-size: 0.9rem;
    line-height: 1.4;
    resize: vertical;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.headingcheck-wrapper textarea {
    min-height: 160px;
}

.headingcheck-wrapper input[type="text"]:focus,
.headingcheck-wrapper textarea:focus {
    outline: none;
    border-color: var(--e-global-color-uicore_primary, #2563eb);
    box-shadow: 0 0 0 1px var(--e-global-color-uicore_primary, #2563eb);
}

/* ---------------------------
 * Sekcja przycisków
 * -------------------------- */

.headingcheck-actions {
    margin-top: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
}

.headingcheck-button-primary,
.headingcheck-button-secondary {
    min-width: 180px;
    padding-inline: 1.5rem;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
    cursor: pointer;
}

/* proporcje jak w slugify / metacheck */
.headingcheck-button-primary {
    flex: 2 1 220px;
}

.headingcheck-button-secondary {
    flex: 1 1 140px;
}

/* przycisk „Wyczyść” – analogicznie do metacheck */
.headingcheck-button-secondary {
    background-color: var(--e-global-color-uicore_light, #f9fafb);
    color: var(--e-global-color-uicore_primary, #2563eb);
    border: 1px solid var(--e-global-color-uicore_primary, #2563eb);
}

.headingcheck-button-secondary:hover {
    background-color: var(--e-global-color-uicore_primary, #2563eb);
    color: var(--e-global-color-uicore_white, #ffffff);
}

/* ---------------------------
 * Wyniki analizy – obszar wyników
 * -------------------------- */

.headingcheck-results {
    margin-top: 0.75rem;
}

/* ---------------------------
 * Podsumowanie ogólne + status
 * -------------------------- */

.headingcheck-summary {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 2fr);
    gap: 1rem;
    border-radius: 6px;
    border: 1px solid var(--e-global-color-uicore_light, #e5e7eb);
    background: var(--e-global-color-uicore_white, #ffffff);
    padding: 0.85rem 0.95rem 1rem;
    font-size: 0.9rem;
}

.headingcheck-summary-main {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.headingcheck-summary-messages {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.headingcheck-summary-heading {
    margin: 0 0 0.2rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #111827;
}

.headingcheck-subheading {
    margin: 0.35rem 0 0.3rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: #111827;
}

.headingcheck-summary-row {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
}

.headingcheck-summary-label {
    color: #374151;
}

.headingcheck-summary-value {
    white-space: nowrap;
    font-weight: 600;
}

/* status ogólny – ramka */
.headingcheck-summary.headingcheck-overall--good {
    border-color: #18b600;
}

.headingcheck-summary.headingcheck-overall--warn {
    border-color: #f59e0b;
}

.headingcheck-summary.headingcheck-overall--bad {
    border-color: #e30000;
}

/* ---------------------------
 * Informacje o URL i słowie kluczowym
 * -------------------------- */

.headingcheck-url-info {
    margin: 0.15rem 0;
    font-size: 0.86rem;
    color: #4b5563;
}

.headingcheck-url-info span {
    font-weight: 500;
}

.headingcheck-url-info--muted {
    color: #9ca3af;
}

.headingcheck-keyword-info {
    margin: 0.2rem 0;
    font-size: 0.86rem;
}

.headingcheck-keyword-info--good {
    color: #047857;
}

.headingcheck-keyword-info--warn {
    color: #92400e;
}

/* ---------------------------
 * Rozkład poziomów H1–H6
 * -------------------------- */

.headingcheck-levels-wrapper {
    margin-top: 0.3rem;
}

.headingcheck-levels {
    list-style: none;
    margin: 0.1rem 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    font-size: 0.84rem;
}

.headingcheck-level-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.45rem;
    border-radius: 999px;
    background: #f3f4f6;
}

.headingcheck-level-label {
    font-weight: 600;
    color: #111827;
}

.headingcheck-level-value {
    font-weight: 500;
    color: #4b5563;
}

/* ---------------------------
 * Alerty / rekomendacje
 * -------------------------- */

.headingcheck-alert-list {
    list-style: none;
    margin: 0.15rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.headingcheck-alert {
    position: relative;
    padding: 0.4rem 0.55rem 0.4rem 1.9rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.headingcheck-alert::before {
    content: "";
    position: absolute;
    left: 0.55rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 999px;
}

/* sukces */
.headingcheck-alert--success {
    background: #ecfdf3;
    color: #166534;
}

.headingcheck-alert--success::before {
    background: #16a34a;
}

/* ostrzeżenie */
.headingcheck-alert--warning {
    background: #fffbeb;
    color: #92400e;
}

.headingcheck-alert--warning::before {
    background: #f59e0b;
}

/* błąd */
.headingcheck-alert--error {
    background: #fef2f2;
    color: #b91c1c;
}

.headingcheck-alert--error::before {
    background: #ef4444;
}

/* info */
.headingcheck-alert--info {
    background: #eff6ff;
    color: #1d4ed8;
}

.headingcheck-alert--info::before {
    background: #3b82f6;
}

.headingcheck-alert-text {
    display: block;
}

/* ---------------------------
 * Panele: drzewo + duplikaty
 * -------------------------- */

.headingcheck-panel {
    margin-top: 0.9rem;
    padding: 0.85rem 0.95rem;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    font-size: 0.9rem;
}

.headingcheck-panel-heading {
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #111827;
}

/* ---------------------------
 * Drzewko nagłówków
 * -------------------------- */

.headingcheck-tree {
    list-style: none;
    margin: 0.3rem 0 0;
    padding-left: 0.75rem;
    border-left: 1px solid #e5e7eb;
}

.headingcheck-tree-item {
    position: relative;
    padding-left: 1.15rem;
    margin: 0.2rem 0;
}

.headingcheck-tree-item::before {
    content: "";
    position: absolute;
    left: -0.01rem;
    top: 0.95rem;
    width: 0.8rem;
    border-top: 1px solid #e5e7eb;
}

/* wiersz nagłówka w drzewku */
.headingcheck-tree-item-content {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
}

.headingcheck-tree-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    padding: 0.05rem 0.35rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    background: #e5e7eb;
    color: #111827;
}

.headingcheck-tree-text {
    font-size: 0.88rem;
    color: #111827;
}

.headingcheck-tree-index {
    font-size: 0.75rem;
    color: #9ca3af;
}

/* wyróżnienie nagłówków z keywordem */
.headingcheck-heading--keyword > .headingcheck-tree-item-content .headingcheck-tree-badge {
    background: #22c55e;
    color: #ffffff;
}

.headingcheck-heading--keyword > .headingcheck-tree-item-content .headingcheck-tree-text {
    font-weight: 600;
}

/* wyróżnienie duplikatów */
.headingcheck-heading--duplicate > .headingcheck-tree-item-content .headingcheck-tree-badge {
    background: #f97316;
    color: #111827;
}

.headingcheck-heading--duplicate > .headingcheck-tree-item-content .headingcheck-tree-text {
    text-decoration: underline dotted #f97316;
}

/* delikatne różnicowanie poziomów H2–H6 */
.headingcheck-heading--level-1 .headingcheck-tree-badge {
    background: #1d4ed8;
    color: #ffffff;
}

.headingcheck-heading--level-2 .headingcheck-tree-badge {
    background: #0ea5e9;
    color: #0f172a;
}

.headingcheck-heading--level-3 .headingcheck-tree-badge {
    background: #a5b4fc;
    color: #111827;
}

.headingcheck-heading--level-4 .headingcheck-tree-badge {
    background: #bfdbfe;
    color: #111827;
}

.headingcheck-heading--level-5 .headingcheck-tree-badge {
    background: #e5e7eb;
    color: #111827;
}

.headingcheck-heading--level-6 .headingcheck-tree-badge {
    background: #f3f4f6;
    color: #111827;
}

/* ---------------------------
 * Duplikaty – lista
 * -------------------------- */

.headingcheck-duplicates-list {
    list-style: none;
    margin: 0.25rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.86rem;
}

.headingcheck-duplicates-item {
    padding: 0.35rem 0.45rem;
    border-radius: 4px;
    background: #f9fafb;
}

.headingcheck-duplicates-text {
    display: block;
    font-weight: 500;
    color: #111827;
}

.headingcheck-duplicates-meta {
    display: block;
    margin-top: 0.1rem;
    font-size: 0.76rem;
    color: #6b7280;
}

/* ---------------------------
 * Komunikaty o błędach globalnych
 * -------------------------- */

.headingcheck-message {
    position: relative;
    margin-top: 0.5rem;
    padding: 0.65rem 1rem;
    border-radius: 6px;
    width: 100%;
    text-align: center;
    font-weight: 600;
    font-size: 0.95rem;
    color: #f9fafb;
}

.headingcheck-message-error {
    background: #e30000;
}

/* małe notki informacyjne */
.headingcheck-note {
    margin-top: 0.6rem;
    font-size: 0.82rem;
    color: #6b7280;
}

/* ---------------------------
 * Responsywność
 * -------------------------- */

@media (max-width: 768px) {
    .headingcheck-wrapper {
        padding: 1rem;
    }

    .headingcheck-summary {
        grid-template-columns: 1fr;
    }

    .headingcheck-summary-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .headingcheck-summary-value {
        white-space: normal;
    }

    .headingcheck-button-primary,
    .headingcheck-button-secondary {
        flex: 1 1 100%;
    }
}

@media (max-width: 640px) {
    .headingcheck-field-inline {
        flex-direction: column;
    }

    .headingcheck-tree {
        padding-left: 0.55rem;
    }
}