/* Frontend CSS for WP Calendar Booking */

.wcb-booking-widget {
    max-width: 900px;
    margin: 20px auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.wcb-booking-widget * {
    box-sizing: border-box;
}

.wcb-widget-header {
    background: linear-gradient(135deg, var(--wcb-primary-color) 0%, var(--wcb-secondary-color) 100%);
    color: white;
    padding: 30px;
    text-align: center;
    border-radius: 12px 12px 0 0;
}

.wcb-widget-content {
    background: white;
    border-radius: 0 0 12px 12px;
    border: 1px solid var(--wcb-widget-border-color, #e0e0e0);
    border-top: none;
    overflow: hidden;
    position: relative;
}

.wcb-calendar-wrapper {
    display: grid;
    grid-template-columns: 1fr min(300px, 35%);
    gap: clamp(15px, 3vw, 30px);
    max-width: 100%;
    overflow: hidden;
}

.wcb-calendar {
    background: var(--wcb-background-color);
    border-radius: 12px;
    padding: 20px;
    min-width: 0;
    overflow: hidden;
}

.wcb-time-slots {
    background: var(--wcb-background-color);
    border-radius: 12px;
    padding: 20px;
    border: 2px solid var(--wcb-border-color);
    min-width: 0; /* Allow grid items to shrink below their content size */
    overflow: hidden; /* Prevent content from spilling out */
    box-sizing: border-box;
    max-width: 100%;
}

#wcb-calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
}

.wcb-calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    min-height: 40px;
}

.wcb-calendar-day-available {
    background: var(--wcb-available-day-color);
    color: #2d5a2d;
    font-weight: 500;
}

.wcb-calendar-day-available:hover {
    background: #d4edda;
    transform: scale(1.05);
}

.wcb-calendar-day-selected {
    background: var(--wcb-selected-color) !important;
    color: var(--wcb-selected-text-color) !important;
    transform: scale(1.1) !important;
}

.wcb-time-slot {
    display: block;
    width: 100%;
    background: white;
    border: 2px solid var(--wcb-border-color);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--wcb-accent-color);
    text-align: center;
    transition: all 0.2s ease;
}

/* Time slot buttons should never cause overflow */
.wcb-time-slot {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    word-wrap: break-word !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.wcb-time-slot:hover {
    border-color: var(--wcb-primary-color);
    background: #f0f2ff;
    transform: translateY(-1px);
}

.wcb-time-slot.selected {
    background: var(--wcb-selected-color) !important;
    color: var(--wcb-selected-text-color) !important;
    border-color: var(--wcb-selected-color) !important;
}

.wcb-step {
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.6;
    transition: opacity 0.3s ease;
    color: var(--wcb-step-text-color, #ffffff);
}

.wcb-step.active {
    opacity: 1;
    color: var(--wcb-step-text-active-color, #ffffff);
}

.wcb-step-number {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--wcb-step-text-color, #ffffff);
    transition: all 0.3s ease;
}

.wcb-step.active .wcb-step-number {
    background: white;
    color: var(--wcb-primary-color);
}

.wcb-form-group {
    margin-bottom: 20px;
}

.wcb-form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--wcb-text-color);
}

.wcb-form-input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--wcb-border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.wcb-form-input:focus {
    outline: none;
    border-color: var(--wcb-primary-color);
}

.wcb-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wcb-btn-primary {
    background: var(--wcb-primary-color);
    color: white;
}

.wcb-btn-primary:hover {
    background: var(--wcb-accent-color);
    transform: translateY(-1px);
}

.wcb-btn-secondary {
    background: #f1f3f4;
    color: #333;
}

.wcb-btn-secondary:hover {
    background: #e1e3e4;
}

.wcb-btn-success {
    background: var(--wcb-success-color);
    color: white;
}

.wcb-btn-success:hover {
    background: #218838;
    transform: translateY(-1px);
}

.wcb-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.wcb-message {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.wcb-message-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.wcb-message-error {
    background: #f8d7da;
    border: 1px solid #f1b0b7;
    color: #721c24;
}

/* Base responsive layout */
.wcb-calendar-wrapper {
    display: grid;
    grid-template-columns: 1fr min(300px, 35%);
    gap: clamp(15px, 3vw, 30px);
}

/* Large screens - maintain side-by-side layout with more space */
@media (min-width: 1200px) {
    .wcb-calendar-wrapper {
        grid-template-columns: 1fr 320px;
        gap: 40px;
    }
}

/* Medium-large screens - reduce time slots width */
@media (max-width: 1199px) and (min-width: 901px) {
    .wcb-calendar-wrapper {
        grid-template-columns: 1fr min(280px, 35%);
        gap: 25px;
    }
}

/* Medium screens - stack when too cramped */
@media (max-width: 900px) and (min-width: 769px) {
    .wcb-calendar-wrapper {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    .wcb-time-slots {
        width: 100% !important;
        max-width: 450px !important;
        margin: 0 auto !important;
    }
}

@media (max-width: 768px) {
    .wcb-calendar-wrapper {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    .wcb-step-panel {
        padding: 15px !important;
    }
    
    .wcb-steps {
        gap: 10px !important;
    }
    
    .wcb-steps span:last-child {
        display: none !important;
    }
    
    .wcb-widget-header h2 {
        font-size: 22px !important;
    }
    
    .wcb-time-slots {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
    }
}

/* Remove the duplicate medium screen rules that were added earlier */

@media (max-width: 480px) {
    .wcb-booking-widget {
        margin: 10px !important;
        max-width: none !important;
    }
    
    .wcb-widget-header {
        padding: 20px !important;
    }
    
    .wcb-step-panel {
        padding: 10px !important;
    }
    
    #wcb-calendar-days > div {
        font-size: 12px !important;
        min-height: 35px !important;
    }
}

/* Prevent overlap by enforcing container bounds */
.wcb-step-panel {
    overflow: hidden;
    position: relative;
}

/* Force proper sizing on all screen sizes */
@media (max-width: 1000px) {
    .wcb-calendar-wrapper {
        grid-template-columns: 1fr min(280px, 40%) !important;
        gap: 15px !important;
    }
}

@media (max-width: 850px) {
    .wcb-calendar-wrapper {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    .wcb-time-slots {
        width: 100% !important;
        max-width: 400px !important;
        margin: 0 auto !important;
        position: relative !important;
        z-index: 1 !important;
    }
}

/* Force stacking when JavaScript detects overflow */
.wcb-calendar-wrapper.wcb-force-stack {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
}

.wcb-calendar-wrapper.wcb-force-stack .wcb-time-slots {
    width: 100% !important;
    max-width: 450px !important;
    margin: 0 auto !important;
}

/* Smooth transitions for layout changes */
.wcb-calendar-wrapper {
    transition: grid-template-columns 0.3s ease;
}

.wcb-time-slots {
    transition: width 0.3s ease, max-width 0.3s ease;
}

/* Ensure time slot buttons don't cause overflow */
.wcb-time-slots button {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
}
