/* ===========================
   Writing Proofreader Checker (wpc-)
   =========================== */

:root {
    --wpc-primary: #2563eb;
    --wpc-primary-light: #dbeafe;
    --wpc-primary-dark: #1d4ed8;
    --wpc-success: #16a34a;
    --wpc-success-light: #dcfce7;
    --wpc-warn: #f59e0b;
    --wpc-warn-light: #fef3c7;
    --wpc-error: #dc2626;
    --wpc-error-light: #fee2e2;
    --wpc-info: #3b82f6;
    --wpc-info-light: #dbeafe;
    --wpc-border: #e2e8f0;
    --wpc-bg-card: #f8fafc;
    --wpc-text: #1e293b;
    --wpc-text-muted: #64748b;
    --wpc-text-faint: #94a3b8;
    --wpc-radius: 12px;
    --wpc-radius-sm: 6px;
    --wpc-shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .05);
    --wpc-shadow-md: 0 4px 16px rgba(0, 0, 0, .10);
    --wpc-transition: .2s ease;
}

/* ── Anchor Navigation ── */
.wpc-anchor-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px 0;
    margin-bottom: 4px;
}

.wpc-anchor-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 7px 16px;
    border: 1px solid var(--wpc-border);
    border-radius: 20px;
    font-size: .82rem;
    font-weight: 600;
    color: var(--wpc-text-muted);
    background: #fff;
    text-decoration: none;
    transition: all var(--wpc-transition);
    white-space: nowrap;
}

.wpc-anchor-link:hover {
    border-color: var(--wpc-primary);
    color: var(--wpc-primary);
    background: var(--wpc-primary-light);
    box-shadow: 0 2px 8px rgba(37, 99, 235, .12);
}

/* ── Toolbar ── */
.wpc-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.wpc-toolbar-left {
    display: flex;
    gap: 6px;
    align-items: center;
}

.wpc-toolbar-right {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: .82rem;
    color: var(--wpc-text-muted);
}

/* ── Buttons ── */
.wpc-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--wpc-radius-sm);
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--wpc-transition);
    line-height: 1;
}

.wpc-btn--primary {
    background: var(--wpc-primary);
    color: #fff;
}

.wpc-btn--primary:hover {
    background: var(--wpc-primary-dark);
    box-shadow: 0 2px 8px rgba(37, 99, 235, .25);
}

.wpc-btn--ghost {
    background: transparent;
    color: var(--wpc-text-muted);
    border: 1px solid var(--wpc-border);
}

.wpc-btn--ghost:hover {
    border-color: var(--wpc-primary);
    color: var(--wpc-primary);
    background: var(--wpc-primary-light);
}

.wpc-btn--sm {
    padding: 5px 10px;
    font-size: .78rem;
}

/* ── Textarea ── */
.wpc-textarea-wrap {
    position: relative;
    border: 1px solid var(--wpc-border);
    border-radius: var(--wpc-radius);
    background: #fff;
    transition: border-color var(--wpc-transition);
}

.wpc-textarea-wrap:focus-within {
    border-color: var(--wpc-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

.wpc-textarea-wrap.wpc-drag-over {
    border-color: var(--wpc-primary);
    background: var(--wpc-primary-light);
}

.wpc-highlight-layer {
    position: absolute;
    inset: 0;
    padding: 12px 14px;
    overflow: auto;
    font: inherit;
    font-size: .9rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: transparent;
    pointer-events: none;
    z-index: 1;
}

.wpc-textarea {
    display: block;
    width: 100%;
    min-height: 260px;
    padding: 12px 14px;
    border: none;
    outline: none;
    resize: vertical;
    background: transparent;
    font-size: .9rem;
    line-height: 1.7;
    color: var(--wpc-text);
    position: relative;
    z-index: 2;
}

.wpc-textarea::placeholder {
    color: var(--wpc-text-faint);
}

/* ── Highlight marks ── */
.wpc-hl-error {
    background: rgba(220, 38, 38, .15);
    border-bottom: 2px wavy var(--wpc-error);
    border-radius: 2px;
}

.wpc-hl-warn {
    background: rgba(245, 158, 11, .12);
    border-bottom: 2px wavy var(--wpc-warn);
    border-radius: 2px;
}

.wpc-hl-info {
    background: rgba(59, 130, 246, .10);
    border-bottom: 2px dashed var(--wpc-info);
    border-radius: 2px;
}

.wpc-hl-active {
    background: rgba(37, 99, 235, .2) !important;
}

/* ── Presets ── */
.wpc-presets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.wpc-preset-btn {
    padding: 5px 12px;
    border: 1px solid var(--wpc-border);
    border-radius: 16px;
    background: #fff;
    font-size: .78rem;
    color: var(--wpc-text-muted);
    cursor: pointer;
    transition: all var(--wpc-transition);
}

.wpc-preset-btn:hover {
    border-color: var(--wpc-primary);
    color: var(--wpc-primary);
    background: var(--wpc-primary-light);
}

/* ── Controls Card ── */
.wpc-controls-card {
    border: 1px solid var(--wpc-border);
    border-radius: var(--wpc-radius);
    padding: 16px;
    background: #fff;
}

.wpc-controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.wpc-control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.wpc-control-label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--wpc-text-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
}

.wpc-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--wpc-border);
    border-radius: var(--wpc-radius-sm);
    font-size: .85rem;
    color: var(--wpc-text);
    background: #fff;
    cursor: pointer;
    transition: border-color var(--wpc-transition);
}

