/* =====================================================
   Competitor SEO Toolkit
   Shared styles for Admin + Public front-end
   ===================================================== */

:root {
    --cst-blue:     #2563eb;
    --cst-blue-dk:  #1d4ed8;
    --cst-green:    #16a34a;
    --cst-red:      #dc2626;
    --cst-amber:    #d97706;
    --cst-grey:     #6b7280;
    --cst-border:   #e5e7eb;
    --cst-bg:       #f9fafb;
    --cst-white:    #ffffff;
    --cst-text:     #1e293b;
    --cst-radius:   10px;
}

/* ──────────────────────────────
   Shared wrapper
────────────────────────────── */
.cst-tool-wrap,
.cst-wrap {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--cst-text);
    max-width: 1100px;
}

/* ──────────────────────────────
   Tool header
────────────────────────────── */
.cst-tool-header { margin-bottom: 18px; }
.cst-tool-header h3 { font-size: 1.4rem; margin: 0 0 6px; }
.cst-tool-header p  { margin: 0; color: var(--cst-grey); font-size: .95rem; }

/* ──────────────────────────────
   Form row
────────────────────────────── */
.cst-form-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    padding: 18px 20px;
    background: var(--cst-white);
    border: 1px solid var(--cst-border);
    border-radius: var(--cst-radius);
    margin-bottom: 22px;
}
.cst-form-two { align-items: flex-end; }
.cst-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1 1 240px;
}
.cst-field label { font-weight: 600; font-size: .85rem; color: var(--cst-text); }

/* ──────────────────────────────
   URL Input
────────────────────────────── */
.cst-input {
    flex: 1 1 300px;
    padding: 10px 14px;
    border: 1.5px solid var(--cst-border);
    border-radius: 7px;
    font-size: .95rem;
    background: var(--cst-white);
    color: var(--cst-text);
    outline: none;
    transition: border-color .2s;
    /* override WP admin styles */
    box-shadow: none !important;
    height: auto !important;
    line-height: normal !important;
}
.cst-input:focus { border-color: var(--cst-blue); }

/* ──────────────────────────────
   Button
────────────────────────────── */
.cst-btn {
    padding: 10px 22px;
    background: var(--cst-blue);
    color: #fff !important;
    border: none;
    border-radius: 7px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .1s;
    white-space: nowrap;
    text-decoration: none !important;
    display: inline-block;
}
.cst-btn:hover { background: var(--cst-blue-dk); transform: translateY(-1px); }
.cst-btn:active { transform: translateY(0); }

/* ──────────────────────────────
   Spinner
────────────────────────────── */
.cst-spinner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 0;
    color: var(--cst-grey);
    font-size: .9rem;
}
.cst-spin-ring {
    width: 28px; height: 28px;
    border: 3px solid var(--cst-border);
    border-top-color: var(--cst-blue);
    border-radius: 50%;
    animation: cst-spin .7s linear infinite;
    flex-shrink: 0;
}
@keyframes cst-spin { to { transform: rotate(360deg); } }

/* ──────────────────────────────
   Error box
────────────────────────────── */
.cst-error-box {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--cst-radius);
    color: #991b1b;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: .9rem;
}

/* ──────────────────────────────
   Result topbar
────────────────────────────── */
.cst-result-topbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}
.cst-cache-badge {
    background: #fef9c3;
    border: 1px solid #fde047;
    border-radius: 20px;
    padding: 3px 12px;
    font-size: .78rem;
    color: #78350f;
}

/* ──────────────────────────────
   Card
────────────────────────────── */
.cst-card {
    background: var(--cst-white);
    border: 1px solid var(--cst-border);
    border-radius: var(--cst-radius);
    padding: 20px 22px;
    margin-bottom: 18px;
}
.cst-card h4 {
    font-size: 1rem;
    margin: 0 0 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--cst-border);
    color: var(--cst-text);
}

