/**
 * Shipping Manager setup guide.
 *
 * Shown at WooCommerce -> Settings -> Shipping -> Shipping Manager.
 * Follows the plugin's own admin theme: orange #f25500 accents, white cards on
 * the WordPress grey, hairline borders, 500-weight headings.
 *
 * Note on specificity: WordPress admin styles `a` aggressively, so anything
 * that sets a link colour here has to be at least as specific as `.tpsm-guide a`
 * or it silently loses. Button rules below are written as `.tpsm-guide a.x`
 * for exactly that reason.
 */

.tpsm-guide {
    --tpsm-brand: #f25500;
    --tpsm-brand-dark: #d44a00;
    --tpsm-brand-tint: #fff3ec;
    --tpsm-brand-line: #ffd6bf;
    --tpsm-ok: #00a32a;
    --tpsm-ok-tint: #edf7ee;
    --tpsm-surface: #fff;
    --tpsm-panel: #f7f8f9;
    --tpsm-line: #e2e4e7;
    --tpsm-line-soft: #eef0f1;
    --tpsm-heading: #1d2327;
    --tpsm-body: #3c434a;
    --tpsm-muted: #787c82;
    --tpsm-radius: 10px;
    --tpsm-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);

    box-sizing: border-box;
    max-width: 1180px;
    /* Breathing room from the WooCommerce sub-navigation above. */
    margin: 24px 0 32px;
    color: var(--tpsm-body);
    font-size: 14px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

.tpsm-guide *,
.tpsm-guide *::before,
.tpsm-guide *::after {
    box-sizing: inherit;
}

/* WooCommerce prints an empty settings table / save row after the section. */
.tpsm-guide ~ .form-table,
.tpsm-guide ~ p.submit {
    display: none;
}

.tpsm-guide p {
    margin: 0 0 12px;
}

.tpsm-guide p:last-child {
    margin-bottom: 0;
}

.tpsm-guide .tpsm-i {
    flex: 0 0 auto;
    vertical-align: middle;
}

/* -- Links ---------------------------------------------------------------- */

.tpsm-guide a {
    color: var(--tpsm-brand);
    text-decoration: none;
    box-shadow: none;
    transition: color 0.15s ease;
}

.tpsm-guide a:hover,
.tpsm-guide a:focus {
    color: var(--tpsm-brand-dark);
    box-shadow: none;
}

.tpsm-guide a:focus-visible {
    outline: 2px solid var(--tpsm-brand);
    outline-offset: 2px;
    border-radius: 3px;
}

.tpsm-guide a.tpsm-guide-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
}

.tpsm-guide a.tpsm-guide-link .tpsm-i {
    width: 13px;
    height: 13px;
    transition: transform 0.15s ease;
}

.tpsm-guide a.tpsm-guide-link:hover .tpsm-i {
    transform: translateX(2px);
}

/* -- Header --------------------------------------------------------------- */

.tpsm-guide-topbar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 24px;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: var(--tpsm-surface);
    border: 1px solid var(--tpsm-line);
    border-radius: var(--tpsm-radius);
    box-shadow: var(--tpsm-shadow);
    margin-bottom: 16px;
}

.tpsm-guide-brand {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
}

.tpsm-guide-logo {
    display: flex;
    align-items: center;
    padding-right: 18px;
    border-right: 1px solid var(--tpsm-line);
}

.tpsm-guide-logo img {
    display: block;
    width: 52px;
    height: 48px;
}

.tpsm-guide-titles {
    display: block;
    min-width: 0;
}

.tpsm-guide-title {
    display: block;
    color: var(--tpsm-heading);
    font-size: 20px;
    font-weight: 600;
    line-height: 1.3;
}

.tpsm-guide-tagline {
    display: block;
    color: var(--tpsm-muted);
    font-size: 13px;
}

.tpsm-guide-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

/* -- Buttons -------------------------------------------------------------- */

.tpsm-guide a.tpsm-guide-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 6px;
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.tpsm-guide a.tpsm-guide-btn .tpsm-i {
    width: 14px;
    height: 14px;
}

