.cbs-schedule-wrapper {
    max-width: 100%;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    position: relative;
    z-index: 10;
    background: white;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-radius: 8px;
    overflow: visible;
}

.cbs-schedule-wrapper.cbs-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.cbs-schedule-wrapper.cbs-loading::after {
    content: "Loading...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px 40px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    z-index: 1000;
    font-weight: 600;
    color: #333;
}

.cbs-schedule-header {
    margin-bottom: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    text-align: center;
}

.cbs-main-content {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.cbs-left-panel {
    flex: 0 0 320px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.cbs-right-panel {
    flex: 1;
    min-width: 0;
}

.cbs-button-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cbs-schedule-header h2 {
    margin: 0;
    color: #333;
    font-size: 24px;
}

.cbs-mini-calendar {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px;
    width: 100%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.cbs-calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 5px;
}

.cbs-cal-nav {
    background: none;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.cbs-cal-nav:hover {
    background: #f0f8ff;
    border-color: #0073aa;
}

.cbs-cal-month-year {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.cbs-calendar-grid {
    display: flex;
    flex-direction: column;
}

.cbs-cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 5px;
}

.cbs-cal-weekday {
    text-align: center;
    font-size: 11px;
    color: #666;
    font-weight: 600;
    padding: 4px 0;
}

.cbs-cal-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.cbs-cal-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    color: #333;
}

.cbs-cal-day:not(.cbs-cal-empty):not(.cbs-cal-past):hover {
    background: #f0f8ff;
    color: #0073aa;
}

.cbs-cal-day.cbs-cal-today {
    background: #e3f2fd;
    font-weight: 600;
    color: #0073aa;
}

.cbs-cal-day.cbs-cal-selected {
    background: #0073aa;
    color: white;
    font-weight: 600;
}

.cbs-cal-day.cbs-cal-past {
    color: #ccc;
    cursor: not-allowed;
}

.cbs-cal-day.cbs-cal-empty {
    cursor: default;
}

.cbs-date-selector {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
}

.cbs-nav-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 12px;
    color: #333;
    font-weight: 500;
    min-width: 80px;
    justify-content: center;
}

.cbs-nav-button:hover:not(:disabled) {
    background: #f0f8ff;
    border-color: #0073aa;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,115,170,0.15);
}

.cbs-nav-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #f5f5f5;
}

.cbs-nav-arrow {
    font-size: 14px;
    font-weight: bold;
}

.cbs-nav-text {
    font-size: 11px;
}

.cbs-current-date {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    background: #f8f9fa;
    border: 2px solid #0073aa;
    border-radius: 6px;
    min-width: 80px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 12px;
    font-weight: 500;
}

.cbs-current-date:hover {
    background: #e9ecef;
    box-shadow: 0 2px 8px rgba(0,115,170,0.15);
}

.cbs-date-display {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #333;
}

#cbs-date-picker {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    top: 0;
    left: 0;
}


.cbs-schedule-grid {
    overflow-x: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    position: relative;
    z-index: 5;
    margin-bottom: 15px;
}

.cbs-schedule-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.cbs-schedule-table thead {
    background: #f5f5f5;
}

.cbs-schedule-table th {
    padding: 6px 4px;
    text-align: center;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #e0e0e0;
    font-size: 12px;
}

.cbs-time-header {
    width: 55px;
    text-align: left !important;
    padding-left: 8px !important;
    font-size: 11px;
}

.cbs-court-header {
    min-width: 90px;
    white-space: nowrap;
}

.cbs-hour-row {
    border-bottom: 1px solid #f0f0f0;
}

.cbs-hour-row:hover {
    background: #fafafa;
}

.cbs-time-cell {
    padding: 6px 8px;
    font-weight: 500;
    font-size: 11px;
    color: #666;
    background: #f9f9f9;
    border-right: 1px solid #e0e0e0;
}

.cbs-slot-cell {
    padding: 4px 6px;
    text-align: center;
    border-right: 1px solid #f0f0f0;
    vertical-align: middle;
    min-width: 90px;
}

.cbs-slot-cell:last-child {
    border-right: none;
}

.cbs-available {
    background: #f0fdf4;
}

.cbs-booked {
    background: #fef2f2;
}

.cbs-book-slot {
    padding: 3px 6px;
    background: #f0fdf4;
    color: #22c55e;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s;
}

.cbs-book-slot:hover {
    background: #16a34a;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.cbs-available-text {
    color: #22c55e;
    font-size: 12px;
    font-weight: 500;
}

.cbs-booking-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cbs-booked-label {
    color: #dc2626;
    font-weight: 600;
    font-size: 13px;
}

