/**
 * WP Service Booking - Frontend Booking Widget Styles
 *
 * Uses CSS custom properties (--wpsb-*) injected dynamically
 * from the Appearance settings. Fallback values ensure the widget
 * works even if the inline style block is missing.
 *
 * @package WPSB
 * @version 3.0.0
 */

/* ─── Widget Container ─── */
.wpsb-booking-widget {
    font-family: var(--wpsb-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);
    max-width: var(--wpsb-max-width, 800px);
    margin: 0 auto;
    padding: 20px;
    position: relative;
    color: #333;
}

/* ─── Step Indicator ─── */
.wpsb-step-indicator {
    margin-bottom: 30px;
    overflow-x: auto;
}

.wpsb-steps {
    display: flex;
    justify-content: space-between;
    gap: 4px;
    min-width: 500px;
}

.wpsb-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    opacity: 0.4;
    transition: opacity 0.3s;
}

.wpsb-step.wpsb-active,
.wpsb-step.wpsb-completed {
    opacity: 1;
}

.wpsb-step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
    transition: background 0.3s, color 0.3s;
}

.wpsb-step.wpsb-active .wpsb-step-number {
    background: var(--wpsb-primary, #007cba);
    color: #fff;
}

.wpsb-step.wpsb-completed .wpsb-step-number {
    background: var(--wpsb-success, #46b450);
    color: #fff;
}

.wpsb-step-label {
    font-size: 11px;
    text-align: center;
    color: #666;
}

.wpsb-step.wpsb-active .wpsb-step-label {
    color: var(--wpsb-primary, #007cba);
    font-weight: 600;
}

/* ─── Step Content ─── */
.wpsb-step-content h2 {
    font-size: 22px;
    margin-bottom: 8px;
    color: var(--wpsb-text, #1e3a5f);
}

.wpsb-step-subtitle {
    color: #666;
    margin-bottom: 20px;
    font-size: 14px;
}

/* ─── Category Groups ─── */
.wpsb-category-group {
    margin-bottom: 20px;
}

.wpsb-category-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--wpsb-primary, #007cba);
    margin: 0 0 10px 0;
    padding: 8px 0;
    border-bottom: 2px solid var(--wpsb-primary, #007cba);
    letter-spacing: 0.3px;
}

.wpsb-category-toggle {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.15s;
}

.wpsb-category-toggle:hover {
    opacity: 0.75;
}

.wpsb-cat-chevron {
    font-size: 10px;
    transition: transform 0.2s ease;
    display: inline-block;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}

.wpsb-cat-count {
    font-weight: 400;
    font-size: 13px;
    color: #888;
    margin-left: auto;
}

/* ─── Service Picker Grid ─── */
.wpsb-services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    max-height: 2000px;
    transition: max-height 0.3s ease, opacity 0.2s ease, margin 0.3s ease;
}

.wpsb-services-grid.wpsb-collapsed {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
    pointer-events: none;
}

.wpsb-service-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border: 2px solid #e0e0e0;
    border-radius: var(--wpsb-radius, 8px);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    background: #fff;
}

.wpsb-service-card.wpsb-service-pickable:hover {
    border-color: var(--wpsb-primary, #007cba);
    box-shadow: 0 2px 8px var(--wpsb-primary-light, rgba(0, 124, 186, 0.1));
}

.wpsb-service-info {
    flex: 1;
    min-width: 0;
}

.wpsb-service-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.wpsb-service-header h3 {
    font-size: 16px;
    margin: 0;
    color: var(--wpsb-text, #1e3a5f);
}

.wpsb-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    background: var(--wpsb-primary-light, #e8f0fe);
    color: var(--wpsb-primary, #007cba);
    font-weight: 500;
}

.wpsb-service-description {
    font-size: 13px;
    color: #666;
    margin: 4px 0 8px;
    line-height: 1.4;
}

.wpsb-service-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
}

.wpsb-service-duration {
    color: #666;
}

.wpsb-service-price {
    font-weight: 600;
    color: var(--wpsb-text, #1e3a5f);
}

.wpsb-service-add-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--wpsb-primary-light, rgba(0, 124, 186, 0.08));
    color: var(--wpsb-primary, #007cba);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.wpsb-service-pickable:hover .wpsb-service-add-icon {
    background: var(--wpsb-primary, #007cba);
    color: #fff;
}

/* ─── Back to Cart Button ─── */
.wpsb-back-to-cart {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--wpsb-primary, #007cba);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 0;
    margin-bottom: 16px;
    font-family: inherit;
    transition: opacity 0.2s;
}

.wpsb-back-to-cart:hover {
    opacity: 0.7;
}

/* ─── Service Cart (Selected Services) ─── */
.wpsb-cart {
    max-width: 560px;
}

.wpsb-cart-header {
    margin-bottom: 12px;
}

.wpsb-cart-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--wpsb-text, #1e3a5f);
}

.wpsb-cart-items {
    border: 1px solid #e0e0e0;
    border-radius: var(--wpsb-radius, 8px);
    overflow: hidden;
    margin-bottom: 16px;
}

.wpsb-cart-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}

.wpsb-cart-item:last-child {
    border-bottom: none;
}

.wpsb-cart-item:hover {
    background: #fafafa;
}

.wpsb-cart-item-info {
    flex: 1;
    min-width: 0;
}

.wpsb-cart-item-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--wpsb-text, #1e3a5f);
    margin-bottom: 4px;
}

.wpsb-cart-item-meta {
    font-size: 13px;
    color: #666;
}

.wpsb-cart-item-remove {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    color: #999;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
}

.wpsb-cart-item-remove:hover {
    color: #dc3232;
    background: rgba(220, 50, 50, 0.08);
}

/* ─── Add Service Button ─── */
.wpsb-add-service-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    border: 2px dashed #ccc;
    border-radius: var(--wpsb-radius, 8px);
    background: none;
    color: var(--wpsb-primary, #007cba);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 16px;
}

.wpsb-add-service-btn:hover {
    border-color: var(--wpsb-primary, #007cba);
    background: var(--wpsb-primary-light, rgba(0, 124, 186, 0.04));
}

/* ─── Cart Totals ─── */
.wpsb-cart-totals {
    background: #f8f9fa;
    border-radius: var(--wpsb-radius, 8px);
    padding: 16px 20px;
    border: 1px solid #e0e0e0;
}

.wpsb-cart-totals-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 14px;
    color: #555;
}

.wpsb-cart-totals-row strong {
    color: var(--wpsb-text, #1e3a5f);
    font-size: 15px;
}

/* ─── Providers Grid ─── */
.wpsb-providers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.wpsb-provider-card {
    padding: 20px;
    border: 2px solid #e0e0e0;
    border-radius: var(--wpsb-radius, 8px);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    text-align: center;
    background: #fff;
}

.wpsb-provider-card:hover {
    border-color: var(--wpsb-primary, #007cba);
}

.wpsb-provider-card.wpsb-selected {
    border-color: var(--wpsb-primary, #007cba);
    background: var(--wpsb-primary-light, rgba(0, 124, 186, 0.08));
}

.wpsb-provider-card h3 {
    font-size: 16px;
    margin: 0 0 8px;
    color: var(--wpsb-text, #1e3a5f);
}

.wpsb-provider-card p {
    font-size: 13px;
    color: #666;
    margin: 0;
}

/* ─── Calendar ─── */
.wpsb-calendar-wrapper {
    max-width: 400px;
    margin: 0 auto;
}

.wpsb-calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.wpsb-calendar-header h3 {
    font-size: 18px;
    margin: 0;
    color: var(--wpsb-text, #1e3a5f);
}

.wpsb-calendar-header button {
    background: none;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 16px;
    color: #333;
    transition: background 0.2s;
}

.wpsb-calendar-header button:hover {
    background: #f0f0f0;
}

.wpsb-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.wpsb-calendar-day-header {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    padding: 8px 0;
}

.wpsb-calendar-cell {
    text-align: center;
    padding: 10px 4px;
    border: none;
    border-radius: calc(var(--wpsb-radius, 8px) * 0.75);
    font-size: 14px;
    background: none;
    cursor: default;
    transition: background 0.2s;
}

.wpsb-calendar-cell.wpsb-available {
    cursor: pointer;
    color: #333;
}

.wpsb-calendar-cell.wpsb-available:hover {
    background: var(--wpsb-primary-light, #e8f0fe);
}

.wpsb-calendar-cell.wpsb-unavailable {
    color: #ccc;
}

.wpsb-calendar-cell.wpsb-today {
    font-weight: 700;
    color: var(--wpsb-primary, #007cba);
}

.wpsb-calendar-cell.wpsb-selected {
    background: var(--wpsb-primary, #007cba) !important;
    color: #fff !important;
    font-weight: 600;
}

.wpsb-calendar-cell.wpsb-empty {
    visibility: hidden;
}

/* ─── Time Slots ─── */
.wpsb-date-reminder {
    font-size: 0.95em;
    color: #555;
    margin: 0 0 16px;
    padding: 10px 14px;
    background: #f0f6ff;
    border-left: 3px solid var(--wpsb-primary, #2563eb);
    border-radius: 4px;
}

.wpsb-time-slots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}

.wpsb-time-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 12px;
    border: 2px solid #e0e0e0;
    border-radius: var(--wpsb-radius, 8px);
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.wpsb-time-slot:hover {
    border-color: var(--wpsb-primary, #007cba);
}

.wpsb-time-slot.wpsb-selected {
    border-color: var(--wpsb-primary, #007cba);
    background: var(--wpsb-primary, #007cba);
    color: #fff;
}

.wpsb-time {
    font-size: 16px;
    font-weight: 600;
}

.wpsb-remaining {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

.wpsb-selected .wpsb-remaining {
    color: rgba(255, 255, 255, 0.8);
}

.wpsb-no-slots,
.wpsb-no-results {
    text-align: center;
    color: #666;
    padding: 40px 20px;
    font-size: 14px;
}

/* ─── Customer Form ─── */
.wpsb-customer-form {
    max-width: 500px;
}

.wpsb-form-group {
    margin-bottom: 16px;
}

.wpsb-form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: #333;
}

.wpsb-form-group input,
.wpsb-form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ccc;
    border-radius: calc(var(--wpsb-radius, 8px) * 0.75);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.wpsb-form-group input:focus,
.wpsb-form-group textarea:focus {
    border-color: var(--wpsb-primary, #007cba);
    outline: none;
    box-shadow: 0 0 0 2px var(--wpsb-primary-lighter, rgba(0, 124, 186, 0.15));
}

/* ─── Summary Card ─── */
.wpsb-summary-card {
    background: #f9f9f9;
    border-radius: var(--wpsb-radius, 8px);
    padding: 24px;
    max-width: 500px;
}

.wpsb-summary-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.wpsb-summary-section h3 {
    font-size: 14px;
    color: #666;
    margin: 0 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wpsb-summary-service-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
}

.wpsb-summary-total {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #ccc;
    font-size: 15px;
    color: var(--wpsb-text, #1e3a5f);
}

.wpsb-summary-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
    border-bottom: 1px solid #eee;
}

.wpsb-summary-label {
    color: #666;
    font-weight: 500;
}

.wpsb-summary-value {
    color: #333;
    text-align: right;
}

/* ─── Pending Notice ─── */
.wpsb-pending-notice {
    margin-top: 20px;
    padding: 12px 16px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: calc(var(--wpsb-radius, 8px) * 0.75);
    font-size: 13px;
    color: #795548;
    line-height: 1.5;
}

/* ─── Success Screen ─── */
.wpsb-success-screen {
    text-align: center;
    padding: 40px 20px;
}

.wpsb-success-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    background: var(--wpsb-success, #46b450);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wpsb-success-icon svg {
    width: 32px;
    height: 32px;
    color: #fff;
}

.wpsb-success-screen h2 {
    color: var(--wpsb-success, #46b450);
    text-align: center;
}

.wpsb-success-message {
    color: #666;
    margin-top: 12px;
}

/* ─── Navigation ─── */
.wpsb-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.wpsb-btn {
    padding: 12px 28px;
    border: none;
    border-radius: calc(var(--wpsb-radius, 8px) * 0.75);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    font-family: inherit;
}

.wpsb-btn:active {
    transform: scale(0.98);
}

.wpsb-btn-primary {
    background: var(--wpsb-primary, #007cba);
    color: #fff;
    margin-left: auto;
}

.wpsb-btn-primary:hover {
    background: var(--wpsb-primary-hover, #005a87);
}

.wpsb-btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.wpsb-btn-secondary:hover {
    background: #e0e0e0;
}

/* ─── Loading ─── */
.wpsb-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: var(--wpsb-radius, 8px);
}

.wpsb-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: var(--wpsb-primary, #007cba);
    border-radius: 50%;
    animation: wpsb-spin 0.8s linear infinite;
}

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

/* ─── Toast Notifications ─── */
.wpsb-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    border-radius: var(--wpsb-radius, 8px);
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    max-width: 90%;
    text-align: center;
}

.wpsb-toast-error {
    background: #dc3232;
    color: #fff;
}

.wpsb-toast-visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ─── Responsive ─── */
@media (max-width: 600px) {
    .wpsb-services-grid {
        grid-template-columns: 1fr;
    }

    .wpsb-time-slots-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .wpsb-cart-item {
        padding: 12px 14px;
    }

    .wpsb-cart-totals {
        padding: 12px 14px;
    }

    .wpsb-summary-item {
        flex-direction: column;
        gap: 2px;
    }

    .wpsb-summary-value {
        text-align: left;
    }

    .wpsb-summary-service-item {
        flex-direction: column;
        gap: 2px;
    }
}