/* ──────────────────────────────
   Table
────────────────────────────── */
.cst-tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}
.cst-tbl th,
.cst-tbl td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--cst-border);
    text-align: left;
    vertical-align: top;
}
.cst-tbl th {
    width: 180px;
    font-weight: 600;
    color: #475569;
    background: var(--cst-bg);
    white-space: nowrap;
}
.cst-tbl tr:last-child td,
.cst-tbl tr:last-child th { border-bottom: none; }
.cst-tbl tbody tr:hover td { background: #f8fafc; }
.cst-table-scroll { overflow-x: auto; }

/* ──────────────────────────────
   Compare table
────────────────────────────── */
.cst-compare-tbl th:not(:first-child),
.cst-compare-tbl td:not(:first-child) { text-align: right; }
.cst-compare-tbl thead th {
    background: var(--cst-text);
    color: #fff;
    font-weight: 600;
}
.cst-compare-tbl thead th:first-child { background: var(--cst-text); }
.cst-factor { font-weight: 600; color: var(--cst-grey); background: var(--cst-bg) !important; }
.cst-win { color: var(--cst-green); font-weight: 700; }
.cst-delta-up   { color: var(--cst-green); font-weight: 700; }
.cst-delta-down { color: var(--cst-red);   font-weight: 700; }
.cst-delta-eq   { color: var(--cst-grey); }

/* ──────────────────────────────
   Frequency table bars
────────────────────────────── */
.cst-freq-tbl td:nth-child(2) { text-align: right; width: 40px; }
.cst-bar-bg {
    background: var(--cst-bg);
    border-radius: 4px;
    height: 14px;
    min-width: 80px;
    overflow: hidden;
}
.cst-bar-fill {
    height: 100%;
    background: var(--cst-blue);
    border-radius: 4px;
    min-width: 4px;
    transition: width .5s ease;
}

/* ──────────────────────────────
   Keyword grid
────────────────────────────── */
.cst-kw-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
@media (max-width: 700px) {
    .cst-kw-grid { grid-template-columns: 1fr; }
}

/* ──────────────────────────────
   Heading tree
────────────────────────────── */
.cst-tree, .cst-tree-list { list-style: none !important; margin: 0; padding: 0; }
.cst-tree-list            { padding-left: 22px; }
.cst-tree > .cst-tree-list { padding-left: 0; }
.cst-tree-list li         { padding: 4px 0; }
.cst-tree-row             { display: flex; align-items: center; gap: 8px; }
.cst-tree-text            { font-size: .9rem; color: var(--cst-text); }
.cst-legend               { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }

/* heading badges */
.cst-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    padding: 2px 7px;
    font-size: .7rem;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: .03em;
}
.cst-h1 { background: #1e293b; color: #fff; }
.cst-h2 { background: #2563eb; color: #fff; }
.cst-h3 { background: #7c3aed; color: #fff; }
.cst-h4 { background: #db2777; color: #fff; }
.cst-h5 { background: #d97706; color: #fff; }
.cst-h6 { background: #6b7280; color: #fff; }

/* ──────────────────────────────
   Score circle (slug tool)
────────────────────────────── */
.cst-score-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.cst-score-circle {
    width: 110px; height: 110px;
    border-radius: 50%;
    background: var(--cst-blue);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.cst-score-circle .d-score-num   { font-size: 2.2rem; font-weight: 800; line-height: 1; }
.cst-score-circle .d-score-grade { font-size: .95rem; font-weight: 600; opacity: .85; }
.cst-score-circle.grade-A { background: var(--cst-green); }
.cst-score-circle.grade-B { background: var(--cst-blue); }
.cst-score-circle.grade-C { background: var(--cst-amber); }
.cst-score-circle.grade-D { background: #ea580c; }
.cst-score-circle.grade-F { background: var(--cst-red); }
.cst-score-right { flex: 1; }
.cst-score-right h4 { margin-top: 0; }

/* ──────────────────────────────
   Issues / Goods panels
────────────────────────────── */
.cst-issues-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 18px;
}
@media (max-width: 600px) { .cst-issues-row { grid-template-columns: 1fr; } }
.cst-issues-box, .cst-goods-box {
    padding: 14px 16px;
    border-radius: 8px;
    font-size: .88rem;
}
.cst-issues-box { background: #fef2f2; border: 1px solid #fecaca; }
.cst-goods-box  { background: #f0fdf4; border: 1px solid #bbf7d0; }
.cst-issues-box h5 { color: var(--cst-red);   margin: 0 0 8px; font-size: .9rem; }
.cst-goods-box  h5 { color: var(--cst-green); margin: 0 0 8px; font-size: .9rem; }
.cst-issues-box ul, .cst-goods-box ul  { margin: 0; padding-left: 16px; }
.cst-issues-box li { color: #991b1b; margin-bottom: 3px; }
.cst-goods-box  li { color: #166534; margin-bottom: 3px; }

/* ──────────────────────────────
   Status indicators
────────────────────────────── */
.cst-yes        { color: var(--cst-green); font-weight: 700; }
.cst-no         { color: var(--cst-red);   font-weight: 700; }
.cst-warn       { color: var(--cst-amber); font-weight: 700; }
.cst-none       { color: var(--cst-grey);  font-style: italic; }
.cst-badge-inline {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: .85rem;
    font-weight: 600;
}
.cst-badge-inline.cst-yes  { background: #dcfce7; }
.cst-badge-inline.cst-warn { background: #fef3c7; }
.cst-badge-inline.cst-no   { background: #fee2e2; }

/* ──────────────────────────────
   Inline list
────────────────────────────── */
.cst-ul {
    margin: 4px 0 0;
    padding-left: 18px;
    font-size: .87rem;
}
.cst-ul li { margin-bottom: 3px; color: #374151; }

/* ──────────────────────────────
   ADMIN PAGE OVERRIDES
   (only affects WP admin context)
────────────────────────────── */
.cst-wrap h1     { font-size: 1.7rem; color: var(--cst-text); margin-bottom: 4px; }
.cst-subtitle    { color: var(--cst-grey); margin-top: 0; }

/* Admin form box (old selector kept for backward compat) */
.cst-form-box {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 18px 20px;
    background: var(--cst-white);
    border: 1px solid var(--cst-border);
    border-radius: var(--cst-radius);
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.cst-url-input {
    flex: 1 1 300px;
    padding: 10px 14px !important;
    border: 1.5px solid var(--cst-border) !important;
    border-radius: 7px !important;
    font-size: .95rem !important;
    box-shadow: none !important;
}
.cst-url-input:focus { border-color: var(--cst-blue) !important; }

/* Admin spinners */
.cst-spinner-inner {
    width: 28px; height: 28px;
    border: 3px solid var(--cst-border);
    border-top-color: var(--cst-blue);
    border-radius: 50%;
    animation: cst-spin .7s linear infinite;
}

/* Admin section */
.cst-section {
    background: var(--cst-white);
    border: 1px solid var(--cst-border);
    border-radius: var(--cst-radius);
    padding: 20px 24px;
    margin-bottom: 20px;
}
.cst-section h2 {
    font-size: 1rem;
    margin: 0 0 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--cst-border);
}

/* Admin result bar */
.cst-result-bar {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 12px;
    align-items: center;
}

/* Admin compare table */
.cst-compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
.cst-compare-table th,
.cst-compare-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--cst-border);
    text-align: right;
}
.cst-compare-table th:first-child,
.cst-compare-table td:first-child { text-align: left; background: var(--cst-bg); font-weight: 600; color: #475569; }
.cst-compare-table thead th { background: var(--cst-text); color: #fff; }
.cst-compare-table .delta-pos  { color: var(--cst-green); font-weight: 700; }
.cst-compare-table .delta-neg  { color: var(--cst-red);   font-weight: 700; }
.cst-compare-table .delta-neu  { color: var(--cst-grey); }
.cst-delta-up   { color: var(--cst-green); font-weight: 700; }
.cst-delta-down { color: var(--cst-red);   font-weight: 700; }
.cst-delta-eq   { color: var(--cst-grey); }

/* Admin cached badge */
.cst-cached-badge {
    background: #fef9c3;
    border: 1px solid #fde047;
    border-radius: 20px;
    padding: 2px 10px;
    font-size: .78rem;
    color: #78350f;
}

/* Admin error */
.cst-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--cst-radius);
    color: #991b1b;
    padding: 12px 16px;
    margin-top: 12px;
    font-size: .9rem;
}

/* Admin heading list */
.cst-heading-list { margin: 4px 0 0; padding-left: 16px; font-size: .88rem; }
.cst-heading-list li { margin-bottom: 3px; color: #374151; }

/* Admin freq table */
.freq-bar-bg  { background: var(--cst-bg); border-radius: 4px; height: 14px; overflow: hidden; }
.freq-bar-fill { height: 100%; background: var(--cst-blue); border-radius: 4px; min-width: 4px; transition: width .5s; }
.freq-bar-cell { width: 120px; }

/* Admin dashboard */
.cst-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 18px;
    margin: 20px 0;
}
.cst-card-admin {
    background: var(--cst-white);
    border: 1px solid var(--cst-border);
    border-radius: var(--cst-radius);
    padding: 22px 18px;
    text-decoration: none;
    color: var(--cst-text);
    display: block;
    transition: box-shadow .2s, transform .2s;
}
.cst-card-admin:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,.09);
    transform: translateY(-2px);
    color: var(--cst-blue);
}
.cst-card-admin .dashicons { font-size: 2rem; color: var(--cst-blue); margin-bottom: 8px; }
.cst-card-admin h3 { margin: 6px 0 5px; font-size: 1rem; }
.cst-card-admin p  { margin: 0; color: var(--cst-grey); font-size: .87rem; }

.cst-info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--cst-radius);
    padding: 18px 22px;
    margin-top: 10px;
}
.cst-info-box code {
    display: inline-block;
    background: #dbeafe;
    border-radius: 4px;
    padding: 3px 8px;
    margin: 4px 4px 4px 0;
    font-size: .88rem;
}

/* Admin score */
.cst-score-wrap  { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.cst-score-detail { flex: 1; }
.cst-score-detail h2 { margin-top: 0; }
.cst-issues-goods { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cst-issues, .cst-goods { padding: 14px 16px; border-radius: 8px; font-size: .88rem; }
.cst-issues { background: #fef2f2; border: 1px solid #fecaca; }
.cst-goods  { background: #f0fdf4; border: 1px solid #bbf7d0; }
.cst-issues h4 { color: var(--cst-red);   margin: 0 0 8px; }
.cst-goods  h4 { color: var(--cst-green); margin: 0 0 8px; }
.cst-issues ul, .cst-goods ul { margin: 0; padding-left: 16px; }
.cst-issues li { color: #991b1b; margin-bottom: 3px; }
.cst-goods  li { color: #166534; margin-bottom: 3px; }

/* Admin kw grid */
.cst-kw-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.cst-kw-meta  { display: flex; justify-content: flex-end; margin-bottom: 10px; }

@media (max-width: 800px) {
    .cst-kw-grid    { grid-template-columns: 1fr; }
    .cst-issues-goods { grid-template-columns: 1fr; }
}