.tpsm-guide a.tpsm-guide-btn-primary {
    background: var(--tpsm-brand);
    border-color: var(--tpsm-brand);
    /* Must beat `.tpsm-guide a`, or the label renders orange on orange. */
    color: #fff;
}

.tpsm-guide a.tpsm-guide-btn-primary:hover,
.tpsm-guide a.tpsm-guide-btn-primary:focus {
    background: var(--tpsm-brand-dark);
    border-color: var(--tpsm-brand-dark);
    color: #fff;
    transform: translateY(-1px);
}

.tpsm-guide a.tpsm-guide-btn-ghost {
    background: var(--tpsm-surface);
    border-color: var(--tpsm-line);
    color: var(--tpsm-body);
}

.tpsm-guide a.tpsm-guide-btn-ghost:hover,
.tpsm-guide a.tpsm-guide-btn-ghost:focus {
    border-color: var(--tpsm-brand);
    color: var(--tpsm-brand);
    background: var(--tpsm-brand-tint);
}

/* -- Status --------------------------------------------------------------- */

.tpsm-guide-status {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 20px;
    margin-bottom: 16px;
    border: 1px solid var(--tpsm-line);
    border-left: 4px solid var(--tpsm-line);
    border-radius: var(--tpsm-radius);
    background: var(--tpsm-surface);
    box-shadow: var(--tpsm-shadow);
}

.tpsm-guide-status.is-ready {
    border-left-color: var(--tpsm-ok);
    background: var(--tpsm-ok-tint);
    border-color: #cde8d2;
    border-left-color: var(--tpsm-ok);
}

.tpsm-guide-status.is-pending {
    border-color: var(--tpsm-brand-line);
    border-left-color: var(--tpsm-brand);
    background: var(--tpsm-brand-tint);
}

.tpsm-guide-status-icon {
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    margin-top: 8px;
    border-radius: 50%;
}

.tpsm-guide-status.is-ready .tpsm-guide-status-icon {
    background: var(--tpsm-ok);
    box-shadow: 0 0 0 3px rgba(0, 163, 42, 0.15);
}

.tpsm-guide-status.is-pending .tpsm-guide-status-icon {
    background: var(--tpsm-brand);
    box-shadow: 0 0 0 3px rgba(242, 85, 0, 0.15);
}

.tpsm-guide-status-text {
    margin: 0;
}

.tpsm-guide-status-text strong {
    color: var(--tpsm-heading);
}

/* -- Cards ---------------------------------------------------------------- */

.tpsm-guide-card {
    padding: 22px 24px 24px;
    margin-bottom: 16px;
    background: var(--tpsm-surface);
    border: 1px solid var(--tpsm-line);
    border-radius: var(--tpsm-radius);
    box-shadow: var(--tpsm-shadow);
}

.tpsm-guide-card:last-of-type {
    margin-bottom: 20px;
}

.tpsm-guide .tpsm-guide-h {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 4px;
    padding: 0;
    color: var(--tpsm-heading);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
}

.tpsm-guide .tpsm-guide-h .tpsm-i {
    width: 17px;
    height: 17px;
    color: var(--tpsm-brand);
}

.tpsm-guide-sub {
    margin: 0 0 16px;
    color: var(--tpsm-muted);
    font-size: 13px;
}

.tpsm-guide-lead {
    margin-top: 10px;
    max-width: 78ch;
}

/* Responsive two-up. Collapses on its own without a media query. */
.tpsm-guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
    align-items: start;
}

.tpsm-guide-grid > .tpsm-guide-card {
    margin-bottom: 0;
    height: 100%;
}

/* -- Flow ----------------------------------------------------------------- */

.tpsm-guide-flow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 18px;
}

.tpsm-guide-flow-step {
    padding: 8px 14px;
    border: 1px solid var(--tpsm-line);
    border-radius: 6px;
    background: var(--tpsm-panel);
    font-size: 13px;
    font-weight: 500;
    color: var(--tpsm-body);
    white-space: nowrap;
}

.tpsm-guide-flow-step.is-result {
    background: var(--tpsm-brand-tint);
    border-color: var(--tpsm-brand-line);
    color: var(--tpsm-brand-dark);
    font-weight: 600;
}

