/**
 * Smart Home Compatibility Checker
 * --------------------------------
 * Stylesheet for the [smart_checker] shortcode UI.
 *
 * Design notes:
 * - Every rule is scoped under `.shcc-checker-wrapper` (or its descendants)
 *   so it cannot leak into the host WordPress theme.
 * - CSS custom properties live on the wrapper for easy theming/overrides.
 * - Layout is mobile-first; the form switches to a 2-column grid at >= 600px.
 * - All interactive elements have transitions, hover states, and focus rings.
 */

/* ==========================================================================
   1. Wrapper / theme tokens
   ========================================================================== */
.shcc-checker-wrapper {
    /* Theming tokens - override these on the wrapper to re-skin the widget. */
    --shcc-bg:            #ffffff;
    --shcc-surface:       #f8fafc;
    --shcc-border:        #e2e8f0;
    --shcc-border-strong: #cbd5e1;
    --shcc-text:          #0f172a;
    --shcc-text-muted:    #64748b;
    --shcc-primary:       #4f46e5;
    --shcc-primary-hover: #4338ca;
    --shcc-primary-soft:  rgba(79, 70, 229, 0.12);
    --shcc-success:       #16a34a;
    --shcc-success-soft:  #dcfce7;
    --shcc-danger:        #dc2626;
    --shcc-danger-soft:   #fee2e2;
    --shcc-radius:        12px;
    --shcc-radius-sm:     8px;
    --shcc-shadow:        0 4px 12px rgba(15, 23, 42, 0.06);
    --shcc-shadow-hover:  0 10px 24px rgba(15, 23, 42, 0.10);
    --shcc-transition:    180ms cubic-bezier(0.4, 0, 0.2, 1);

    box-sizing: border-box;
    max-width: 760px;
    margin: 1.5em auto;
    padding: 1.75rem;
    background: var(--shcc-bg);
    color: var(--shcc-text);
    border: 1px solid var(--shcc-border);
    border-radius: var(--shcc-radius);
    box-shadow: var(--shcc-shadow);
    font-family: inherit; /* respect the host theme's typography */
    line-height: 1.5;
}

/* Reset box-sizing for everything inside the widget so our paddings/widths
   behave predictably regardless of the host theme's reset. */
.shcc-checker-wrapper,
.shcc-checker-wrapper *,
.shcc-checker-wrapper *::before,
.shcc-checker-wrapper *::after {
    box-sizing: border-box;
}

.shcc-checker-wrapper .shcc-checker-title {
    margin: 0 0 1.25rem;
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--shcc-text);
    letter-spacing: -0.01em;
}

/* ==========================================================================
   2. Form layout
   ========================================================================== */
.shcc-checker-wrapper .shcc-checker-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

@media (min-width: 600px) {
    .shcc-checker-wrapper .shcc-checker-form {
        grid-template-columns: 1fr 1fr;
        align-items: end;
    }

    /* The action button sits below the inputs on its own full-width row. */
    .shcc-checker-wrapper .shcc-field-action {
        grid-column: 1 / -1;
    }
}

.shcc-checker-wrapper .shcc-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.shcc-checker-wrapper .shcc-field label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--shcc-text);
    letter-spacing: 0.01em;
}

/* ==========================================================================
   3. Inputs (select + search) - shared base styles
   ========================================================================== */
.shcc-checker-wrapper .shcc-hub-select,
.shcc-checker-wrapper .shcc-device-input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    font-size: 1rem;
    font-family: inherit;
    color: var(--shcc-text);
    background-color: var(--shcc-bg);
    border: 1px solid var(--shcc-border-strong);
    border-radius: var(--shcc-radius-sm);
    outline: none;
    transition:
        border-color var(--shcc-transition),
        box-shadow var(--shcc-transition),
        background-color var(--shcc-transition);
    -webkit-appearance: none;
    appearance: none;
}

.shcc-checker-wrapper .shcc-hub-select:hover,
.shcc-checker-wrapper .shcc-device-input:hover {
    border-color: var(--shcc-primary);
}

.shcc-checker-wrapper .shcc-hub-select:focus,
.shcc-checker-wrapper .shcc-device-input:focus {
    border-color: var(--shcc-primary);
    box-shadow: 0 0 0 4px var(--shcc-primary-soft);
}

.shcc-checker-wrapper .shcc-device-input::placeholder {
    color: var(--shcc-text-muted);
    opacity: 1;
}

/* Custom chevron for the <select> - replaces the default OS arrow. */
.shcc-checker-wrapper .shcc-hub-select {
    padding-right: 2.4rem;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%2364748b' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    background-size: 12px 8px;
    cursor: pointer;
}

/* ==========================================================================
   4. Submit button
   ========================================================================== */
