/* ════════════════════════════════════════════════════════════════════════════
   RECATOOLS — Keyword Density Checker — style.css
   Tool-specific overrides only.
   Base styles live in /assets/css/tool-page.css.
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Textarea input ──────────────────────────────────────────────────────────── */
.kd-textarea {
    width: 100%;
    min-height: 220px;
    resize: vertical;
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 0.9375rem;
    line-height: 1.65;
    padding: 0.875rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    transition: border-color 0.15s;
    box-sizing: border-box;
}
.kd-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(232,98,42,0.12);
}
.kd-textarea::placeholder {
    color: var(--muted);
}

/* ── Keyword input row ───────────────────────────────────────────────────────── */
.kd-keyword-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}
.kd-keyword-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}
.kd-keyword-input {
    flex: 1;
    min-width: 200px;
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 0.9375rem;
    padding: 0.625rem 0.875rem;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    transition: border-color 0.15s;
}
.kd-keyword-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(232,98,42,0.12);
}
.kd-keyword-input::placeholder {
    color: var(--muted);
}

/* ── Input meta row ──────────────────────────────────────────────────────────── */
.kd-input-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: var(--muted);
}

/* ── Action row ──────────────────────────────────────────────────────────────── */
.kd-action-row {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}
.kd-action-row .btn-primary {
    flex: 1;
    min-width: 160px;
}

/* ── Results section ─────────────────────────────────────────────────────────── */
.kd-results {
    margin-top: 1.75rem;
    animation: kd-fade-in 0.25s ease;
}
@keyframes kd-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Stats row ───────────────────────────────────────────────────────────────── */
.kd-stats-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}
.kd-stat {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.kd-stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}
.kd-stat-val {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    font-family: 'IBM Plex Serif', serif;
}
.kd-stat-sep {
    color: var(--muted);
    margin: 0 0.25rem;
}

/* ── Target keyword summary ──────────────────────────────────────────────────── */
.kd-target-summary {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.75rem 1rem;
    background: rgba(232,98,42,0.08);
    border: 1.5px solid var(--accent);
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9375rem;
}

/* ── Legend ──────────────────────────────────────────────────────────────────── */
.kd-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}
.kd-legend-item {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    border: 1.5px solid transparent;
}
.kd-legend-item.density-grey   { background: #f2f2f2; color: #888; border-color: #ddd; }
.kd-legend-item.density-green  { background: #edfbf1; color: #1a7a3a; border-color: #a8e6ba; }
.kd-legend-item.density-orange { background: #fff7ed; color: #b45309; border-color: #fcd38b; }
.kd-legend-item.density-red    { background: #fef2f2; color: #b91c1c; border-color: #fca5a5; }

/* ── Tabs ────────────────────────────────────────────────────────────────────── */
.kd-tabs {
    display: flex;
    gap: 0.375rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}
.kd-tab {
    background: transparent;
    border: none;
    border-bottom: 2.5px solid transparent;
    margin-bottom: -2px;
    padding: 0.625rem 1rem;
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    border-radius: 4px 4px 0 0;
}
.kd-tab:hover {
    color: var(--accent);
}
.kd-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.kd-tabpanel {
    /* visible by default; hidden attribute added via JS */
}

/* ── Table ───────────────────────────────────────────────────────────────────── */
.kd-table-wrap {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid var(--border);
}
.kd-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    background: #fff;
}
.kd-table thead th {
    background: var(--bg);
    padding: 0.625rem 0.875rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.kd-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}
.kd-table tbody tr:last-child {
    border-bottom: none;
}
.kd-table tbody tr:hover {
    background: var(--bg);
}
.kd-table td {
    padding: 0.5rem 0.875rem;
    vertical-align: middle;
}
.kd-rank {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted);
    white-space: nowrap;
    min-width: 50px;
}
.kd-phrase {
    font-weight: 500;
    font-family: 'SFMono-Regular', 'Consolas', monospace;
    font-size: 0.875rem;
}
.kd-count {
    text-align: right;
    font-weight: 700;
    min-width: 55px;
}
.kd-density {
    min-width: 120px;
    white-space: nowrap;
}
.kd-density-val {
    font-weight: 700;
    margin-right: 0.375rem;
}
.kd-density-label {
    font-size: 0.75rem;
    color: var(--muted);
}
.kd-bar-col {
    min-width: 100px;
    width: 18%;
}
.kd-bar-cell {
    padding-right: 1rem;
}
.kd-bar-track {
    background: var(--border);
    border-radius: 999px;
    height: 6px;
    overflow: hidden;
    min-width: 60px;
}
.kd-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
    transition: width 0.4s ease;
}

/* ── Row colour coding ───────────────────────────────────────────────────────── */
.density-grey   .kd-density-val { color: #888; }
.density-green  .kd-density-val { color: #1a7a3a; }
.density-orange .kd-density-val { color: #b45309; }
.density-red    .kd-density-val { color: #b91c1c; }

.density-grey   .kd-bar-fill { background: #c4c4c4; }
.density-green  .kd-bar-fill { background: #2da651; }
.density-orange .kd-bar-fill { background: #f59e0b; }
.density-red    .kd-bar-fill { background: #ef4444; }

/* ── Target row highlight ────────────────────────────────────────────────────── */
.kd-target-row {
    background: rgba(232,98,42,0.06) !important;
    outline: 1.5px solid var(--accent);
    outline-offset: -1px;
}
.kd-target-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--accent);
    color: #fff;
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
    margin-left: 0.375rem;
    vertical-align: middle;
}

/* ── Empty state ─────────────────────────────────────────────────────────────── */
.kd-empty {
    padding: 2rem;
    text-align: center;
    color: var(--muted);
    font-style: italic;
}

/* ── CSV export button ───────────────────────────────────────────────────────── */
.kd-export-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
}
.kd-csv-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    border: 1.5px solid var(--accent);
    color: var(--accent);
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.kd-csv-btn:hover {
    background: var(--accent);
    color: #fff;
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .kd-stats-row {
        gap: 0.75rem;
    }
    .kd-stat-val {
        font-size: 1rem;
    }
    .kd-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .kd-tab {
        white-space: nowrap;
    }
    .kd-bar-col,
    .kd-bar-cell {
        display: none;
    }
    .kd-keyword-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .kd-keyword-input {
        width: 100%;
    }
}

/* cache-buster: 2026-05-24T05:06:05Z */