.wpc-select:focus {
    border-color: var(--wpc-primary);
    outline: none;
}

/* ── Rule Toggles ── */
.wpc-rules-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.wpc-rule-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border: 1px solid var(--wpc-border);
    border-radius: var(--wpc-radius-sm);
    background: #fff;
    font-size: .82rem;
    transition: all var(--wpc-transition);
}

.wpc-rule-item:hover {
    border-color: var(--wpc-primary-light);
}

.wpc-rule-name {
    color: var(--wpc-text);
    font-weight: 500;
}

.wpc-rule-desc {
    font-size: .72rem;
    color: var(--wpc-text-faint);
    margin-top: 1px;
}

/* Toggle switch */
.wpc-toggle {
    position: relative;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.wpc-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.wpc-toggle-slider {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--wpc-transition);
}

.wpc-toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    bottom: 2px;
    background: #fff;
    border-radius: 50%;
    transition: var(--wpc-transition);
}

.wpc-toggle input:checked+.wpc-toggle-slider {
    background: var(--wpc-primary);
}

.wpc-toggle input:checked+.wpc-toggle-slider::before {
    transform: translateX(16px);
}

/* ── Check Button ── */
.wpc-check-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    margin-top: 12px;
    background: var(--wpc-primary);
    color: #fff;
    border: none;
    border-radius: var(--wpc-radius);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--wpc-transition);
}

.wpc-check-btn:hover {
    background: var(--wpc-primary-dark);
    box-shadow: 0 4px 12px rgba(37, 99, 235, .3);
    transform: translateY(-1px);
}

.wpc-check-btn:active {
    transform: translateY(0);
}

.wpc-check-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
}

/* ── Results Panel ── */
.wpc-results {
    margin-top: 16px;
}

/* Score Section */
.wpc-score-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    border: 1px solid var(--wpc-border);
    border-radius: var(--wpc-radius);
    background: #fff;
}

.wpc-score-circle {
    position: relative;
    width: 90px;
    height: 90px;
    flex-shrink: 0;
}

.wpc-score-circle svg {
    transform: rotate(-90deg);
}

.wpc-score-bg {
    fill: none;
    stroke: #e2e8f0;
    stroke-width: 8;
}

.wpc-score-fill {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset .6s ease, stroke .3s;
}

.wpc-score-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--wpc-text);
    line-height: 1;
}

.wpc-score-label {
    font-size: .65rem;
    font-weight: 600;
    color: var(--wpc-text-muted);
    margin-top: 2px;
}

.wpc-score-details {
    flex: 1;
}

.wpc-score-summary {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.wpc-score-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .85rem;
    font-weight: 600;
}

.wpc-score-stat--error {
    color: var(--wpc-error);
}

.wpc-score-stat--warn {
    color: var(--wpc-warn);
}

.wpc-score-stat--info {
    color: var(--wpc-info);
}

.wpc-score-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.wpc-score-dot--error {
    background: var(--wpc-error);
}

.wpc-score-dot--warn {
    background: var(--wpc-warn);
}

.wpc-score-dot--info {
    background: var(--wpc-info);
}

/* Stats Grid */
.wpc-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 14px;
    padding: 14px;
    border: 1px solid var(--wpc-border);
    border-radius: var(--wpc-radius);
    background: var(--wpc-bg-card);
}

.wpc-stat-item {
    text-align: center;
}

.wpc-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--wpc-text);
}

.wpc-stat-label {
    font-size: .68rem;
    color: var(--wpc-text-muted);
    margin-top: 2px;
}

/* Error List */
.wpc-errors-list {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wpc-error-item {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--wpc-border);
    border-radius: var(--wpc-radius-sm);
    background: #fff;
    cursor: pointer;
    transition: all var(--wpc-transition);
    border-left: 4px solid transparent;
}

.wpc-error-item:hover {
    box-shadow: var(--wpc-shadow);
}

.wpc-error-item--error {
    border-left-color: var(--wpc-error);
}

.wpc-error-item--warn {
    border-left-color: var(--wpc-warn);
}

.wpc-error-item--info {
    border-left-color: var(--wpc-info);
}

