/* Floating Chat Widget Styles */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.chat-container {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 400px;
    height: 600px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    z-index: 1001;
}

.chat-container.open {
    display: flex;
}

.chat-header {
    background: var(--primary, #4a6cf7);
    color: white;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.status {
    font-size: 0.8rem;
    opacity: 0.8;
}

.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f9f9f9;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    margin-bottom: 12px;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.message.user {
    background: var(--primary, #4a6cf7);
    color: white;
    margin-left: auto;
    text-align: right;
}

.message.bot {
    background: #e9ecef;
    color: #333;
    margin-right: auto;
}

.options-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px;
    background: white;
    border-top: 1px solid #eee;
}

.option-card {
    flex: 1;
    min-width: 120px;
    padding: 16px;
    border: 1px solid #ddd;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.option-card:hover {
    border-color: var(--primary, #4a6cf7);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.option-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.option-icon {
    font-size: 1.5rem;
    color: var(--primary, #4a6cf7);
}

.option-title {
    font-weight: bold;
    font-size: 0.95rem;
    margin: 0;
}

.option-description {
    font-size: 0.8rem;
    color: #666;
    margin: 0;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 16px;
}

.service-option {
    padding: 16px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    font-size: 0.85rem;
}

.service-option:hover {
    border-color: var(--primary, #4a6cf7);
    background-color: #f0f7ff;
}

.time-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px;
}

.time-slot {
    padding: 10px 16px;
    border: 1px solid #ddd;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    min-width: calc(25% - 10px);
    text-align: center;
    font-size: 0.85rem;
}

.time-slot:hover {
    border-color: var(--primary, #4a6cf7);
    background-color: #f0f7ff;
}

.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 16px 8px;
    background: white;
}

.quick-reply {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.quick-reply:hover {
    border-color: var(--primary, #4a6cf7);
    background-color: #f0f7ff;
}

.calendar {
    padding: 16px;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.calendar-date {
    padding: 8px 4px;
    text-align: center;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.calendar-date:hover {
    background-color: #f0f7ff;
}

.calendar-date.selected {
    background-color: var(--primary, #4a6cf7);
    color: white;
}

.week-view {
    display: flex;
    gap: 12px;
    padding: 16px;
}

.week-day {
    flex: 1;
    padding: 16px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.week-day:hover {
    border-color: var(--primary, #4a6cf7);
    background-color: #f0f7ff;
}

.booking-summary {
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-top: 10px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.summary-item strong {
    color: var(--primary, #4a6cf7);
}

.confirmation-message {
    padding: 16px;
    text-align: center;
    color: #28a745;
    font-size: 0.9rem;
}

.chat-input {
    padding: 16px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
}

.chat-input input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    outline: none;
    font-size: 0.9rem;
}

.chat-input button {
    margin-left: 10px;
    width: 45px;
    height: 45px;
    border: none;
    border-radius: 50%;
    background: var(--primary, #4a6cf7);
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
}

.chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary, #4a6cf7);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s;
    z-index: 1000;
}

.chat-toggle:hover {
    transform: scale(1.05);
}

/* Mobile View Fixes for Floating Widget */
@media (max-width: 768px) {
    .chat-widget {
        bottom: 15px;
        right: 15px;
        left: 15px;
        width: auto;
    }
    
    .chat-toggle {
        width: 55px;
        height: 55px;
        font-size: 1.3rem;
        margin-left: auto; /* Push to right side */
    }
    
    .chat-container {
        width: 100%;
        height: 70vh;
        max-height: 500px;
        bottom: 70px;
        right: 0;
        left: 0;
        border-radius: 15px 15px 0 0;
    }
    
    .chat-messages {
        height: calc(100% - 120px);
        padding: 12px;
    }
    
    .message {
        max-width: 90%;
        font-size: 0.85rem;
        padding: 10px 12px;
    }
    
    .options-container {
        gap: 8px;
    }
    
    .option-card {
        padding: 12px;
    }
    
    .option-header {
        gap: 8px;
    }
    
    .option-icon {
        font-size: 1.3rem;
    }
    
    .option-title {
        font-size: 0.9rem;
    }
    
    .option-description {
        font-size: 0.8rem;
    }
    
    .services-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .service-option {
        padding: 12px 8px;
        font-size: 0.8rem;
    }
    
    .time-slots {
        gap: 6px;
    }
    
    .time-slot {
        padding: 8px 10px;
        font-size: 0.75rem;
        flex: 1;
        min-width: calc(33% - 6px);
        text-align: center;
    }
    
    .quick-replies {
        gap: 6px;
        padding: 12px 12px 6px;
    }
    
    .quick-reply {
        padding: 6px 10px;
        font-size: 0.75rem;
        margin-bottom: 6px;
    }
    
    .calendar {
        padding: 10px;
    }
    
    .calendar-date {
        padding: 6px 3px;
        font-size: 0.75rem;
    }
    
    .week-view {
        flex-direction: column;
        gap: 8px;
    }
    
    .week-day {
        padding: 12px 8px;
        font-size: 0.8rem;
    }
    
    .booking-summary {
        padding: 12px;
    }
    
    .summary-item {
        font-size: 0.8rem;
        margin-bottom: 5px;
    }
    
    .confirmation-message {
        padding: 12px;
        font-size: 0.8rem;
    }
    
    .chat-input {
        padding: 12px;
    }
    
    .chat-input input {
        padding: 10px 12px;
        font-size: 0.85rem;
    }
    
    .chat-input button {
        width: 38px;
        height: 38px;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .chat-widget {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
    
    .chat-toggle {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    .chat-container {
        height: 75vh;
        bottom: 65px;
    }
    
    .chat-header {
        padding: 12px;
    }
    
    .chat-header h3 {
        font-size: 1rem;
    }
    
    .status {
        font-size: 0.65rem;
    }
    
    .calendar-grid {
        gap: 3px;
    }
    
    .calendar-date {
        padding: 5px 2px;
        font-size: 0.7rem;
    }
    
    .time-slot {
        min-width: calc(50% - 3px);
    }
}

/* Fix for very tall screens */
@media (max-height: 700px) and (max-width: 768px) {
    .chat-container {
        height: 80vh;
        max-height: none;
    }
}

/* Landscape mode fixes */
@media (max-width: 768px) and (orientation: landscape) {
    .chat-container {
        height: 85vh;
        max-height: none;
    }
    
    .chat-messages {
        height: calc(100% - 100px);
    }
    
    .services-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .week-view {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .week-day {
        flex: 0 0 calc(50% - 5px);
    }
}

/* Prevent body scrolling when widget is open on mobile */
.chat-container[style*="display: flex"] ~ body {
    overflow: hidden;
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
    .chat-toggle:hover {
        transform: none;
    }
    
    .option-card:hover {
        transform: none;
    }
    
    .service-option:hover,
    .time-slot:hover,
    .quick-reply:hover {
        background-color: initial;
    }
    
    .service-option:active,
    .time-slot:active,
    .quick-reply:active,
    .option-card:active {
        background-color: var(--primary);
        color: white;
        border-color: var(--primary);
    }
}

/* Safe area insets for notched phones */
@supports (padding: max(0px)) {
    .chat-widget {
        bottom: max(15px, env(safe-area-inset-bottom));
        right: max(15px, env(safe-area-inset-right));
        left: max(15px, env(safe-area-inset-left));
    }
}