.shcc-checker-wrapper .shcc-check-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.8rem 1.25rem;
    font-size: 1rem;
    font-family: inherit;
    font-weight: 600;
    color: #ffffff;
    background-color: var(--shcc-primary);
    border: 1px solid var(--shcc-primary);
    border-radius: var(--shcc-radius-sm);
    cursor: pointer;
    transition:
        background-color var(--shcc-transition),
        border-color var(--shcc-transition),
        transform var(--shcc-transition),
        box-shadow var(--shcc-transition);
    text-decoration: none;
}

.shcc-checker-wrapper .shcc-check-btn:hover {
    background-color: var(--shcc-primary-hover);
    border-color: var(--shcc-primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shcc-shadow-hover);
}

.shcc-checker-wrapper .shcc-check-btn:active {
    transform: translateY(0);
    box-shadow: var(--shcc-shadow);
}

.shcc-checker-wrapper .shcc-check-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--shcc-primary-soft);
}

/* ==========================================================================
   5. Results container
   ========================================================================== */
.shcc-checker-wrapper #checker-results,
.shcc-checker-wrapper .shcc-results {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

/* Subtle entrance animation when results are (re)rendered. */
@keyframes shccFadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   6. Device cards
   ========================================================================== */
.shcc-checker-wrapper .shcc-device-card {
    padding: 1rem 1.1rem;
    background-color: var(--shcc-surface);
    border: 1px solid var(--shcc-border);
    border-radius: var(--shcc-radius-sm);
    transition:
        transform var(--shcc-transition),
        box-shadow var(--shcc-transition),
        border-color var(--shcc-transition);
    animation: shccFadeIn 220ms ease-out both;
}

.shcc-checker-wrapper .shcc-device-card:hover {
    transform: translateY(-2px);
    border-color: var(--shcc-border-strong);
    box-shadow: var(--shcc-shadow-hover);
}

.shcc-checker-wrapper .shcc-device-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.shcc-checker-wrapper .shcc-device-name {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--shcc-text);
    line-height: 1.3;
}

.shcc-checker-wrapper .shcc-device-meta {
    margin-bottom: 0.6rem;
}

.shcc-checker-wrapper .shcc-device-category {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--shcc-primary);
    background-color: var(--shcc-primary-soft);
    border-radius: 999px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.shcc-checker-wrapper .shcc-device-hubs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    color: var(--shcc-text-muted);
}

.shcc-checker-wrapper .shcc-hubs-label {
    font-weight: 600;
    color: var(--shcc-text);
}

.shcc-checker-wrapper .shcc-hub-tag {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--shcc-text);
    background-color: var(--shcc-bg);
    border: 1px solid var(--shcc-border);
    border-radius: 999px;
    transition:
        border-color var(--shcc-transition),
        background-color var(--shcc-transition);
}

.shcc-checker-wrapper .shcc-hub-tag:hover {
    border-color: var(--shcc-primary);
    background-color: var(--shcc-primary-soft);
}

/* ==========================================================================
   7. Compatibility status badges
   ========================================================================== */
.shcc-checker-wrapper .shcc-status {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.65rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: 999px;
    line-height: 1.2;
    white-space: nowrap;
}

.shcc-checker-wrapper .shcc-status--ok {
    color: var(--shcc-success);
    background-color: var(--shcc-success-soft);
    border: 1px solid var(--shcc-success);
}

.shcc-checker-wrapper .shcc-status--no {
    color: var(--shcc-danger);
    background-color: var(--shcc-danger-soft);
    border: 1px solid var(--shcc-danger);
}

/* ==========================================================================
   8. Empty / hint messages
   ========================================================================== */
.shcc-checker-wrapper .shcc-message {
    margin: 0;
    padding: 1.1rem 1.25rem;
    text-align: center;
    background-color: var(--shcc-surface);
    border: 1px dashed var(--shcc-border-strong);
    border-radius: var(--shcc-radius-sm);
    color: var(--shcc-text-muted);
    font-size: 0.95rem;
    animation: shccFadeIn 220ms ease-out both;
}

.shcc-checker-wrapper .shcc-message--hint {
    color: var(--shcc-text-muted);
}

.shcc-checker-wrapper .shcc-message--empty {
    color: var(--shcc-text);
    font-weight: 500;
}

/* ==========================================================================
   9. Small-screen tweaks
   ========================================================================== */
@media (max-width: 480px) {
    .shcc-checker-wrapper {
        padding: 1.25rem;
        margin: 1rem auto;
        border-radius: var(--shcc-radius-sm);
    }

    .shcc-checker-wrapper .shcc-checker-title {
        font-size: 1.2rem;
    }

    .shcc-checker-wrapper .shcc-device-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ==========================================================================
   10. Respect users who prefer reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .shcc-checker-wrapper *,
    .shcc-checker-wrapper *::before,
    .shcc-checker-wrapper *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
