/**
 * BnB Booking Plugin - Frontend Styles
 */

:root {
    --bnb-primary: #8B8077;
    --bnb-primary-dark: #6B5F56;
    --bnb-primary-light: #A39087;
    --bnb-secondary: #CBC0AF;
    --bnb-text: #5B443E;
    --bnb-accent: #E9DED4;
    --bnb-bg-accent: #F6F1EB;
    --bnb-icon: #808080;
    --bnb-success: #2E5233;
    --bnb-success-bg: #E8F0E8;
    --bnb-warning: #8B6914;
    --bnb-warning-bg: #FFF8E1;
    --bnb-error: #7D2D2D;
    --bnb-error-bg: #F8E8E8;
}

.bnb-booking-widget,
.bnb-booking-shortcode {
    max-width: 600px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.bnb-booking-form {
    background: #ffffff;
    padding: 20px;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.bnb-booking-title {
    color: #333;
    margin-bottom: 15px;
    font-size: 24px;
    font-weight: 600;
}

.bnb-booking-description {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.5;
}

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

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

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.4;
    background-color: #fff;
    box-sizing: border-box;
    transition: border-color 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--bnb-primary);
    box-shadow: 0 0 0 2px rgba(139, 128, 119, 0.15);
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
}

.form-row .form-group {
    padding: 0 10px;
    box-sizing: border-box;
}

.col-md-6 {
    flex: 0 0 50%;
    max-width: 50%;
}

@media (max-width: 768px) {
    .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    .form-row {
        margin: 0;
    }
    
    .form-row .form-group {
        padding: 0;
    }
}

/* Single guest selector styling */
.form-group select[name="adults"] {
    max-width: 200px;
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    margin-bottom: 0;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.btn-primary {
    color: #fff;
    background-color: var(--bnb-primary);
    border-color: var(--bnb-primary);
}

.btn-primary:hover {
    background-color: var(--bnb-primary-dark);
    border-color: var(--bnb-primary-dark);
}

.btn-primary:disabled {
    background-color: #ccc;
    border-color: #ccc;
    cursor: not-allowed;
}

.btn-block {
    display: block;
    width: 100%;
}

.booking-summary {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 20px;
}

.booking-summary h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.booking-summary p {
    margin: 5px 0;
    color: #666;
}

#booking-messages {
    margin-top: 15px;
}

.alert {
    padding: 12px 16px;
    margin-bottom: 15px;
    border: 1px solid transparent;
    border-radius: 4px;
}

.alert-success {
    color: var(--bnb-success);
    background-color: var(--bnb-success-bg);
    border-color: var(--bnb-secondary);
}

.alert-error,
.alert-danger {
    color: var(--bnb-error);
    background-color: var(--bnb-error-bg);
    border-color: #D2A5A5;
}

.alert-info {
    color: var(--bnb-text);
    background-color: var(--bnb-bg-accent);
    border-color: var(--bnb-secondary);
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--bnb-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Loading state */
.bnb-booking-form.loading .form-control {
    opacity: 0.6;
}

.bnb-booking-form.loading .btn {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Booking Header */
.booking-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, var(--bnb-bg-accent), var(--bnb-accent));
    border-radius: 8px;
}

.booking-header h3 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 24px;
    font-weight: 600;
}

.check-times {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.check-time {
    color: #666;
    font-weight: 500;
    font-size: 14px;
}

/* Availability Calendar */
.availability-calendar-container {
    margin: 30px 0;
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 20px;
}

.availability-calendar-container h4 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
}

#availability-calendar {
    max-width: 100%;
    margin: 0 auto;
    position: relative;
}

#availability-calendar.loading-data {
    opacity: 0.7;
}

#availability-calendar.loading-data::after {
    content: 'Loading...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 14px;
    color: #666;
    border: 1px solid #ddd;
    z-index: 10;
}

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

