/* ==========================================================================
   Heading Structure Analyser — hsa-style.css
   Prefix: hsa-
   ========================================================================== */

.hsa-wrap *, .hsa-wrap *::before, .hsa-wrap *::after { box-sizing: border-box; }

.hsa-wrap {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: #1f2937;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px 48px;
    position: relative;
}

.hsa-main-title    { font-size: 1.55rem; font-weight: 700; color: #111827; margin: 0 0 8px; }
.hsa-main-subtitle { font-size: 0.92rem; color: #6b7280; margin: 0 0 26px; }

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
.hsa-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
    align-items: start;
}
@media (max-width: 820px) { .hsa-layout { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.hsa-card {
    background: #fff;
    border: 1px solid #dde3ea;
    border-radius: 10px;
    padding: 22px 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.hsa-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f2f5;
}

/* --------------------------------------------------------------------------
   Input tabs
   -------------------------------------------------------------------------- */
.hsa-input-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 18px;
}

.hsa-input-tab {
    padding: 8px 18px;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    color: #6b7280;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.hsa-input-tab:hover          { color: #2563eb; }
.hsa-input-tab-active         { color: #2563eb; border-bottom-color: #2563eb; }

.hsa-input-panel              { display: none; }
.hsa-input-panel-active       { display: block; }

/* --------------------------------------------------------------------------
   Fields
   -------------------------------------------------------------------------- */
.hsa-field { margin-bottom: 16px; }

.hsa-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #374151;
    margin-bottom: 5px;
}

.hsa-req  { color: #e53935; }
.hsa-hint { font-size: 0.75rem; color: #9ca3af; margin: 4px 0 0; }

.hsa-field input[type="url"],
.hsa-field textarea {
    width: 100%;
    padding: 9px 12px;
    font-size: 0.9rem;
    font-family: inherit;
    border: 1.5px solid #d1d5db;
    border-radius: 6px;
    background: #fafafa;
    color: #1f2937;
    transition: border-color 0.2s;
    resize: vertical;
}
.hsa-field input:focus,
.hsa-field textarea:focus {
    outline: none;
    border-color: #2563eb;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.hsa-btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.hsa-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: 7px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.hsa-btn-sm      { padding: 6px 14px; font-size: 0.8rem; }
.hsa-btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.hsa-btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
.hsa-btn-outline { background: transparent; color: #2563eb; border-color: #2563eb; }
.hsa-btn-outline:hover { background: #eff6ff; }
.hsa-btn-ghost   { background: transparent; color: #6b7280; border-color: #e5e7eb; }
.hsa-btn-ghost:hover { background: #f9fafb; }

/* --------------------------------------------------------------------------
   Error
   -------------------------------------------------------------------------- */
.hsa-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 7px;
    color: #991b1b;
    padding: 10px 14px;
    font-size: 0.86rem;
    margin-top: 12px;
}

/* --------------------------------------------------------------------------
   "What we check" card
   -------------------------------------------------------------------------- */
.hsa-checks-card { background: #f8faff; }

.hsa-checks-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.hsa-checks-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #374151;
}

.hsa-badge {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 7px;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}
.hsa-badge-error   { background: #fee2e2; color: #dc2626; }
.hsa-badge-warning { background: #fef3c7; color: #d97706; }
.hsa-badge-info    { background: #e0e7ff; color: #3730a3; }
.hsa-badge-good    { background: #dcfce7; color: #16a34a; }

/* --------------------------------------------------------------------------
   Placeholder
   -------------------------------------------------------------------------- */
.hsa-placeholder {
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
}
.hsa-placeholder-icon {
    font-size: 3rem;
    font-weight: 900;
    color: #cbd5e1;
    line-height: 1;
    margin-bottom: 12px;
    font-family: Georgia, serif;
}
.hsa-placeholder p { font-size: 0.9rem; margin: 0; }

/* --------------------------------------------------------------------------
   Score + level counts
   -------------------------------------------------------------------------- */
.hsa-score-row {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.hsa-score-block {
    text-align: center;
    min-width: 80px;
}

.hsa-score-grade {
    font-size: 3rem;
    font-weight: 900;
    line-height: 1;
    margin-bottom: 4px;
}
.hsa-grade-a  { color: #16a34a; }
.hsa-grade-b  { color: #65a30d; }
.hsa-grade-c  { color: #d97706; }
.hsa-grade-d  { color: #ea580c; }
.hsa-grade-f  { color: #dc2626; }

.hsa-score-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280;
}

.hsa-level-counts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}

.hsa-level-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 52px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1.5px solid;
}
.hsa-level-badge-num {
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1;
}
.hsa-level-badge-lbl {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

/* Heading level colours */
.hsa-h1 { border-color: #bfdbfe; background: #eff6ff; color: #1d4ed8; }
.hsa-h2 { border-color: #ddd6fe; background: #f5f3ff; color: #6d28d9; }
.hsa-h3 { border-color: #bbf7d0; background: #f0fdf4; color: #15803d; }
.hsa-h4 { border-color: #fed7aa; background: #fff7ed; color: #c2410c; }
.hsa-h5 { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }
.hsa-h6 { border-color: #e5e7eb; background: #f9fafb; color: #4b5563; }

.hsa-source-url {
    font-size: 0.78rem;
    color: #6b7280;
    margin-top: 12px;
    word-break: break-all;
    padding-top: 10px;
    border-top: 1px solid #f0f2f5;
}
.hsa-source-url a { color: #2563eb; }

/* --------------------------------------------------------------------------
   Issues list
   -------------------------------------------------------------------------- */
.hsa-issues-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f2f5;
}
.hsa-issues-header .hsa-card-title { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }

.hsa-issue-count {
    font-size: 0.78rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 12px;
    background: #f3f4f6;
    color: #374151;
}

.hsa-issues-empty {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    color: #15803d;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 7px;
    padding: 10px 14px;
}

.hsa-issue-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 7px;
    margin-bottom: 8px;
    font-size: 0.86rem;
    line-height: 1.5;
}
.hsa-issue-item:last-child { margin-bottom: 0; }

.hsa-issue-error   { background: #fef2f2; border: 1px solid #fca5a5; }
.hsa-issue-warning { background: #fffbeb; border: 1px solid #fde68a; }
.hsa-issue-info    { background: #eff6ff; border: 1px solid #bfdbfe; }

.hsa-issue-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.hsa-issue-text { flex: 1; }
.hsa-issue-text strong { display: block; margin-bottom: 2px; }

/* --------------------------------------------------------------------------
   Heading outline
   -------------------------------------------------------------------------- */
.hsa-outline-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 4px;
}
.hsa-outline-header .hsa-card-title { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }

.hsa-outline {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.hsa-outline-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 5px 10px;
    border-radius: 5px;
    line-height: 1.4;
    transition: background 0.1s;
}
.hsa-outline-item:hover { background: #f8fafc; }

.hsa-outline-tag {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1px 6px;
    border-radius: 4px;
    flex-shrink: 0;
    min-width: 28px;
    text-align: center;
}

/* Level indents */
.hsa-indent-1 { padding-left: 10px;  }
.hsa-indent-2 { padding-left: 30px;  }
.hsa-indent-3 { padding-left: 50px;  }
.hsa-indent-4 { padding-left: 70px;  }
.hsa-indent-5 { padding-left: 90px;  }
.hsa-indent-6 { padding-left: 110px; }

/* Level tag colours */
.hsa-tag-h1 { background: #eff6ff; color: #1d4ed8; }
.hsa-tag-h2 { background: #f5f3ff; color: #6d28d9; }
.hsa-tag-h3 { background: #f0fdf4; color: #15803d; }
.hsa-tag-h4 { background: #fff7ed; color: #c2410c; }
.hsa-tag-h5 { background: #fef2f2; color: #b91c1c; }
.hsa-tag-h6 { background: #f9fafb; color: #4b5563; }

.hsa-outline-text {
    font-size: 0.88rem;
    color: #1f2937;
    flex: 1;
    word-break: break-word;
}

/* Flag skipped-level items */
.hsa-outline-item.hsa-skip-warn .hsa-outline-text::after {
    content: ' ⚠';
    color: #d97706;
    font-size: 0.8em;
}

/* Empty heading highlight */
.hsa-outline-item.hsa-empty-warn .hsa-outline-text {
    color: #9ca3af;
    font-style: italic;
}

/* --------------------------------------------------------------------------
   Loading overlay
   -------------------------------------------------------------------------- */
.hsa-loading {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.88);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    border-radius: 10px;
    z-index: 10;
    backdrop-filter: blur(2px);
}
.hsa-loading p { font-size: 0.95rem; color: #4b5563; font-weight: 500; margin: 0; }

.hsa-spinner {
    width: 42px; height: 42px;
    border: 4px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: hsa-spin 0.75s linear infinite;
}
@keyframes hsa-spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 600px) {
    .hsa-card    { padding: 16px 14px; }
    .hsa-btn     { width: 100%; justify-content: center; }
    .hsa-btn-row { flex-direction: column; }
    .hsa-btn-sm  { width: auto; }
    .hsa-score-row { flex-direction: column; align-items: flex-start; }
}
