/* Keyword Volume Checker - tool-specific overrides on top of shared
 * tools.css. Composes the shared primitives (.tool-form-card, .input-form,
 * .text-input, .primary-btn, .results-region, etc.) and adds:
 *
 *   - .form-field / .field-label    (per-field label-on-top layout; same
 *                                     shape SCC + KDC declare locally)
 *   - .kw-preview                    live keyword-volume preview card
 *   - .country-picker / .country-option   checkbox grid for countries
 *   - .overview-region / .overview-chart   single-canvas multi-line trend
 *   - .quota-region / .quota-chip    same shape SCC / KDC / DAC use
 *   - per-country trend sparkline inside .results-table
 */

/* ===== Form fields ===== */

.tool-form-card { padding: 18px 24px; }

.form-field { margin-bottom: 16px; }
.form-field:last-child { margin-bottom: 0; }
.field-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink, #1f2937);
    margin: 0 0 6px 0;
}
.field-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 6px;
    gap: 12px;
    flex-wrap: wrap;
}
.field-label-row .field-label { margin-bottom: 0; }
.field-cap-note {
    font-size: 12px;
    color: var(--ink-500, #6b7280);
    font-weight: 400;
}

.input-form .text-input { width: 100%; }

/* ===== Live keyword-volume preview card ===== */

.kw-preview[hidden] { display: none; }
.kw-preview {
    background: var(--ink-25, #fafafa);
    border: 1px solid var(--ink-100, #e5e7eb);
    border-radius: 8px;
    padding: 8px 14px;
    margin-top: 8px;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 13px;
    align-items: center;
}
.kw-preview-label {
    color: var(--ink-500, #6b7280);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.kw-preview-stats {
    font-weight: 600;
    color: var(--ink-900, #111827);
}
.kw-preview-stats em {
    font-style: normal;
    color: var(--ink-500, #6b7280);
    font-weight: 500;
    margin-left: 4px;
    margin-right: 12px;
}
.kw-preview-stats em:last-child { margin-right: 0; }
.kw-preview.is-loading .kw-preview-stats { color: var(--ink-500, #6b7280); font-style: italic; }

/* ===== Country picker (checkbox grid) ===== */

.country-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
    background: var(--ink-25, #fafafa);
    border: 1px solid var(--ink-100, #e5e7eb);
    border-radius: 8px;
    padding: 12px;
}
.country-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    background: #fff;
    border: 1px solid var(--ink-100, #e5e7eb);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--ink-700, #374151);
    transition: border-color 0.12s ease, background 0.12s ease;
    user-select: none;
}
.country-option:hover { border-color: var(--ink-300, #9ca3af); }
.country-option:has(input:checked) {
    background: #fff5f5;
    border-color: var(--brand-red, #dc1717);
    color: var(--ink, #1f2937);
}
/* Fallback for browsers without :has() */
.country-option.is-checked {
    background: #fff5f5;
    border-color: var(--brand-red, #dc1717);
    color: var(--ink, #1f2937);
}
.country-option.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.country-option.is-disabled:hover { border-color: var(--ink-100, #e5e7eb); }
.country-cb {
    margin: 0;
    accent-color: var(--brand-red, #dc1717);
}
.country-flag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 16px;
    flex-shrink: 0;
}
.country-flag .kvc-flag-svg,
.kvc-flag-svg {
    display: block;
    width: 22px;
    height: 16px;
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}
.country-name {
    font-weight: 500;
    line-height: 1.2;
}

/* ===== Form controls (data source + submit) ===== */
.form-controls {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}
.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 0 1 auto;
}
.control-label {
    font-size: 12px;
    color: var(--ink-500, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.type-select {
    padding: 8px 10px;
    background: #fff;
    border: 1px solid var(--ink-200, #d1d5db);
    border-radius: 6px;
    font-size: 13px;
    color: var(--ink, #1f2937);
}
.form-controls .primary-btn {
    margin-left: auto;
}
.kw-feedback {
    margin-top: 10px;
    min-height: 18px;
}
.feedback-msg.is-error { color: var(--brand-red, #dc1717); }
.feedback-msg.is-ok    { color: #047857; }

/* ===== Quota card (same shape as KDC) ===== */
.quota-region {
    background: #fff;
    border: 1px solid var(--ink-100, #e5e7eb);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    padding: 12px 16px;
    margin-bottom: 16px;
    margin-top: 16px;
}
.quota-region[hidden] { display: none; }
.quota-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.quota-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: var(--ink-500, #6b7280);
}
.quota-upgrade {
    font-size: 12px;
    font-weight: 600;
    color: var(--brand-red, #dc1717);
    text-decoration: none;
}
.quota-upgrade:hover { text-decoration: underline; }
.quota-chips {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}
.quota-chip {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 6px;
    background: var(--ink-50, #f3f4f6);
    border: 1px solid var(--ink-100, #e5e7eb);
}
.quota-chip-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--ink-500, #6b7280);
}
.quota-chip-text {
    font-variant-numeric: tabular-nums;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink, #1f2937);
}
.quota-chip-bar {
    display: block;
    height: 4px;
    background: var(--ink-200, #d1d5db);
    border-radius: 999px;
    overflow: hidden;
}
.quota-chip-fill {
    display: block;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--brand-red, #dc1717) 0%, #ef6262 100%);
    transition: width 0.4s ease;
}
.quota-chip.is-warning .quota-chip-fill { background: linear-gradient(90deg, #d97706 0%, #f59e0b 100%); }
.quota-chip.is-danger  .quota-chip-fill { background: linear-gradient(90deg, #b91c1c 0%, #ef4444 100%); }
.quota-chip.is-warning .quota-chip-text { color: #b45309; }
.quota-chip.is-danger  .quota-chip-text { color: #b91c1c; }

/* ===== Overview region (multi-country trend overlay) ===== */
.overview-region {
    background: #fff;
    border: 1px solid var(--ink-100, #e5e7eb);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    padding: 16px 18px;
    margin-bottom: 16px;
    margin-top: 16px;
}
.overview-region[hidden] { display: none; }
.overview-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.overview-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--ink-900, #111827);
}
.overview-subtitle {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-500, #6b7280);
    margin-left: 6px;
}
.overview-summary {
    font-size: 13px;
    color: var(--ink-700, #374151);
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}
.overview-summary .summary-pill {
    background: var(--ink-50, #f3f4f6);
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--ink-100, #e5e7eb);
    font-size: 12px;
}
.overview-summary .summary-pill strong {
    font-weight: 700;
    color: var(--ink-900, #111827);
}
.overview-chart-wrap {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 18px;
    align-items: start;
}
@media (max-width: 720px) {
    .overview-chart-wrap { grid-template-columns: 1fr; }
}
.overview-chart {
    width: 100%;
    height: 240px;
    background: var(--ink-25, #fafafa);
    border: 1px solid var(--ink-100, #e5e7eb);
    border-radius: 6px;
    overflow: visible;
    /* SVG <text> doesn't inherit font-family from CSS reliably across
       browsers; set it explicitly on the SVG so axis labels use Poppins
       rather than the user-agent serif default. */
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.overview-chart .grid-line {
    stroke: var(--ink-200, #d1d5db);
    stroke-dasharray: 2 4;
    stroke-width: 1;
}
.overview-chart .axis-label {
    fill: var(--ink-500, #6b7280);
    font-size: 11px;
    font-family: inherit;
    font-weight: 500;
}
.overview-chart .series-line {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: opacity 0.15s ease, stroke-width 0.15s ease;
}
.overview-chart .series-line.is-dimmed { opacity: 0.15; }
.overview-chart .series-line.is-highlighted { stroke-width: 3; }
.overview-chart .series-dot {
    transition: opacity 0.15s ease;
}
.overview-chart .series-dot.is-dimmed { opacity: 0.1; }

.overview-legend {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 160px;
}
.overview-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--ink-700, #374151);
    cursor: pointer;
    background: transparent;
    border: 1px solid transparent;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.overview-legend-item:hover { background: var(--ink-50, #f3f4f6); }
.overview-legend-item.is-disabled {
    color: var(--ink-400, #9ca3af);
    text-decoration: line-through;
}
.overview-legend-swatch {
    display: inline-block;
    width: 14px;
    height: 3px;
    border-radius: 2px;
    flex-shrink: 0;
}
.overview-legend-name {
    font-weight: 500;
}
.overview-legend-value {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
    color: var(--ink-500, #6b7280);
    font-size: 11px;
}

/* ===== Results table ===== */

/* Every column centered, per the multi-country comparison shape -
 * each row is a separate market and the per-country values read more
 * naturally column-by-column when aligned to a shared center axis
 * (the per-country sparkline anchors visually under the trend header
 * etc.). Overrides the shared default of left-aligned td + right-aligned
 * th-num. */
#results-table thead th,
#results-table tbody td {
    text-align: center;
    vertical-align: middle;
}
/* Country cell uses an inline-flex layout, so keep its inner content
 * grouped via justify-content but the cell itself still centered. */
#results-table tbody td:first-child .col-country {
    justify-content: center;
}

.results-table .col-country {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.results-table .col-country-flag {
    display: inline-flex;
    align-items: center;
    width: 24px;
    height: 18px;
    flex-shrink: 0;
}
.results-table .col-country-flag .kvc-flag-svg {
    width: 24px;
    height: 18px;
}
.overview-legend-flag {
    display: inline-flex;
    align-items: center;
    width: 18px;
    height: 13px;
    flex-shrink: 0;
    margin-right: 6px;
}
.overview-legend-flag .kvc-flag-svg {
    width: 18px;
    height: 13px;
}
.big-chart-flag {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    width: 28px;
    height: 21px;
    margin-right: 8px;
}
.big-chart-flag .kvc-flag-svg {
    width: 28px;
    height: 21px;
}
.trend-tooltip .tip-flag {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    width: 18px;
    height: 13px;
    margin-right: 6px;
}
.trend-tooltip .tip-flag .kvc-flag-svg {
    width: 18px;
    height: 13px;
    border-color: rgba(255, 255, 255, 0.4);
}
.results-table .col-country-name {
    font-weight: 600;
    color: var(--ink-900, #111827);
}
.results-table .col-country-code {
    margin-left: 4px;
    color: var(--ink-500, #6b7280);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.results-table .col-cpc-currency {
    color: var(--ink-500, #6b7280);
    font-size: 11px;
    margin-right: 2px;
    text-transform: uppercase;
    font-weight: 500;
}
.competition-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
}
.competition-badge.is-low    { background: #ecfdf5; color: #047857; }
.competition-badge.is-medium { background: #fffbeb; color: #b45309; }
.competition-badge.is-high   { background: #fef2f2; color: #b91c1c; }
.competition-badge.is-na     { background: var(--ink-50, #f3f4f6); color: var(--ink-500, #6b7280); }
.competition-value {
    font-variant-numeric: tabular-nums;
    font-size: 11px;
    color: var(--ink-500, #6b7280);
    margin-left: 4px;
    font-weight: 500;
}

.trend-cell-svg {
    width: 90px;
    height: 24px;
    cursor: pointer;
    vertical-align: middle;
    overflow: visible;
}
.trend-cell-svg .trend-line {
    fill: none;
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.no-data {
    color: var(--ink-400, #9ca3af);
    font-style: italic;
}
.no-data-cell {
    color: var(--ink-300, #cbd5e0);
}

.results-table tr.is-no-data .col-country-name { color: var(--ink-500, #6b7280); }
.results-table tr.is-error .col-country-name { color: var(--ink-500, #6b7280); }
.results-table tr.is-error .col-error-msg {
    font-size: 11px;
    color: var(--brand-red, #dc1717);
    margin-left: 8px;
    font-weight: 500;
}

/* Trend tooltip - shared pattern with SVC / DAC / WAC.
 * One floating element on body, base64-encoded data-tip on each SVG.
 * We re-use the .trend-tooltip class so the shared CSS handles position.
 */
.trend-tooltip {
    position: absolute;
    pointer-events: none;
    background: var(--ink-900, #111827);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-width: 220px;
    white-space: nowrap;
}
.trend-tooltip[hidden] { display: none; }
.trend-tooltip strong { color: #fff; }

/* ===== Big trend modal (click-to-zoom) - inherits .modal-backdrop / .modal-card from shared ===== */
.kvc-big-chart {
    width: 100%;
    max-width: 100%;
    height: 320px;
    overflow: visible;
    background: var(--ink-25, #fafafa);
    border: 1px solid var(--ink-100, #e5e7eb);
    border-radius: 8px;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.kvc-big-chart .grid-line {
    stroke: var(--ink-200, #d1d5db);
    stroke-dasharray: 2 4;
    stroke-width: 1;
}
.kvc-big-chart .axis-label {
    fill: var(--ink-500, #6b7280);
    font-size: 12px;
    font-family: inherit;
    font-weight: 500;
}
.kvc-big-chart .series-line {
    fill: none;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.kvc-big-stats {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}
.kvc-big-stat {
    background: var(--ink-50, #f3f4f6);
    border-radius: 6px;
    padding: 8px 12px;
}
.kvc-big-stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-500, #6b7280);
    font-weight: 700;
}
.kvc-big-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--ink-900, #111827);
    font-variant-numeric: tabular-nums;
}

/* ===== Upgrade banner ===== */
.upgrade-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    background: linear-gradient(120deg, #fff7ed 0%, #fef2f2 100%);
    border: 1px solid #fed7aa;
    border-radius: 12px;
    padding: 18px 22px;
    margin-top: 24px;
}
.upgrade-banner-icon {
    flex-shrink: 0;
    color: var(--brand-red, #dc1717);
    width: 36px;
    height: 36px;
}
.upgrade-banner-icon svg { width: 100%; height: 100%; }
.upgrade-banner-text {
    flex: 1 1 0;
    min-width: 0;
}
.upgrade-banner-text strong {
    display: block;
    font-size: 15px;
    color: var(--ink-900, #111827);
    margin-bottom: 4px;
}
.upgrade-banner-text span {
    display: block;
    font-size: 13px;
    color: var(--ink-700, #374151);
    line-height: 1.45;
}
.upgrade-banner-cta {
    flex-shrink: 0;
}
@media (max-width: 600px) {
    .upgrade-banner { flex-direction: column; align-items: flex-start; }
    .upgrade-banner-cta { margin-top: 8px; align-self: stretch; }
}