.tpsm-guide-flow-sep {
    display: inline-flex;
    color: #b8bcc2;
}

.tpsm-guide-flow-sep .tpsm-i {
    width: 15px;
    height: 15px;
}

/* -- Steps ---------------------------------------------------------------- */

.tpsm-guide-steps {
    list-style: none;
    margin: 16px 0 0;
    padding: 0;
    counter-reset: none;
}

.tpsm-guide-steps > li {
    position: relative;
    display: flex;
    gap: 16px;
    padding: 0 0 22px 0;
}

.tpsm-guide-steps > li:last-child {
    padding-bottom: 0;
}

/* Connector line between step markers. */
.tpsm-guide-steps > li:not(:last-child)::before {
    content: "";
    position: absolute;
    top: 32px;
    bottom: 6px;
    left: 15px;
    width: 2px;
    background: var(--tpsm-line);
}

.tpsm-guide-steps > li.is-done:not(:last-child)::before {
    background: var(--tpsm-brand-line);
}

.tpsm-guide-step-num {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--tpsm-line);
    background: var(--tpsm-surface);
    color: var(--tpsm-muted);
    font-size: 13px;
    font-weight: 700;
    font-style: normal;
    line-height: 1;
}

.tpsm-guide-step-num i {
    font-style: normal;
}

.tpsm-guide-step-num .tpsm-i {
    display: none;
    width: 15px;
    height: 15px;
    stroke-width: 2.2;
}

.tpsm-guide-steps > li.is-done .tpsm-guide-step-num {
    background: var(--tpsm-brand);
    border-color: var(--tpsm-brand);
    color: #fff;
}

.tpsm-guide-steps > li.is-done .tpsm-guide-step-num i {
    display: none;
}

.tpsm-guide-steps > li.is-done .tpsm-guide-step-num .tpsm-i {
    display: block;
}

.tpsm-guide-step-body {
    min-width: 0;
    padding-top: 3px;
}

.tpsm-guide .tpsm-guide-step-body h3 {
    margin: 0 0 2px;
    padding: 0;
    color: var(--tpsm-heading);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
}

.tpsm-guide-step-body p {
    margin: 0 0 6px;
    max-width: 72ch;
}

/* -- Conditions ----------------------------------------------------------- */

.tpsm-guide-conditions {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--tpsm-line-soft);
}

.tpsm-guide-conditions > li {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    align-items: center;
    padding: 10px 0;
    margin: 0;
    border-bottom: 1px solid var(--tpsm-line-soft);
}

.tpsm-guide-chip {
    flex: 0 0 auto;
    min-width: 132px;
    padding: 4px 10px;
    border-radius: 4px;
    background: var(--tpsm-brand-tint);
    border: 1px solid var(--tpsm-brand-line);
    color: var(--tpsm-brand-dark);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    line-height: 1.4;
}

.tpsm-guide-chip-desc {
    flex: 1 1 180px;
    font-size: 13px;
    color: var(--tpsm-body);
}

.tpsm-guide-note {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    margin: 16px 0 0;
    padding: 12px 14px;
    border-radius: 6px;
    background: var(--tpsm-panel);
    font-size: 12.5px;
    color: var(--tpsm-muted);
    line-height: 1.6;
}

.tpsm-guide-note .tpsm-i {
    width: 15px;
    height: 15px;
    margin-top: 2px;
    color: var(--tpsm-muted);
}

/* -- Stats ---------------------------------------------------------------- */

.tpsm-guide-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

.tpsm-guide-stat {
    padding: 14px;
    border: 1px solid var(--tpsm-line);
    border-radius: 8px;
    background: var(--tpsm-panel);
}

.tpsm-guide-stat-value {
    display: block;
    color: var(--tpsm-heading);
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
}

.tpsm-guide-stat-label {
    display: block;
    margin-top: 2px;
    color: var(--tpsm-heading);
    font-size: 12.5px;
    font-weight: 600;
}

.tpsm-guide-stat-note {
    display: block;
    margin-top: 3px;
    color: var(--tpsm-muted);
    font-size: 12px;
    line-height: 1.5;
}

