/**
 * ZipReviews Rating Calculator - WordPress Plugin Styles
 *
 * All selectors are prefixed with .zr-rc- to avoid conflicts
 * with WordPress themes and other plugins.
 */

/* ─── Widget Container ──────────────────────────────────────────────────────── */
.zr-rc-widget {
    max-width: 520px;
    margin: 2rem auto;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    border: 1px solid #e2e8f0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
    color: #1e293b;
    box-sizing: border-box;
}

.zr-rc-widget *,
.zr-rc-widget *::before,
.zr-rc-widget *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ─── Hidden Utility ─────────────────────────────────────────────────────────── */
.zr-rc-hidden {
    display: none !important;
}

/* ─── Header ─────────────────────────────────────────────────────────────────── */
.zr-rc-header {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.zr-rc-header-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.zr-rc-header-icon svg {
    display: block;
}

.zr-rc-header-text h2 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #ffffff;
    margin: 0;
    padding: 0;
    border: none;
    line-height: 1.3;
}

.zr-rc-header-text p {
    font-size: 0.8rem;
    opacity: 0.85;
    margin: 2px 0 0 0;
    color: #ffffff;
}

/* ─── Body ───────────────────────────────────────────────────────────────────── */
.zr-rc-body {
    padding: 1.5rem;
}

/* ─── Form Groups ────────────────────────────────────────────────────────────── */
.zr-rc-form-group {
    margin-bottom: 1.25rem;
    overflow: visible;
}

.zr-rc-form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: #1e293b;
    margin-bottom: 0.4rem;
}

/* Prevent WP themes from constraining form elements */
.zr-rc-widget select,
.zr-rc-widget input,
.zr-rc-widget button {
    max-height: none !important;
    height: auto !important;
}

/* ─── Autocomplete Wrapper ───────────────────────────────────────────────────── */
.zr-rc-autocomplete-wrapper {
    position: relative;
    flex: 1;
    min-width: 0;
}

.zr-rc-widget .zr-rc-input-group .zr-rc-autocomplete-wrapper .zr-rc-input {
    width: 100% !important;
}

/* ─── Autocomplete Dropdown ──────────────────────────────────────────────────── */
.zr-rc-autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    max-height: 260px;
    overflow-y: auto;
}

.zr-rc-autocomplete-item {
    padding: 0.6rem 0.9rem;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid #f1f5f9;
}

.zr-rc-autocomplete-item:last-child {
    border-bottom: none;
}

.zr-rc-autocomplete-item:hover,
.zr-rc-autocomplete-item.zr-rc-autocomplete-active {
    background: #eff6ff;
}

.zr-rc-autocomplete-name {
    font-weight: 600;
    font-size: 0.88rem;
    color: #1e293b;
    line-height: 1.3;
}

.zr-rc-autocomplete-address {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 1px;
    line-height: 1.3;
}

.zr-rc-autocomplete-hint {
    padding: 0.55rem 0.75rem;
    font-size: 0.78rem;
    color: #810038;
    font-weight: 600;
    cursor: pointer;
    border-top: 1px solid #f1f5f9;
    text-align: center;
}
.zr-rc-autocomplete-hint:hover {
    background: rgba(129, 0, 56, 0.04);
}

/* ─── Input Group (input + search button) — kept for backwards compat ────────── */
.zr-rc-widget .zr-rc-input-group {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 0.5rem !important;
    align-items: stretch !important;
    width: 100% !important;
}

/* ─── Input ──────────────────────────────────────────────────────────────────── */
.zr-rc-input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    background: #f8fafc;
    color: #1e293b;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.zr-rc-widget .zr-rc-input-group .zr-rc-input {
    flex: 1 1 0% !important;
    min-width: 0 !important;
    width: auto !important;
}

.zr-rc-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.zr-rc-input::placeholder {
    color: #94a3b8;
}

/* ─── Search Button ──────────────────────────────────────────────────────────── */
.zr-rc-widget .zr-rc-search-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.35rem !important;
    padding: 0.7rem 1rem !important;
    background: #2563eb !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 8px !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    font-family: inherit;
    cursor: pointer !important;
    white-space: nowrap !important;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    line-height: 1.5 !important;
    text-decoration: none !important;
    box-shadow: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}

.zr-rc-widget .zr-rc-search-btn:hover {
    background: #1d4ed8 !important;
    color: #ffffff !important;
}

.zr-rc-widget .zr-rc-search-btn:active {
    transform: scale(0.97);
}

.zr-rc-widget .zr-rc-search-btn:disabled {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
    transform: none;
}

.zr-rc-widget .zr-rc-search-btn svg {
    display: inline-block !important;
    vertical-align: middle;
    flex-shrink: 0;
    stroke: #ffffff !important;
}

/* ─── Select ─────────────────────────────────────────────────────────────────── */
.zr-rc-select {
    width: 100%;
    height: auto !important;
    min-height: 44px;
    padding: 0.7rem 2.5rem 0.7rem 0.9rem !important;
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    line-height: 1.5;
    background-color: #f8fafc;
    color: #1e293b;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    overflow: visible;
    max-height: none !important;
    clip: auto !important;
    -webkit-clip-path: none !important;
    clip-path: none !important;
}

.zr-rc-select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