.month-year {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.nav-btn {
    background: var(--bnb-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
}

.nav-btn:hover {
    background: var(--bnb-primary-dark);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: #ddd;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}

.day-header {
    background: #f8f9fa;
    padding: 10px 5px;
    text-align: center;
    font-weight: 600;
    color: #333;
    font-size: 12px;
    border-right: 1px solid #ddd;
}

.day-header:last-child {
    border-right: none;
}

.calendar-day {
    background: #fff;
    min-height: 60px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    border-right: 1px solid #ddd;
    padding: 0;
}

.calendar-day:last-child {
    border-right: none;
}

.day-cell {
    position: relative;
    height: 100%;
    width: 100%;
    display: flex;
}

.day-cell .half {
    height: 100%;
    width: 50%;
    background: #fff;
    transition: background-color 0.2s;
    box-sizing: border-box;
}

.day-cell .half.red {
    background: #f8d7da !important;
}

.day-cell.full-red .half {
    background: #f8d7da !important;
    border-color: transparent !important; /* seamless full cell */
}

.day-cell .half.available {
    background: #fff;
}

.date-num {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #333;
    background: rgba(255, 255, 255, 0.8);
    padding: 2px 4px;
    border-radius: 2px;
    z-index: 2;
    pointer-events: none;
}

.day-number {
    font-size: 14px;
    font-weight: 500;
}

.calendar-day.other-month {
    color: #ccc;
    background: #f8f9fa;
}

.calendar-day.other-month .day-cell .half {
    background: #f8f9fa !important;
}

.calendar-day.past-date {
    background: #f1f1f1;
    color: #999;
    cursor: not-allowed;
}

.calendar-day.past-date .day-cell .half {
    background: #f1f1f1 !important;
}

.calendar-day.past-date .date-num {
    color: #999;
}

.calendar-day.available {
    /* Background removed - now handled by individual halves */
    color: #333;
    border: 1px solid #e1e5e9;
}

.calendar-day.available:hover {
    /* Background removed - now handled by individual halves */
    transform: scale(1.05);
}

.calendar-day.booked {
    /* Background removed - now handled by individual halves */
    color: #721c24;
    cursor: not-allowed;
}

.calendar-day.partially-booked {
    /* Background removed - now handled by individual halves */
    color: #856404;
}

.calendar-day.partially-booked:hover {
    /* Background removed - now handled by individual halves */
}

.calendar-day.selected .day-cell .half {
    background: var(--bnb-primary) !important;
}

.calendar-day.selected .date-num {
    color: white !important;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.2);
}

.calendar-day.selected.check-in:not(.split-availability)::after {
    content: 'IN';
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 8px;
    background: rgba(255,255,255,0.3);
    padding: 1px 3px;
    border-radius: 2px;
}

.calendar-day.selected.check-out:not(.split-availability)::after {
    content: 'OUT';
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 8px;
    background: rgba(255,255,255,0.3);
    padding: 1px 3px;
    border-radius: 2px;
}

.calendar-day.selected.in-range .day-cell .half {
    background: rgba(139, 128, 119, 0.3) !important;
}

.calendar-day.selected.in-range .date-num {
    color: #333 !important;
}

/* Half-and-half vertical display for check-in/check-out availability */
.calendar-day.split-availability {
    position: relative;
    border: 1px solid #e1e5e9 !important; /* Subtle border */
    color: #333 !important;
    font-weight: 600 !important; /* Make text more visible */
}

/* OLD CSS REMOVED - Now using individual .half elements instead of gradients */

/* Hover effects for split availability */
.calendar-day.split-availability:hover {
    transform: scale(1.05);
    opacity: 0.8;
}

/* Cursor states for split availability */
.calendar-day.unavailable {
    cursor: not-allowed !important;
}

.calendar-day.checkin-only,
.calendar-day.checkout-only,
.calendar-day.fully_available {
    cursor: pointer;
}

/* Enhanced visual cues for half-day availability */
.calendar-day.clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.calendar-day.clickable:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(139, 128, 119, 0.2);
}

.calendar-day.checkin-only:hover {
    border-color: #28a745 !important;
}

.calendar-day.checkout-only:hover {
    border-color: #ffc107 !important;
}

.calendar-day.fully_available:hover {
    border-color: var(--bnb-primary) !important;
}

.calendar-day.unavailable:hover {
    transform: none;
    box-shadow: none;
}

/* Calendar Legend */
.calendar-legend {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e1e5e9;
}

.calendar-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #333;
}