/* -- Configured methods --------------------------------------------------- */

.tpsm-guide-methods {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    margin: 0;
    padding: 0;
}

.tpsm-guide-methods > li {
    margin: 0;
}

.tpsm-guide a.tpsm-guide-method,
.tpsm-guide-methods a {
    display: block;
    height: 100%;
    padding: 14px 16px;
    border: 1px solid var(--tpsm-line);
    border-radius: 8px;
    background: var(--tpsm-panel);
    transition: all 0.15s ease;
}

.tpsm-guide-methods a:hover,
.tpsm-guide-methods a:focus {
    border-color: var(--tpsm-brand);
    background: var(--tpsm-brand-tint);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(16, 24, 40, 0.06);
}

.tpsm-guide-method-head {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    align-items: center;
    justify-content: space-between;
}

.tpsm-guide-method-name {
    color: var(--tpsm-heading);
    font-size: 14px;
    font-weight: 600;
    word-break: break-word;
}

.tpsm-guide-method-count {
    flex: 0 0 auto;
    padding: 2px 9px;
    border-radius: 10px;
    background: var(--tpsm-brand);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.tpsm-guide-method-count.is-empty {
    background: #a7aaad;
}

.tpsm-guide-method-zone {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    color: var(--tpsm-muted);
    font-size: 12px;
}

.tpsm-guide-method-zone .tpsm-i {
    width: 13px;
    height: 13px;
}

/* -- Tip ------------------------------------------------------------------ */

.tpsm-guide-tip {
    background: var(--tpsm-panel);
    box-shadow: none;
}

.tpsm-guide-tip p {
    max-width: 78ch;
}

/* -- Footer --------------------------------------------------------------- */

.tpsm-guide-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 24px;
    align-items: center;
    justify-content: space-between;
    padding-top: 4px;
}

.tpsm-guide-footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin: 0;
}

.tpsm-guide-footer-links a {
    font-weight: 600;
}

.tpsm-guide-rating {
    margin: 0;
    color: var(--tpsm-muted);
    font-size: 12px;
}

.tpsm-guide-rating .tpsm-guide-stars {
    color: #ffb900;
    font-size: 13px;
    margin: 0 4px;
    letter-spacing: 1px;
}

/* -- Responsive ----------------------------------------------------------- */

@media screen and (max-width: 960px) {
    .tpsm-guide-topbar {
        align-items: flex-start;
    }

    .tpsm-guide-actions {
        width: 100%;
    }

    .tpsm-guide a.tpsm-guide-btn {
        flex: 1 1 auto;
        justify-content: center;
    }
}

@media screen and (max-width: 782px) {
    /* WordPress switches to its touch admin layout here. */
    .tpsm-guide {
        margin-top: 16px;
        font-size: 15px;
    }

    .tpsm-guide-topbar,
    .tpsm-guide-card {
        padding: 18px 16px;
        border-radius: 8px;
    }

    .tpsm-guide-brand {
        gap: 14px;
    }

    .tpsm-guide-logo {
        padding-right: 14px;
    }

    .tpsm-guide-logo img {
        width: 42px;
        height: 39px;
    }

    .tpsm-guide-title {
        font-size: 17px;
    }

    .tpsm-guide a.tpsm-guide-btn {
        padding: 12px 16px;
        white-space: normal;
    }

    .tpsm-guide-flow-step {
        white-space: normal;
    }

    .tpsm-guide-chip {
        min-width: 0;
    }

    .tpsm-guide-conditions > li {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .tpsm-guide-footer {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media screen and (max-width: 600px) {
    .tpsm-guide-brand {
        flex-wrap: wrap;
    }

    .tpsm-guide-logo {
        border-right: 0;
        padding-right: 0;
    }

    .tpsm-guide-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .tpsm-guide-stats,
    .tpsm-guide-methods {
        grid-template-columns: 1fr;
    }

    .tpsm-guide-steps > li {
        gap: 12px;
    }
}

/* -- Motion / contrast preferences ---------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .tpsm-guide *,
    .tpsm-guide *::before,
    .tpsm-guide *::after {
        transition: none !important;
        transform: none !important;
    }
}