/* ─── Slider ─────────────────────────────────────────────────────────────────── */
.zr-rc-slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.zr-rc-slider {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #e2e8f0;
    border-radius: 3px;
    cursor: pointer;
    outline: none;
    margin: 0;
}

.zr-rc-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: #2563eb;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
    transition: transform 0.15s, box-shadow 0.15s;
    border: none;
}

.zr-rc-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

.zr-rc-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #2563eb;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.zr-rc-slider-value {
    min-width: 75px;
    text-align: right;
    font-weight: 600;
    font-size: 0.9rem;
    color: #2563eb;
    white-space: nowrap;
}

/* ─── Search Results List (pick a business) — kept for backwards compat ───────── */
.zr-rc-widget .zr-rc-search-results {
    margin-bottom: 1.25rem;
}

.zr-rc-widget .zr-rc-search-results-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
    margin: 0 0 0.5rem 0;
}

.zr-rc-widget .zr-rc-search-result-item {
    padding: 0.65rem 0.85rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 0.4rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    background: #ffffff;
}

.zr-rc-widget .zr-rc-search-result-item:hover {
    border-color: #2563eb;
    background: #eff6ff;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.08);
}

.zr-rc-widget .zr-rc-search-result-item:last-child {
    margin-bottom: 0;
}

.zr-rc-widget .zr-rc-search-result-name {
    font-weight: 600;
    font-size: 0.88rem;
    color: #1e293b;
    line-height: 1.3;
}

.zr-rc-widget .zr-rc-search-result-detail {
    font-size: 0.8rem;
    color: #475569;
    margin-top: 2px;
}

.zr-rc-widget .zr-rc-search-result-detail .zr-rc-stars {
    color: #f59e0b;
}

.zr-rc-widget .zr-rc-search-result-address {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 2px;
    line-height: 1.3;
}

/* ─── Current Info Box ───────────────────────────────────────────────────────── */
.zr-rc-current-info {
    padding: 0.75rem 1rem;
    background: #ecfdf5;
    border: 1px solid #86efac;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    font-size: 0.85rem;
    color: #166534;
    line-height: 1.5;
}

.zr-rc-current-info strong {
    font-weight: 600;
}

.zr-rc-current-info .zr-rc-stars {
    color: #f59e0b;
}

/* ─── Loading ────────────────────────────────────────────────────────────────── */
.zr-rc-loading {
    padding: 2rem 1rem;
    text-align: center;
    color: #2563eb;
}

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

.zr-rc-loading svg {
    animation: zr-rc-spin 1s linear infinite;
    display: inline-block;
}

.zr-rc-loading p,
.zr-rc-loading .zr-rc-loading-text {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #64748b;
}

/* ─── Error ──────────────────────────────────────────────────────────────────── */
.zr-rc-error {
    padding: 0.75rem 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #991b1b;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* ─── Success Message ────────────────────────────────────────────────────────── */
.zr-rc-success-msg {
    padding: 0.75rem 1rem;
    background: #ecfdf5;
    border: 1px solid #86efac;
    border-radius: 8px;
    color: #166534;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* ─── Results ────────────────────────────────────────────────────────────────── */
.zr-rc-results {
    background: #f8fafc;
    border-radius: 10px;
    padding: 1.25rem;
    border: 1px solid #e2e8f0;
}

.zr-rc-results-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
}

.zr-rc-results-header svg {
    stroke: #2563eb;
    flex-shrink: 0;
}

.zr-rc-results-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #2563eb;
}

.zr-rc-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px dashed #e2e8f0;
}

.zr-rc-stat:last-of-type {
    border-bottom: none;
}

.zr-rc-stat-label {
    font-size: 0.85rem;
    color: #64748b;
}

.zr-rc-stat-value {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.9rem;
}

.zr-rc-stat-value.zr-rc-highlight {
    color: #2563eb;
    font-size: 1rem;
}

.zr-rc-disclaimer {
    margin-top: 1rem;
    padding: 0.6rem 0.75rem;
    background: #ffffff;
    border-radius: 6px;
    font-size: 0.72rem;
    color: #64748b;
    line-height: 1.4;
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
}

.zr-rc-disclaimer svg {
    flex-shrink: 0;
    margin-top: 1px;
}

/* ─── Calculate Button ───────────────────────────────────────────────────────── */
.zr-rc-calculate-btn {
    width: 100%;
    padding: 0.75rem 1.25rem;
    background: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background 0.2s, transform 0.1s;
    line-height: 1.5;
}

.zr-rc-calculate-btn:hover {
    background: #1d4ed8;
}

.zr-rc-calculate-btn:active {
    transform: scale(0.98);
}

.zr-rc-calculate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.zr-rc-calculate-btn svg {
    display: inline-block;
    vertical-align: middle;
}

/* ─── Footer ─────────────────────────────────────────────────────────────────── */
.zr-rc-footer {
    padding: 0.75rem 1.5rem;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    text-align: center;
}

.zr-rc-footer a {
    font-size: 0.72rem;
    color: #64748b;
    text-decoration: none;
    transition: color 0.2s;
}

.zr-rc-footer a:hover {
    color: #2563eb;
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .zr-rc-body {
        padding: 1rem;
    }

    .zr-rc-header {
        padding: 1rem 1.25rem;
    }

    .zr-rc-header-text h2 {
        font-size: 1rem;
    }
}
