/* ============================================================
   StoryBrand Auditor — Report Stylesheet
   Shared between admin dashboard and front-end shortcode.
   ============================================================ */

/* ── Reset / Base ─────────────────────────────────────────── */
.sba-report *,
.sba-report *::before,
.sba-report *::after {
    box-sizing: border-box;
}

.sba-report {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1a1a2e;
    line-height: 1.6;
    max-width: 900px;
    margin: 24px auto;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0,0,0,.10);
}

/* ── Header ───────────────────────────────────────────────── */
.sba-report-header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 60%, #0f3460 100%);
    color: #fff;
    padding: 32px;
}

.sba-report-header-inner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}

.sba-report-badge {
    display: inline-block;
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 20px;
    padding: 3px 12px;
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.sba-report-site {
    margin: 0 0 4px;
    font-size: 26px;
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
}

.sba-report-url {
    margin: 0 0 4px;
    font-size: 13px;
    opacity: .7;
    word-break: break-all;
}

.sba-report-date {
    margin: 0;
    font-size: 12px;
    opacity: .6;
}

.sba-report-date strong {
    opacity: 1;
    font-weight: 600;
}

/* ── Score Circle ─────────────────────────────────────────── */
.sba-report-score-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.sba-score-circle {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    border: 5px solid var(--score-color, #3b82f6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.06);
}

.sba-score-number {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
    color: var(--score-color, #fff);
}

.sba-score-label {
    font-size: 11px;
    opacity: .6;
    margin-top: 2px;
}

.sba-grade-badge {
    font-size: 18px;
    font-weight: 800;
    padding: 4px 14px;
    border-radius: 8px;
    color: #fff;
}

.grade-a { background: #22c55e; }
.grade-b { background: #3b82f6; }
.grade-c { background: #f59e0b; }
.grade-d { background: #ef4444; }

/* ── Report Actions ───────────────────────────────────────── */
.sba-report-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.sba-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity .2s, transform .1s;
}

.sba-btn:hover { opacity: .85; }
.sba-btn:active { transform: scale(.97); }

.sba-btn-print  { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.3); }
.sba-btn-pdf    { background: #7c3aed; color: #fff; }
.sba-btn-email  { background: #e74c3c; color: #fff; }
.sba-btn-send   { background: #22c55e; color: #fff; padding: 7px 14px; }
.sba-btn-primary { background: #0f3460; color: #fff; font-size: 15px; padding: 12px 24px; }

.sba-email-form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.sba-email-form input[type="email"] {
    border: 1px solid rgba(255,255,255,.3);
    background: rgba(255,255,255,.1);
    color: #fff;
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 13px;
    min-width: 220px;
}

.sba-email-form input::placeholder { color: rgba(255,255,255,.5); }
.sba-email-feedback { font-size: 13px; color: #22c55e; }

/* ── Sections ─────────────────────────────────────────────── */
.sba-section {
    padding: 28px 32px;
    border-bottom: 1px solid #f0f0f0;
}

.sba-section:last-child { border-bottom: none; }

.sba-section-title {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 700;
    color: #0f3460;
    text-transform: uppercase;
    letter-spacing: .06em;
}

/* ── Summary ──────────────────────────────────────────────── */
.sba-summary-text {
    font-size: 15px;
    color: #374151;
    margin: 0 0 16px;
}

.sba-clarity-box {
    background: #f0f7ff;
    border-left: 4px solid #3b82f6;
    border-radius: 0 8px 8px 0;
    padding: 12px 16px;
    font-size: 14px;
    color: #1e3a5f;
}

/* ── Score Bars ───────────────────────────────────────────── */
.sba-score-bars { display: flex; flex-direction: column; gap: 10px; }

.sba-score-bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sba-score-bar-label {
    font-size: 13px;
    color: #374151;
    width: 200px;
    flex-shrink: 0;
}

.sba-score-bar-track {
    flex: 1;
    height: 10px;
    background: #e5e7eb;
    border-radius: 5px;
    overflow: hidden;
}

.sba-score-bar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width .6s ease;
}

.sba-score-bar-value {
    font-size: 12px;
    font-weight: 700;
    color: #374151;
    width: 40px;
    text-align: right;
    flex-shrink: 0;
}

/* ── Two-Column: Wins + Priorities ───────────────────────── */
.sba-two-col-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    padding: 0;
}

.sba-two-col-item {
    padding: 28px 32px;
}

.sba-two-col-item:first-child {
    border-right: 1px solid #f0f0f0;
}

.sba-wins-title  { color: #15803d; }
.sba-priorities-title { color: #b45309; }

.sba-styled-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.sba-styled-list li {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 8px 0;
    border-bottom: 1px solid #f5f5f5;
    font-size: 14px;
    color: #374151;
}

.sba-styled-list li:last-child { border-bottom: none; }

.sba-list-icon {
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 1px;
}

.sba-wins-list .sba-list-icon    { color: #22c55e; }
.sba-priorities-list .sba-list-icon { color: #f59e0b; }

/* ── Element Cards ────────────────────────────────────────── */
.sba-elements-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sba-element-card {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
}

.sba-element-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    background: #fafafa;
    border-bottom: 1px solid #f0f0f0;
}

.sba-element-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #0f3460;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.sba-element-title-wrap { flex: 1; }

.sba-element-title {
    margin: 0 0 2px;
    font-size: 15px;
    font-weight: 700;
    color: #1a1a2e;
}

.sba-element-principle {
    margin: 0;
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
}

.sba-element-score-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.sba-element-score {
    font-size: 15px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 6px;
    color: #fff;
}

.sba-verdict-chip {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.sba-verdict-pass    { background: #dcfce7; color: #15803d; }
.sba-verdict-partial { background: #fef3c7; color: #92400e; }
.sba-verdict-fail    { background: #fee2e2; color: #991b1b; }

.sba-score-progress {
    height: 4px;
    background: #f0f0f0;
}

.sba-score-fill {
    height: 100%;
    transition: width .5s ease;
}

.sba-element-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sba-element-found,
.sba-element-rec {
    font-size: 14px;
    color: #374151;
}

.sba-element-found strong,
.sba-element-rec strong {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #6b7280;
    margin-bottom: 4px;
}

.sba-element-rewrite strong {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #6b7280;
    margin-bottom: 4px;
}

.sba-rewrite-quote {
    margin: 0;
    padding: 10px 16px;
    background: #f8faff;
    border-left: 3px solid #3b82f6;
    border-radius: 0 6px 6px 0;
    font-style: italic;
    font-size: 14px;
    color: #1e3a5f;
}

/* ── Rewrites Section ─────────────────────────────────────── */
.sba-rewrites-section { background: #fafbff; }

.sba-rewrites-intro {
    font-size: 13px;
    color: #6b7280;
    margin: 0 0 16px;
    font-style: italic;
}

.sba-rewrites-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.sba-rewrite-item {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px 16px;
}

.sba-rewrite-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #6b7280;
    margin-bottom: 6px;
    font-weight: 600;
}

.sba-rewrite-value {
    font-size: 14px;
    font-style: italic;
    color: #0f3460;
    font-weight: 600;
}

/* ── Report Footer ────────────────────────────────────────── */
.sba-report-footer {
    padding: 20px 32px;
    background: #f8f9fa;
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
    border-top: 1px solid #e5e7eb;
}

.sba-report-footer p { margin: 4px 0; }
.sba-disclaimer { font-style: italic; }

/* ── Report Header: URL link + page title ─────────────────── */
.sba-url-link {
    color: rgba(255,255,255,.7);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color .15s;
}

.sba-url-link:hover {
    color: #fff;
    text-decoration: underline;
}

.sba-ext-icon {
    flex-shrink: 0;
    vertical-align: middle;
    opacity: .7;
}

.sba-url-link:hover .sba-ext-icon {
    opacity: 1;
}

.sba-report-pagetitle {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 400;
    opacity: .65;
    font-style: italic;
    color: #fff;
    line-height: 1.3;
}

/* ── History table: Company Name inline edit ──────────────── */
.sba-company-cell {
    white-space: nowrap;
}

.sba-company-name {
    margin-right: 4px;
}

.sba-company-edit-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    font-size: 13px;
    padding: 0 3px;
    line-height: 1;
    vertical-align: middle;
    opacity: .6;
    transition: opacity .15s;
}

.sba-company-edit-btn:hover {
    opacity: 1;
    color: #0f3460;
}

.sba-company-edit-form {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
}

.sba-company-input {
    padding: 4px 7px;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    font-size: 13px;
    min-width: 140px;
    color: #1a1a2e;
}

/* ── Form: text input (company name) ─────────────────────── */
.sba-form-row input[type="text"] {
    width: 100%;
    max-width: 480px;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    color: #1a1a2e;
}

/* ── Score Badge (history table) ─────────────────────────── */
.sba-score-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
}

/* ── Form (shared) ────────────────────────────────────────── */
.sba-audit-form-card {
    background: #f8f9ff;
    border: 1px solid #dbe4ff;
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 20px;
}

.sba-form-heading {
    margin: 0 0 6px;
    font-size: 18px;
    color: #0f3460;
}

.sba-form-desc {
    margin: 0 0 16px;
    font-size: 14px;
    color: #6b7280;
}

.sba-form-row {
    margin-bottom: 14px;
}

.sba-form-row label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 5px;
}

.sba-form-row input[type="url"],
.sba-form-row input[type="email"] {
    width: 100%;
    max-width: 480px;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    color: #1a1a2e;
}

.sba-form-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.sba-email-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #6b7280;
    cursor: pointer;
}

/* ── Status / Loading ─────────────────────────────────────── */
.sba-status {
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sba-status.sba-status-loading {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

.sba-status.sba-status-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.sba-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #bfdbfe;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: sba-spin .8s linear infinite;
}

@keyframes sba-spin { to { transform: rotate(360deg); } }

/* ── Login notice ─────────────────────────────────────────── */
.sba-login-notice {
    padding: 16px;
    background: #fff3cd;
    border: 1px solid #ffecb5;
    border-radius: 8px;
    font-size: 14px;
}

.sba-notice-warn {
    padding: 12px 16px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 640px) {
    .sba-report-header-inner { flex-direction: column; }
    .sba-two-col-section     { grid-template-columns: 1fr; }
    .sba-two-col-item:first-child { border-right: none; border-bottom: 1px solid #f0f0f0; }
    .sba-rewrites-grid       { grid-template-columns: 1fr; }
    .sba-score-bar-label     { width: 130px; font-size: 12px; }
    .sba-section             { padding: 20px 16px; }
    .sba-report-header       { padding: 20px 16px; }
}

/* ── Popup Window Styles ──────────────────────────────────── */
.sba-popup-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #1a1a2e;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,.3);
    gap: 12px;
}

.sba-popup-toolbar-brand {
    color: rgba(255,255,255,.7);
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.sba-popup-toolbar-brand strong {
    color: #fff;
}

.sba-popup-toolbar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.sba-popup-print-btn {
    background: #e74c3c;
    color: #fff;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.sba-popup-print-btn:hover { opacity: .85; }

.sba-popup-close-btn {
    background: rgba(255,255,255,.12);
    color: #fff;
    border: 1px solid rgba(255,255,255,.25);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.sba-popup-close-btn:hover { background: rgba(255,255,255,.2); }

.sba-popup-body {
    padding-top: 56px; /* clear the fixed toolbar */
    background: #f0f2f5;
    min-height: 100vh;
}

.sba-popup-body .sba-report {
    max-width: 860px;
    margin: 24px auto;
    box-shadow: 0 4px 32px rgba(0,0,0,.12);
}

/* ── Print Styles ─────────────────────────────────────────── */
@media print {
    .sba-report {
        box-shadow: none;
        border-radius: 0;
        max-width: 100%;
        margin: 0;
    }

    .no-print,
    .sba-report-actions,
    .sba-popup-toolbar,
    #wpadminbar {
        display: none !important;
    }

    .sba-popup-body {
        padding-top: 0;
        background: #fff;
    }

    .sba-popup-body .sba-report {
        margin: 0;
        box-shadow: none;
    }

    .sba-report-header {
        background: #1a1a2e !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .sba-element-card { page-break-inside: avoid; }

    .sba-section { padding: 16px 24px; }

    a { text-decoration: none; color: inherit; }
}

/* ── Public shortcode — split first/last name row ─────────── */
.sba-form-row-half {
    display: flex;
    gap: 16px;
}

.sba-form-row-half > div {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.sba-form-row-half > div label {
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
    color: #374151;
}

.sba-form-row-half > div input {
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 15px;
    width: 100%;
    box-sizing: border-box;
    transition: border-color .2s;
}

.sba-form-row-half > div input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

@media (max-width: 520px) {
    .sba-form-row-half { flex-direction: column; gap: 0; }
}

/* ── Thank-you card ─────────────────────────────────────────── */
.sba-thankyou-card {
    text-align: center;
    padding: 48px 32px;
}

.sba-thankyou-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: #dcfce7;
    color: #16a34a;
    border-radius: 50%;
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 20px;
}

.sba-thankyou-card h3 {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 12px;
}

.sba-thankyou-card p {
    font-size: 16px;
    color: #4b5563;
    max-width: 440px;
    margin: 0 auto;
    line-height: 1.6;
}
