/* Title Tag Generator , tool-specific styles.
 * Composes shared primitives in code/assets/css/tools.css (.tool-form-card,
 * .mode-toggle, .quota-chip, .results-region, .history-region, etc.).
 *
 * Key gotchas the project has hit repeatedly and we guard against here:
 *  - .mode-toggle pill: shared rule hardcoded for data-mode="bulk"; we
 *    override with data-mode="topic"/"url" so the pill slides correctly.
 *  - [hidden] + display:flex/grid: every panel that uses display:flex/grid
 *    AND toggles via the `hidden` attribute needs a per-tool override.
 *  - .results-region card-stack inner padding: shared region has no
 *    padding (sticky-header dependency); a card stack inside needs its
 *    own padding wrapper.
 */

/* ---- Mode toggle ---------------------------------------------------- */
.mode-toggle[data-mode="topic"]::before { transform: translateX(0); }
.mode-toggle[data-mode="url"]::before   { transform: translateX(100%); }

/* ---- Form layout ---------------------------------------------------- */
.ttg-mode-body { margin-bottom: 18px; }
.ttg-fullwidth { flex: 0 0 auto; width: 100%; box-sizing: border-box; }
.ttg-mode-hint { color: var(--ink-500, #788196); font-weight: 400; font-size: 0.85em; margin-left: 8px; }

.ttg-options-row {
    display: grid;
    grid-template-columns: 1.4fr 0.9fr 0.9fr;
    gap: 14px;
    margin-bottom: 14px;
}
@media (max-width: 720px) {
    .ttg-options-row { grid-template-columns: 1fr; }
}

.ttg-kw-preview {
    margin-top: 6px;
    font-size: 0.85em;
    color: var(--ink-700, #4a5568);
    padding: 6px 10px;
    background: var(--ink-50, #f4f6fa);
    border-radius: 6px;
    line-height: 1.5;
}
.ttg-kw-preview[hidden] { display: none; }

.ttg-styles-row { margin-bottom: 14px; }
.ttg-styles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 8px;
}
@media (max-width: 560px) {
    .ttg-styles-grid { grid-template-columns: repeat(2, 1fr); }
}
.ttg-style-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--ink-50, #f4f6fa);
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.92em;
    user-select: none;
    transition: border-color 120ms, background 120ms;
}
.ttg-style-option:hover { border-color: var(--brand-200, #b4cdff); }
.ttg-style-checkbox { margin: 0; }

.ttg-serp-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}
.ttg-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    font-size: 0.92em;
}
.ttg-toggle input { appearance: none; -webkit-appearance: none; width: 0; height: 0; opacity: 0; position: absolute; }
.ttg-toggle-track {
    width: 34px; height: 18px;
    background: var(--ink-200, #cbd2dc);
    border-radius: 18px;
    position: relative;
    transition: background 150ms;
    flex: 0 0 34px;
}
.ttg-toggle-track::after {
    content: '';
    position: absolute;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: #fff;
    top: 2px; left: 2px;
    transition: transform 150ms;
}
.ttg-toggle input:checked ~ .ttg-toggle-track { background: var(--brand-500, #4076ff); }
.ttg-toggle input:checked ~ .ttg-toggle-track::after { transform: translateX(16px); }

.ttg-serp-loc-control { position: relative; }
.ttg-serp-loc-control[hidden] { display: none; }
.ttg-loc-results {
    position: absolute;
    top: 100%; left: 0; right: 0;
    z-index: 30;
    background: #fff;
    border: 1px solid var(--ink-200, #cbd2dc);
    border-radius: 6px;
    margin: 4px 0 0;
    padding: 4px 0;
    max-height: 240px;
    overflow-y: auto;
    list-style: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.07);
}
.ttg-loc-results[hidden] { display: none; }
.ttg-loc-result {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9em;
}
.ttg-loc-result:hover { background: var(--ink-50, #f4f6fa); }

.ttg-submit-row { margin-top: 10px; }

/* ---- Quota chips ---------------------------------------------------- */
.ttg-chips-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

/* ---- Results region ------------------------------------------------- */
.results-region { scroll-margin-top: 16px; }
.ttg-result-body { padding: 18px 22px 4px; }
.ttg-result-body > *:last-child { margin-bottom: 18px; }

/* ---- Audited block (what we generated for) ------------------------- */
.ttg-audited {
    padding: 14px 18px;
    background: var(--ink-50, #f4f6fa);
    border-left: 4px solid var(--brand-500, #4076ff);
    border-radius: 6px;
    margin-bottom: 20px;
}
.ttg-audited[hidden] { display: none; }
.ttg-audited-label {
    display: block;
    font-size: 0.72em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-500, #788196);
    font-weight: 600;
    margin-bottom: 4px;
}
.ttg-audited-title {
    display: block;
    font-size: 1.05em;
    font-weight: 600;
    color: var(--ink-900, #1a202c);
    line-height: 1.4;
}
.ttg-audited-url {
    display: block;
    font-size: 0.85em;
    color: var(--brand-700, #2b59e0);
    margin-top: 4px;
    word-break: break-all;
}
.ttg-audited-url:hover { text-decoration: underline; }
.ttg-audited-url[hidden] { display: none; }

/* ---- 2-column layout ----------------------------------------------- */
.ttg-results-grid {
    display: grid;
    grid-template-columns: 1.4fr 0.85fr;
    gap: 20px;
}
@media (max-width: 880px) {
    .ttg-results-grid { grid-template-columns: 1fr; }
}

.ttg-cards-col, .ttg-stats-col { min-width: 0; }

/* ---- Card -------------------------------------------------------- */
.ttg-card {
    background: #fff;
    border: 1px solid var(--ink-200, #e4e8ef);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 12px;
    transition: box-shadow 150ms;
}
.ttg-card.is-regenerating { opacity: 0.6; }
.ttg-card:hover { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04); }

.ttg-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.ttg-style-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7em;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: var(--brand-50, #e6efff);
    color: var(--brand-700, #2b59e0);
}
.ttg-style-badge-existing { background: var(--ink-100, #e4e8ef); color: var(--ink-700, #4a5568); }
.ttg-style-badge-how-to     { background: #e7f6ec; color: #226c3a; }
.ttg-style-badge-listicle   { background: #fff4e0; color: #8a5a00; }
.ttg-style-badge-question   { background: #ecebff; color: #4639b9; }
.ttg-style-badge-comparison { background: #fff0f0; color: #b13c3c; }
.ttg-style-badge-best-of    { background: #fef4d9; color: #876200; }
.ttg-style-badge-descriptive { background: var(--ink-100, #e4e8ef); color: var(--ink-700, #4a5568); }

.ttg-kw-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 600;
}
.ttg-kw-pill-full    { background: #e7f6ec; color: #226c3a; }
.ttg-kw-pill-partial { background: #fff4e0; color: #8a5a00; }
.ttg-kw-pill-missing { background: #fff0f0; color: #b13c3c; }

.ttg-card-text-wrap { margin-bottom: 12px; }
.ttg-card-text {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--ink-200, #e4e8ef);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 1.02em;
    font-weight: 500;
    line-height: 1.45;
    resize: none;
    outline: none;
    color: var(--ink-900, #1a202c);
    background: var(--ink-50, #f8fafc);
    overflow: hidden;
    font-family: inherit;
}
.ttg-card-text:focus { border-color: var(--brand-500, #4076ff); background: #fff; }

.ttg-card-text-readonly {
    display: block;
    padding: 8px 12px;
    background: var(--ink-50, #f4f6fa);
    border-radius: 6px;
    font-size: 1em;
    color: var(--ink-900, #1a202c);
    font-weight: 500;
}

/* ---- Pixel bars --------------------------------------------------- */
.ttg-card-bars {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    margin-bottom: 10px;
}
.ttg-pixel-bar {
    display: grid;
    grid-template-columns: 64px 1fr 110px;
    gap: 8px;
    align-items: center;
}
.ttg-pixel-bar-label {
    font-size: 0.78em;
    color: var(--ink-500, #788196);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.ttg-pixel-bar-track {
    position: relative;
    height: 8px;
    background: var(--ink-100, #e4e8ef);
    border-radius: 4px;
    overflow: hidden;
}
.ttg-pixel-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #5fa856, #4a9d4a);
    width: 0;
    transition: width 200ms, background 200ms;
}
.ttg-pixel-bar-fill.is-warning {
    background: linear-gradient(90deg, #f4ad42, #f49342);
}
.ttg-pixel-bar-fill.is-danger {
    background: linear-gradient(90deg, #e85c5c, #d94545);
}
.ttg-pixel-bar-budget {
    position: absolute;
    top: -2px;
    width: 1px;
    height: 12px;
    background: var(--ink-500, #788196);
    pointer-events: none;
    margin-left: -1px;
}
.ttg-pixel-bar-text {
    font-size: 0.75em;
    color: var(--ink-700, #4a5568);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ---- Card foot (counts + actions) -------------------------------- */
.ttg-card-foot {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82em;
}
.ttg-card-charcount {
    color: var(--ink-500, #788196);
    font-variant-numeric: tabular-nums;
}
.ttg-card-foot-spacer { flex: 1; }
.ttg-icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: 1px solid var(--ink-200, #e4e8ef);
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.85em;
    color: var(--ink-700, #4a5568);
    transition: border-color 120ms, background 120ms, color 120ms;
}
.ttg-icon-btn:hover { border-color: var(--brand-500, #4076ff); color: var(--brand-700, #2b59e0); background: var(--brand-50, #e6efff); }
.ttg-icon-btn:disabled { opacity: 0.55; cursor: wait; }

/* ---- Keyword stats card (right rail) ------------------------------ */
.ttg-kw-card {
    background: #fff;
    border: 1px solid var(--ink-200, #e4e8ef);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
}
.ttg-kw-card[hidden] { display: none; }
.ttg-kw-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 6px;
    gap: 10px;
}
.ttg-kw-card-head strong { font-size: 0.9em; }
.ttg-kw-card-keyword {
    font-size: 0.78em;
    color: var(--brand-700, #2b59e0);
    word-break: break-word;
    text-align: right;
}
.ttg-kw-stats { display: flex; flex-direction: column; gap: 2px; }
.ttg-kw-stat {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 0;
}
.ttg-kw-stat-label {
    font-size: 0.74em;
    color: var(--ink-500, #788196);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.ttg-kw-stat-value {
    font-size: 0.88em;
    font-weight: 600;
    color: var(--ink-900, #1a202c);
}
.ttg-kw-trend {
    margin-top: 4px;
    color: var(--brand-500, #4076ff);
}
.ttg-kw-trend-label {
    display: block;
    font-size: 0.68em;
    color: var(--ink-500, #788196);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0;
}

/* ---- SERP top-10 panel (right rail) ------------------------------ */
.ttg-serp-panel {
    background: #fff;
    border: 1px solid var(--ink-200, #e4e8ef);
    border-radius: 8px;
    padding: 14px 16px;
}
.ttg-serp-panel[hidden] { display: none; }
.ttg-serp-panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.ttg-serp-panel-head strong { font-size: 0.92em; }
.ttg-serp-panel-meta {
    font-size: 0.78em;
    color: var(--ink-500, #788196);
}
.ttg-serp-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ttg-serp-item {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 8px;
    padding: 8px 0;
    border-top: 1px dashed var(--ink-100, #e4e8ef);
}
.ttg-serp-item:first-child { border-top: none; padding-top: 0; }
.ttg-serp-rank {
    font-weight: 600;
    font-size: 0.85em;
    color: var(--ink-500, #788196);
    font-variant-numeric: tabular-nums;
}
.ttg-serp-item-body { min-width: 0; }
.ttg-serp-item-title {
    font-size: 0.92em;
    color: var(--ink-900, #1a202c);
    line-height: 1.4;
    word-break: break-word;
}
.ttg-serp-item-meta {
    font-size: 0.75em;
    color: var(--ink-500, #788196);
    margin-top: 2px;
}
.ttg-serp-ob {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    background: #fff0f0;
    color: #b13c3c;
    font-size: 0.85em;
    font-weight: 600;
}
.ttg-serp-item-domain { color: var(--brand-700, #2b59e0); }

/* ---- History --------------------------------------------------- */
/* shared .history-item-* primitives in tools.css */

/* ---- Mobile bar layout fallback -------------------------------- */
@media (max-width: 560px) {
    .ttg-pixel-bar { grid-template-columns: 56px 1fr 90px; }
    .ttg-card-foot { flex-wrap: wrap; }
    .ttg-icon-btn-label { display: none; }
}