.cbs-customer-name {
    color: #666;
    font-size: 9px;
}

.cbs-legend {
    display: flex;
    gap: 30px;
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    position: relative;
    z-index: 5;
}

.cbs-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cbs-legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.cbs-legend-color.cbs-available {
    background: #f0fdf4;
}

.cbs-legend-color.cbs-booked {
    background: #fef2f2;
}

.cbs-modal {
    display: none;
    position: fixed;
    z-index: 100000;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    animation: fadeIn 0.3s;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 0;
    -webkit-overflow-scrolling: touch;
    backdrop-filter: blur(5px);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.cbs-modal-content {
    background-color: white;
    margin: 20px auto;
    margin-bottom: 20px;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: slideIn 0.3s;
    max-height: none;
    min-height: auto;
    z-index: 100001;
    isolation: isolate;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.cbs-modal-close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.cbs-modal-close:hover {
    color: #000;
}

.cbs-modal-content h3 {
    margin-top: 0;
    color: #333;
    font-size: 24px;
    margin-bottom: 20px;
}

.cbs-modal-content p {
    color: #666;
    margin: 10px 0;
}

.cbs-form-group {
    margin-bottom: 15px;
}

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

.cbs-form-group input[type="text"],
.cbs-form-group input[type="email"],
.cbs-form-group input[type="tel"],
.cbs-form-group input[type="date"],
.cbs-form-group select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

.cbs-form-group input:focus,
.cbs-form-group select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0,115,170,0.1);
}

#cbs-booking-form button[type="submit"] {
    width: 100%;
    padding: 12px;
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

#cbs-booking-form button[type="submit"]:hover {
    background: #005a87;
}

.cbs-user-bookings-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.cbs-user-bookings-table thead {
    background: #f5f5f5;
}

.cbs-user-bookings-table th,
.cbs-user-bookings-table td {
    padding: 10px;
    text-align: left;
    border: 1px solid #ddd;
}

.cbs-user-bookings-table th {
    font-weight: 600;
    color: #555;
}

.cbs-user-bookings-table .button-small {
    padding: 4px 8px;
    font-size: 12px;
    margin: 0 2px;
}

.cbs-edit-user-booking {
    background: #0073aa;
    color: white;
    border-color: #0073aa;
}

.cbs-edit-user-booking:hover {
    background: #005a87;
    border-color: #005a87;
}

.cbs-cancel-user-booking {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.cbs-cancel-user-booking:hover {
    background: #c82333;
    border-color: #bd2130;
}

#cbs-edit-current-info {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    margin: 0;
    color: #495057;
    font-weight: 500;
}

#cbs-cancel-edit {
    margin-left: 10px;
    background: #6c757d;
    color: white;
    border-color: #6c757d;
}

#cbs-cancel-edit:hover {
    background: #5a6268;
    border-color: #545b62;
}

#cbs-manage-bookings {
    background: #6c757d;
    color: white;
    padding: 6px 10px;
    border: 2px solid #6c757d;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

#cbs-manage-bookings:hover {
    background: #5a6268;
    border-color: #5a6268;
}

#cbs-back-to-login {
    margin-top: 20px;
}

#cbs-recurring-options {
    padding: 12px;
    background: #f0f8ff;
    border: 1px solid #d1e7ff;
    border-radius: 6px;
    margin-top: 10px;
    margin-bottom: 15px;
}

#cbs-recurring-options small {
    color: #6c757d;
    font-size: 12px;
    display: block;
    margin-top: 5px;
}

#cbs-form-recurring {
    margin-right: 8px;
    width: auto;
    vertical-align: middle;
}

.cbs-form-group input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

.cbs-form-group input[type="checkbox"] + label {
    display: inline;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 0;
}

#cbs-booking-modal .cbs-modal-content {
    display: flex;
    flex-direction: column;
}

#cbs-booking-modal form {
    display: flex;
    flex-direction: column;
}

/* Divi Builder Compatibility */
.et_pb_section .cbs-schedule-wrapper,
.et_pb_row .cbs-schedule-wrapper,
.et_pb_column .cbs-schedule-wrapper,
.et_pb_module .cbs-schedule-wrapper {
    position: relative !important;
    z-index: 99 !important;
    overflow: visible !important;
    min-height: 600px;
    margin-bottom: 40px !important;
}

.et_pb_section,
.et_pb_row {
    overflow: visible !important;
}