.calendar-legend .legend-demo {
    display: flex;
    width: 32px;
    height: 20px;
    border: 1px solid #ddd;
}

.calendar-legend .legend-half {
    width: 50%;
    height: 100%;
    border: none;
}

.calendar-legend .legend-half.available {
    background: #fff;
}

.calendar-legend .legend-half.red {
    background: #f8d7da;
}

.calendar-legend .legend-description {
    text-align: center;
    margin-top: 5px;
}

.calendar-legend .legend-description small {
    color: #666;
    font-size: 12px;
    font-style: italic;
}

/* Selected Booking Range Styles */
.calendar-day.selected-checkin .day-cell .half.right {
    background: var(--bnb-primary) !important; /* Check-in: right half (evening arrival) */
}

.calendar-day.selected-checkout .day-cell .half.left {
    background: var(--bnb-primary) !important; /* Check-out: left half (morning departure) */
}

.calendar-day.selected-middle .day-cell .half {
    background: var(--bnb-primary) !important; /* Middle nights: full square */
}

/* Labels for selected dates */
.calendar-day.selected-checkin::after {
    content: 'IN';
    position: absolute;
    bottom: 2px;
    left: 52%;  /* Position inside right half, on left edge of blue area */
    font-size: 8px;
    color: white;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.3);
    padding: 1px 3px;
    border-radius: 2px;
    z-index: 3;
}

.calendar-day.selected-checkout::after {
    content: 'OUT';
    position: absolute;
    bottom: 2px;
    right: 52%;  /* Position inside left half, on right edge of blue area */
    font-size: 8px;
    color: white;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.3);
    padding: 1px 3px;
    border-radius: 2px;
    z-index: 3;
}

/* Make date numbers white on selected dates */
.calendar-day.selected-checkin .date-num,
.calendar-day.selected-checkout .date-num,
.calendar-day.selected-middle .date-num {
    color: white !important;
    background: rgba(0, 0, 0, 0.2);
    font-weight: bold;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid #ddd;
}

.legend-color.available {
    background: white;
    border: 1px solid #ddd;
}

.legend-color.booked {
    background: #f8d7da;
}

.legend-color.selected {
    background: var(--bnb-primary);
}

