/* Outils SEO Gratuits — styles neutres et adaptatifs (héritent du thème) */

.osg-tool {
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 8px;
    padding: 1.25rem;
    margin: 1rem 0;
    background: rgba(255,255,255,0.6);
    font-size: 0.95rem;
    line-height: 1.5;
}
.osg-tool h3.osg-section-title {
    margin: 0 0 0.75rem 0;
    font-size: 1.05rem;
    font-weight: 600;
}
.osg-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }
.osg-row > * { flex: 0 0 auto; }
.osg-row.grow > input[type="text"],
.osg-row.grow > input[type="url"] { flex: 1 1 240px; min-width: 200px; }

.osg-field { display: block; margin-bottom: 0.75rem; }
.osg-field label { display: block; font-weight: 600; margin-bottom: 0.25rem; font-size: 0.9rem; }
.osg-field .osg-hint { font-size: 0.8rem; opacity: 0.7; margin-top: 0.25rem; }

.osg-tool input[type="text"],
.osg-tool input[type="url"],
.osg-tool input[type="number"],
.osg-tool select,
.osg-tool textarea {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid rgba(0,0,0,0.2);
    border-radius: 4px;
    font: inherit;
    background: #fff;
    color: inherit;
    box-sizing: border-box;
}
.osg-tool textarea { min-height: 120px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.osg-tool textarea.osg-mono-tall { min-height: 200px; }

.osg-btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.2);
    background: #f5f5f5;
    color: inherit;
    cursor: pointer;
    font: inherit;
    transition: background 0.15s;
}
.osg-btn:hover { background: #e8e8e8; }
.osg-btn.osg-btn-primary { background: #2271b1; color: #fff; border-color: #2271b1; }
.osg-btn.osg-btn-primary:hover { background: #135e96; }
.osg-btn.osg-btn-ghost { background: transparent; }
.osg-btn.osg-btn-small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.osg-btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.osg-alert { padding: 0.6rem 0.8rem; border-radius: 4px; margin: 0.5rem 0; border-left: 4px solid; }
.osg-alert-info    { background: #e7f3fe; border-color: #2271b1; color: #135e96; }
.osg-alert-success { background: #e6f4ea; border-color: #2e7d32; color: #1b5e20; }
.osg-alert-warning { background: #fff8e1; border-color: #f9a825; color: #7a5b00; }
.osg-alert-error   { background: #fdecea; border-color: #c62828; color: #8a1a14; }

.osg-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #eee;
    color: #333;
    margin-right: 0.25rem;
}
.osg-badge-ok    { background: #c8e6c9; color: #1b5e20; }
.osg-badge-warn  { background: #fff3cd; color: #7a5b00; }
.osg-badge-err   { background: #f8d7da; color: #8a1a14; }
.osg-badge-info  { background: #d6eaff; color: #135e96; }

.osg-counter { font-size: 0.85rem; opacity: 0.75; }

.osg-tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid rgba(0,0,0,0.12); margin-bottom: 1rem; flex-wrap: wrap; }
.osg-tab-btn {
    background: none; border: none; padding: 0.5rem 1rem; cursor: pointer;
    border-bottom: 3px solid transparent; font: inherit; color: inherit;
}
.osg-tab-btn.is-active { border-bottom-color: #2271b1; font-weight: 600; }
.osg-tab-panel { display: none; }
.osg-tab-panel.is-active { display: block; }

.osg-result { margin-top: 1rem; }
.osg-result-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 0.25rem 1rem; font-size: 0.9rem; }
.osg-result-grid dt { font-weight: 600; opacity: 0.8; }
.osg-result-grid dd { margin: 0; word-break: break-word; }

.osg-list { list-style: none; padding: 0; margin: 0; }
.osg-list li { padding: 0.25rem 0; border-bottom: 1px dashed rgba(0,0,0,0.08); word-break: break-word; }
.osg-list li:last-child { border-bottom: none; }

.osg-code-output {
    display: block;
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 1rem;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
    white-space: pre;
    overflow-x: auto;
    margin: 0.5rem 0;
}

/* SERP preview — réplique du résultat Google (light) */
.osg-serp-preview {
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    padding: 14px 16px 16px;
    background: #fff;
    font-family: arial, Roboto, "Helvetica Neue", sans-serif;
    color: #202124;
    max-width: 600px;
}
.osg-serp-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}
.osg-serp-favicon {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid #dadce0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    flex: 0 0 auto;
    overflow: hidden;
}
.osg-serp-favicon-img {
    width: 18px;
    height: 18px;
    object-fit: contain;
    display: block;
}
.osg-serp-meta {
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.3;
}
.osg-serp-sitename {
    font-size: 14px;
    color: #202124;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.osg-serp-url {
    font-size: 12px;
    color: #4d5156;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.osg-serp-menu {
    color: #4d5156;
    font-size: 20px;
    line-height: 1;
    padding: 0 4px;
    flex: 0 0 auto;
    cursor: default;
    user-select: none;
}
.osg-serp-title {
    color: #1a0dab;
    font-size: 20px;
    line-height: 1.3;
    margin: 6px 0 4px;
    cursor: pointer;
    font-weight: 400;
}
.osg-serp-title:hover { text-decoration: underline; }
.osg-serp-desc {
    color: #4d5156;
    font-size: 14px;
    line-height: 1.58;
}

.osg-loading { display: inline-block; padding: 0.25rem 0.5rem; font-size: 0.85rem; opacity: 0.7; }
.osg-loading::after {
    content: '...';
    display: inline-block;
    animation: osg-dot 1.2s infinite steps(4, end);
    width: 1em; text-align: left;
}
@keyframes osg-dot { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

.osg-meta-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0.25rem 0; }

.osg-table { width: 100%; border-collapse: collapse; margin: 0.5rem 0; font-size: 0.9rem; }
.osg-table th, .osg-table td { padding: 0.4rem 0.6rem; border-bottom: 1px solid rgba(0,0,0,0.08); text-align: left; vertical-align: top; }
.osg-table th { background: rgba(0,0,0,0.04); font-weight: 600; }

.osg-kv-row {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) 80px 80px auto;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.4rem;
}
.osg-kv-row input { width: 100%; box-sizing: border-box; }
.osg-kv-row .osg-btn { padding: 0.3rem 0.6rem; }

/* Checkbox list — defensive overrides against theme form styles.
   Some themes (Astra, Kadence, GeneratePress, Divi) apply grid/flex centering,
   width:100% on labels, or transform/margin on checkboxes inside .entry-content,
   which breaks the inline checkbox+label layout. The !important rules below
   restore the expected left-aligned, single-row look. */
.osg-tool .osg-checkbox-list {
    display: block !important;
    text-align: left !important;
    width: 100% !important;
}
.osg-tool .osg-checkbox-list label {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 0.4rem !important;
    padding: 0.2rem 0 !important;
    margin: 0 !important;
    width: auto !important;
    max-width: none !important;
    font-weight: normal !important;
    text-align: left !important;
    white-space: normal !important;
    line-height: 1.4 !important;
    float: none !important;
    clear: none !important;
}
.osg-tool .osg-checkbox-list label input[type="checkbox"] {
    flex: 0 0 auto !important;
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    max-width: 16px !important;
    margin: 0 !important;
    padding: 0 !important;
    position: static !important;
    transform: none !important;
    appearance: auto !important;
    -webkit-appearance: checkbox !important;
    opacity: 1 !important;
    vertical-align: middle !important;
    float: none !important;
}
.osg-tool .osg-checkbox-list label .osg-counter {
    margin-left: 0.4rem !important;
    flex: 0 1 auto !important;
}

/* Generic safety net for checkboxes anywhere in a tool.
   Themes often shrink/grow/restyle native checkboxes, which causes them to
   wrap onto their own line above the label text (visible in the screenshot
   of the keyword-density tool). Force the native checkbox appearance with a
   fixed inline size, regardless of which container the input lives in. */
.osg-tool input[type="checkbox"] {
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    max-width: 16px !important;
    margin: 0 0.35em 0 0 !important;
    padding: 0 !important;
    position: static !important;
    transform: none !important;
    appearance: auto !important;
    -webkit-appearance: checkbox !important;
    opacity: 1 !important;
    vertical-align: middle !important;
    float: none !important;
    display: inline-block !important;
}

/* Inline checkbox+label pattern: <label><input type="checkbox"> Text</label>
   Use :has() to target labels that directly contain a checkbox so we don't
   break the column layout of <label>+separate-input used by .osg-field.
   :has() supports: Chrome 105+, Safari 15.4+, Firefox 121+. */
.osg-tool label:has(> input[type="checkbox"]) {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 0.35rem !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    font-weight: normal !important;
    text-align: left !important;
    line-height: 1.4 !important;
    float: none !important;
    clear: none !important;
    white-space: normal !important;
}

@media (max-width: 600px) {
    .osg-result-grid { grid-template-columns: 1fr; }
    .osg-kv-row { grid-template-columns: 1fr; }
}

/* Help tooltip — small "?" icon, content in data-tip */
.osg-help {
    display: inline-flex;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #6c757d;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    align-items: center;
    justify-content: center;
    cursor: help;
    position: relative;
    margin-left: 6px;
    vertical-align: middle;
    user-select: none;
    font-family: arial, sans-serif;
}
.osg-help::before { content: "?"; line-height: 1; }
.osg-help::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: #fff;
    padding: 0.55rem 0.75rem;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.45;
    white-space: pre-line;
    width: 280px;
    text-align: left;
    box-shadow: 0 4px 14px rgba(0,0,0,0.18);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.12s;
    z-index: 100;
}
.osg-help:hover::after,
.osg-help:focus::after { opacity: 1; visibility: visible; }
@media (max-width: 500px) {
    .osg-help::after { width: 220px; left: 0; transform: none; }
}

/* Comparator result sections */
.osg-compare-section {
    margin: 0.75rem 0 1rem;
    padding: 0.6rem 0.75rem;
    background: rgba(0,0,0,0.02);
    border-left: 3px solid #2271b1;
    border-radius: 4px;
}
.osg-compare-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
}
.osg-compare-actions {
    margin-left: auto;
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}
.osg-compare-textarea {
    width: 100%;
    min-height: 70px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.45;
    padding: 0.4rem 0.5rem;
    border: 1px solid rgba(0,0,0,0.15);
    border-radius: 4px;
    background: #fff;
    color: inherit;
    resize: vertical;
    box-sizing: border-box;
    white-space: pre;
    overflow: auto;
}