.wpc-error-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    font-size: .7rem;
    font-weight: 700;
    color: #fff;
}

.wpc-error-badge--error {
    background: var(--wpc-error);
}

.wpc-error-badge--warn {
    background: var(--wpc-warn);
}

.wpc-error-badge--info {
    background: var(--wpc-info);
}

.wpc-error-body {
    flex: 1;
    min-width: 0;
}

.wpc-error-message {
    font-size: .85rem;
    color: var(--wpc-text);
    line-height: 1.4;
}

.wpc-error-excerpt {
    font-size: .78rem;
    color: var(--wpc-text-muted);
    margin-top: 4px;
    padding: 4px 8px;
    background: var(--wpc-bg-card);
    border-radius: 4px;
    font-family: monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wpc-error-rule {
    font-size: .7rem;
    color: var(--wpc-text-faint);
    margin-top: 4px;
}

.wpc-error-suggestion {
    font-size: .78rem;
    color: var(--wpc-success);
    margin-top: 3px;
    font-weight: 600;
}

/* ── Empty / No Errors ── */
.wpc-no-errors {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px;
    text-align: center;
    border: 1px solid var(--wpc-success);
    border-radius: var(--wpc-radius);
    background: var(--wpc-success-light);
}

.wpc-no-errors-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.wpc-no-errors-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--wpc-success);
}

.wpc-no-errors-desc {
    font-size: .85rem;
    color: var(--wpc-text-muted);
    margin-top: 4px;
}

/* ── Security Banner ── */
.wpc-security {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 16px 0;
}

.wpc-security-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--wpc-border);
    border-radius: var(--wpc-radius-sm);
    background: #fff;
}

.wpc-security-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.wpc-security-item strong {
    font-size: .82rem;
    color: var(--wpc-text);
    display: block;
}

.wpc-security-item p {
    font-size: .72rem;
    color: var(--wpc-text-muted);
    margin: 2px 0 0;
}

/* ── Use Cases ── */
.wpc-use-cases {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}

.wpc-use-case {
    display: flex;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--wpc-border);
    border-radius: var(--wpc-radius-sm);
    background: #fff;
}

.wpc-use-case-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.wpc-use-case h4 {
    font-size: .9rem;
    color: var(--wpc-text);
    margin: 0 0 4px;
}

.wpc-use-case p {
    font-size: .8rem;
    color: var(--wpc-text-muted);
    margin: 0;
    line-height: 1.5;
}

/* ── FAQ ── */
.wpc-faq dt {
    font-weight: 700;
    color: var(--wpc-text);
    margin-top: 18px;
    padding-left: 20px;
    position: relative;
    font-size: .92rem;
}

.wpc-faq dt::before {
    content: 'Q.';
    position: absolute;
    left: 0;
    color: var(--wpc-primary);
    font-weight: 800;
}

.wpc-faq dd {
    margin: 6px 0 0 20px;
    color: var(--wpc-text-muted);
    font-size: .85rem;
    line-height: 1.7;
}

/* ── Tables ── */
.wpc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
    margin: 12px 0;
    border: 1px solid var(--wpc-border);
    border-radius: var(--wpc-radius-sm);
    overflow: hidden;
}

.wpc-table th,
.wpc-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--wpc-border);
}

.wpc-table thead th {
    font-weight: 700;
    color: var(--wpc-text);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    background: var(--wpc-primary-light);
    border-bottom: 2px solid var(--wpc-primary);
}

.wpc-table tbody th {
    font-weight: 600;
    color: var(--wpc-text);
    white-space: nowrap;
}

.wpc-table tbody td {
    color: var(--wpc-text-muted);
    line-height: 1.5;
}

.wpc-table tbody tr:nth-child(even) {
    background: var(--wpc-bg-card);
}

.wpc-table tbody tr:hover {
    background: var(--wpc-primary-light);
}

.wpc-table tbody tr:last-child th,
.wpc-table tbody tr:last-child td {
    border-bottom: none;
}

/* ── Toast ── */
.wpc-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 24px;
    border-radius: 8px;
    background: var(--wpc-text);
    color: #fff;
    font-size: .85rem;
    font-weight: 600;
    box-shadow: var(--wpc-shadow-md);
    z-index: 9999;
    opacity: 0;
    transition: all .3s ease;
    pointer-events: none;
}

.wpc-toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .wpc-controls-grid {
        grid-template-columns: 1fr;
    }

    .wpc-rules-grid {
        grid-template-columns: 1fr;
    }

    .wpc-use-cases {
        grid-template-columns: 1fr;
    }

    .wpc-security {
        grid-template-columns: 1fr 1fr;
    }

    .wpc-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .wpc-score-card {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 400px) {
    .wpc-security {
        grid-template-columns: 1fr;
    }
}