.legend-color.checkin-only {
    background: linear-gradient(to right, white 50%, #f8d7da 50%);
    border: 1px solid #ddd;
}

.legend-color.checkout-only {
    background: linear-gradient(to right, #f8d7da 50%, white 50%);
    border: 1px solid #ddd;
}

.legend-color.both-available {
    background: white;
    border: 1px solid #ddd;
}

.legend-color.neither-available {
    background: #f8d7da;
}

/* Selected Dates Display */
.selected-dates {
    background: var(--bnb-bg-accent);
    border: 1px solid var(--bnb-secondary);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.selected-dates h4 {
    margin: 0 0 15px 0;
    color: var(--bnb-text);
    font-size: 16px;
    text-align: center;
}

.date-range {
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.date-item {
    text-align: center;
    flex: 1;
    min-width: 120px;
}

.date-item strong {
    display: block;
    color: var(--bnb-text);
    margin-bottom: 5px;
    font-size: 14px;
}

.date-item span {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
}

.date-item small {
    color: #666;
    font-size: 12px;
}

.date-item.nights strong {
    font-size: 18px;
    color: var(--bnb-primary);
}

/* Suite Selection Tabs */
.suite-selection-container {
    margin: 20px 0;
}

.suite-selection-container h4 {
    margin-bottom: 15px;
    color: #333;
    text-align: center;
}

.suite-tabs {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.suite-tab {
    flex: 1;
    max-width: 300px;
    min-width: 250px;
    padding: 20px;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.suite-tab:hover {
    border-color: var(--bnb-primary);
    box-shadow: 0 4px 12px rgba(139, 128, 119, 0.15);
    transform: translateY(-2px);
}

.suite-tab.active {
    border-color: var(--bnb-primary);
    background: var(--bnb-bg-accent);
    box-shadow: 0 4px 15px rgba(139, 128, 119, 0.2);
}

.suite-tab.active::before {
    content: '✓';
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--bnb-primary);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
}

.suite-tab-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.suite-tab-header h5 {
    margin: 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.suite-price {
    color: var(--bnb-primary);
    font-weight: 600;
    font-size: 16px;
    white-space: nowrap;
}

.suite-description {
    color: #666;
    font-size: 14px;
    line-height: 1.4;
    margin: 8px 0;
}

.suite-capacity {
    color: #888;
    font-size: 12px;
}

.selected-suite-info {
    text-align: center;
    margin-bottom: 15px;
    padding: 10px;
}

/* Invalid Click Visual Feedback */
.calendar-day.invalid-click {
    animation: invalidClickPulse 0.6s ease-out;
    transform: scale(1.05);
}

@keyframes invalidClickPulse {
    0% {
        background-color: #ff4444;
        transform: scale(1);
    }
    50% {
        background-color: #ff6666;
        transform: scale(1.08);
    }
    100% {
        background-color: transparent;
        transform: scale(1.05);
    }
}

/* Improved Error Messages */
.alert-error,
.alert-danger {
    color: var(--bnb-error);
    background-color: var(--bnb-error-bg);
    border-color: #D2A5A5;
    border-left: 4px solid var(--bnb-error);
    font-weight: 500;
}

/* Helpful Suggestions in Error Messages */
.alert-error strong {
    color: var(--bnb-error);
}

/* Checkout Date Highlighting */
.calendar-day.valid-checkout {
    background: linear-gradient(135deg, #e8f5e8 0%, #d4f4d4 100%);
    border: 2px solid #28a745;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.2);
    transform: scale(1.02);
    transition: all 0.2s ease;
}

.calendar-day.valid-checkout:hover {
    background: linear-gradient(135deg, #d4f4d4 0%, #c3f0c3 100%);
    border-color: #218838;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

/* Clean color coding - no icons needed */

.calendar-day.blocked-checkout {
    background: linear-gradient(135deg, #ffe6e6 0%, #ffcccc 100%);
    border: 1px solid #dc3545;
    border-radius: 4px;
    opacity: 0.6;
    cursor: not-allowed;
    position: relative;
}

/* Clean color coding for blocked dates too */

/* Make valid checkout dates more prominent */
.calendar-day.valid-checkout .date-num {
    color: #155724 !important;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 4px;
    padding: 2px 4px;
}

/* Pulse animation for valid checkout dates */
.calendar-day.valid-checkout {
    animation: validCheckoutPulse 2s ease-in-out infinite;
}

@keyframes validCheckoutPulse {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(40, 167, 69, 0.2);
    }
    50% {
        box-shadow: 0 4px 16px rgba(40, 167, 69, 0.4);
    }
}

.selected-suite-info {
    text-align: center;
    margin-bottom: 15px;
    padding: 10px;
    background: var(--bnb-bg-accent);
    border-radius: 6px;
    border: 1px solid var(--bnb-secondary);
}

.selected-suite-info p {
    margin: 0;
    color: var(--bnb-text);
}

/* Single guest selector styling */
.form-group select[name="adults"] {
    max-width: 200px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .check-times {
        gap: 15px;
    }
    
    .availability-calendar-container {
        padding: 15px;
    }
    
    .calendar-header {
        padding: 0 5px;
    }
    
    .month-year {
        font-size: 16px;
    }
    
    .nav-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
    
    .calendar-day {
        min-height: 40px;
    }
    
    .day-number {
        font-size: 13px;
    }
    
    .calendar-legend {
        gap: 10px;
        justify-content: space-around;
    }
    
    .legend-item {
        font-size: 11px;
    }
    
    .date-range {
        flex-direction: column;
        gap: 10px;
    }
    
    .date-item {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .bnb-booking-form {
        padding: 15px;
        margin: 10px;
    }
    
    .bnb-booking-title {
        font-size: 20px;
    }
    
    .form-control {
        padding: 8px 10px;
    }
    
    .btn {
        padding: 10px 20px;
    }
    
    .booking-header h3 {
        font-size: 20px;
    }
    
    .check-times {
        flex-direction: column;
        gap: 10px;
    }
    
    .availability-calendar-container {
        padding: 10px;
    }
    
    .calendar-day {
        min-height: 35px;
    }
    
    .day-number {
        font-size: 12px;
    }
    
    .calendar-legend {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
}