/* Fix for Divi overlapping elements */
.cbs-schedule-wrapper + .et_pb_section,
.cbs-schedule-wrapper + .et_pb_row,
.cbs-schedule-wrapper + .et_pb_module {
    position: relative;
    z-index: 1;
    clear: both;
}

@media (max-width: 992px) {
    .cbs-main-content {
        flex-direction: column;
    }
    
    .cbs-left-panel {
        flex: 1 1 auto;
        width: 100%;
        max-width: 400px;
        margin: 0 auto;
    }
    
    .cbs-right-panel {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .cbs-schedule-header {
        text-align: center;
    }
    
    .cbs-left-panel {
        max-width: 100%;
    }
    
    .cbs-mini-calendar {
        width: 100%;
    }
    
    .cbs-date-selector {
        width: 100%;
        justify-content: center;
        flex-direction: column;
        gap: 15px;
    }
    
    .cbs-nav-button {
        width: 100%;
        max-width: 300px;
    }
    
    .cbs-current-date {
        width: 100%;
        max-width: 300px;
        order: -1;
    }
    
    #cbs-manage-bookings {
        width: 100%;
        max-width: 300px;
        order: 3;
    }
    
    .cbs-modal-content {
        width: 95%;
        margin: 10px auto;
        margin-bottom: 20px;
        padding: 20px;
    }
    
    .cbs-modal {
        padding: 10px 0;
    }
    
    .cbs-legend {
        flex-direction: column;
        gap: 10px;
    }
    
    .cbs-schedule-wrapper {
        padding: 15px;
    }
}

.cbs-recurring-badge {
    display: inline-block;
    font-size: 14px;
    margin-left: 5px;
    color: #3b82f6;
    cursor: help;
}

.cbs-cancel-recurring {
    background: #dc2626 !important;
    color: white !important;
    border-color: #dc2626 !important;
    margin-left: 5px;
}

.cbs-cancel-recurring:hover {
    background: #b91c1c !important;
    border-color: #b91c1c !important;
}

/* Date Picker Container */
.cbs-date-picker-container {
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 280px;
}

.cbs-date-picker-input {
    width: 100%;
    padding: 10px 40px 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.cbs-date-picker-input:hover {
    border-color: #999;
}

.cbs-date-picker-input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
}

.cbs-date-picker-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 18px;
}

.cbs-form-help {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 12px;
}

/* Calendar Popup Styles */
.cbs-calendar-popup {
    position: absolute;
    z-index: 9999;
    background: white;
    border: 1px solid #c3c4c7;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.1);
    padding: 12px;
    width: 260px;
    left: 0;
    height: auto;
}

/* Position below input (default) */
.cbs-calendar-popup.popup-below {
    top: 100%;
    margin-top: 4px;
}

/* Position above input when not enough space below */
.cbs-calendar-popup.popup-above {
    bottom: 100%;
    margin-bottom: 4px;
}


.cbs-calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e7eb;
}

.cbs-cal-prev, .cbs-cal-next {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: all 0.2s;
    user-select: none;
    -moz-user-select: none;
    -webkit-user-select: none;
    color: #666;
}

.cbs-cal-prev:hover, .cbs-cal-next:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #333;
}

.cbs-cal-month-year {
    font-weight: 600;
    font-size: 14px;
    color: #1f2937;
}

.cbs-calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: minmax(32px, auto); /* Auto height for each row */
    gap: 1px;
    padding-bottom: 5px;
}

.cbs-cal-day-header {
    text-align: center;
    font-weight: 500;
    font-size: 11px;
    color: #9ca3af;
    padding: 6px 0;
    text-transform: uppercase;
}

.cbs-cal-day {
    text-align: center;
    padding: 7px 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    user-select: none;
    -moz-user-select: none;
    -webkit-user-select: none;
    border: 1px solid transparent;
    color: #374151;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cbs-cal-day:hover {
    background: #0073aa;
    color: white;
    transform: scale(1.05);
}

.cbs-cal-day.disabled {
    color: #ccc;
    cursor: not-allowed;
    background: #f9f9f9;
}

.cbs-cal-day.disabled:hover {
    background: #f9f9f9;
    color: #ccc;
}

.cbs-cal-day-empty {
    min-height: 32px;
}

/* Mobile responsive adjustments for calendar */
@media (max-width: 480px) {
    .cbs-calendar-popup {
        width: 220px;
        padding: 8px;
    }
    
    .cbs-cal-day {
        padding: 5px 1px;
        font-size: 11px;
    }
    
    .cbs-cal-month-year {
        font-size: 13px;
    }
    
    .cbs-cal-prev, .cbs-cal-next {
        padding: 2px 6px;
        font-size: 16px;
    }
}