/* CCO Concierge ChatBot Styles
   ========================================================================== */

/* CSS Custom Properties - matching CCO brand */
:root {
    --chat-primary: #EDE7DC;      /* Champagne Beige - messages bg */
    --chat-secondary: #B8AFA2;    /* Greige - borders */
    --chat-accent: #8B2635;       /* Burgundy Red - buttons, header */
    --chat-accent-hover: #6D1E2A; /* Darker burgundy - hover */
    --chat-text: #3A3A3A;         /* Deep Espresso - text */
    --chat-white: #FFFFFF;
    --chat-shadow: rgba(0, 0, 0, 0.15);
    --chat-radius: 12px;
    --chat-transition: 0.3s ease;
}

/* Chat Toggle Button — "Book Now!" with Concierge Bell
   ========================================================================== */
.cco-chat-toggle {
    display: none;
    position: fixed;
    bottom: 24px;
    left: 5rem;
    width: 275px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 9998;
    padding: 0;
    transition: transform var(--chat-transition), filter var(--chat-transition);
}

.cco-chat-toggle:hover {
    transform: scale(1.05);
}

.cco-chat-toggle:focus {
    outline: 3px solid var(--chat-accent);
    outline-offset: 3px;
    border-radius: 8px;
}

.cco-chat-toggle:focus:not(:focus-visible) {
    outline: none;
}

.cco-chat-toggle:focus-visible {
    outline: 3px solid var(--chat-accent);
    outline-offset: 3px;
    border-radius: 8px;
}

/* SVG background — fills the button, preserves aspect ratio */
.cco-chat-toggle .cco-toggle-bg {
    width: 100%;
    height: auto;
    display: block;
}

/* Text overlay — positioned over the burgundy pill area */
.cco-chat-toggle .cco-toggle-text {
    position: absolute;
    left: 8%;
    top: 56%;
    transform: translateY(-50%);
    text-align: left;
    pointer-events: none;
    width: 52%;
}

.cco-chat-toggle .cco-toggle-title {
    display: block;
    color: var(--chat-white);
    font-family: 'Lato', sans-serif;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
}

.cco-chat-toggle .cco-toggle-subtitle {
    display: block;
    color: var(--chat-white);
    font-family: 'Lato', sans-serif;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.3;
    white-space: nowrap;
    opacity: 0.92;
}

/* Dim toggle slightly when chat is open */
.cco-chat-toggle[aria-expanded="true"] {
    opacity: 0.7;
}

/* Chat Window
   ========================================================================== */
.cco-chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    height: 500px;
    background: var(--chat-white);
    border-radius: var(--chat-radius);
    box-shadow: 0 8px 32px var(--chat-shadow);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: opacity var(--chat-transition), visibility var(--chat-transition), transform var(--chat-transition);
}

.cco-chat-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Chat Header
   ========================================================================== */
.cco-chat-header {
    background: var(--chat-accent);
    color: var(--chat-white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.cco-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cco-chat-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cco-chat-avatar svg,
.cco-chat-avatar img {
    width: 32px;
    height: 32px;
}

.cco-chat-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
    color: #FFFFFF;
}

.cco-chat-subtitle {
    font-size: 14px;
    opacity: 0.9;
    margin: 0;
}

.cco-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cco-chat-action,
.cco-chat-close {
    background: transparent;
    border: none;
    color: var(--chat-white);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--chat-transition);
}

.cco-chat-action:hover,
.cco-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.cco-chat-action:focus,
.cco-chat-close:focus {
    outline: 2px solid var(--chat-white);
    outline-offset: 2px;
}

.cco-chat-action:focus:not(:focus-visible),
.cco-chat-close:focus:not(:focus-visible) {
    outline: none;
}

.cco-chat-action:focus-visible,
.cco-chat-close:focus-visible {
    outline: 2px solid var(--chat-white);
    outline-offset: 2px;
}

.cco-chat-action svg,
.cco-chat-close svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Chat Messages Area
   ========================================================================== */
.cco-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--chat-primary);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Custom scrollbar */
.cco-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.cco-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.cco-chat-messages::-webkit-scrollbar-thumb {
    background: var(--chat-secondary);
    border-radius: 3px;
}

.cco-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #9a9189;
}

/* Message Bubbles
   ========================================================================== */
.cco-chat-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Bot messages - left aligned */
.cco-chat-message.bot {
    align-self: flex-start;
}

.cco-chat-message.bot .message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cco-chat-message.bot .message-avatar svg,
.cco-chat-message.bot .message-avatar img {
    width: 26px;
    height: 26px;
}

.cco-chat-message.bot .message-content {
    background: var(--chat-white);
    color: var(--chat-text);
    padding: 12px 16px;
    border-radius: 4px 16px 16px 16px;
    box-shadow: 0 2px 6px var(--chat-shadow);
}

/* User messages - right aligned */
.cco-chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.cco-chat-message.user .message-content {
    background: var(--chat-accent);
    color: var(--chat-white);
    padding: 12px 16px;
    border-radius: 16px 4px 16px 16px;
}

.message-content {
    font-size: 16px;
    line-height: 1.6;
    word-wrap: break-word;
}

.message-content p {
    margin: 0 0 8px 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul,
.message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin-bottom: 4px;
}

.message-content a {
    color: inherit;
    text-decoration: underline;
}

/* Typing Indicator
   ========================================================================== */
.cco-typing-indicator {
    display: flex;
    gap: 10px;
    align-self: flex-start;
    max-width: 85%;
}

.cco-typing-indicator .message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cco-typing-indicator .message-avatar svg,
.cco-typing-indicator .message-avatar img {
    width: 26px;
    height: 26px;
}

.typing-dots {
    background: var(--chat-white);
    padding: 12px 16px;
    border-radius: 4px 16px 16px 16px;
    box-shadow: 0 2px 6px var(--chat-shadow);
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--chat-secondary);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-6px);
    }
}

/* Chat Input Area
   ========================================================================== */
.cco-chat-team-bar {
    display: block;
    text-align: center;
    padding: 10px 16px;
    background: #41413e;
    color: #e8a87c;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    letter-spacing: 0.3px;
    flex-shrink: 0;
    transition: background var(--chat-transition);
}

.cco-chat-team-bar:hover {
    background: #333330;
    color: #f0b88c;
}

.cco-chat-input-area {
    padding: 16px;
    background: var(--chat-white);
    border-top: 1px solid var(--chat-secondary);
    flex-shrink: 0;
}

.cco-chat-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.cco-chat-input {
    flex: 1;
    border: 1px solid var(--chat-secondary);
    border-radius: 20px;
    padding: 12px 18px;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    min-height: 44px;
    max-height: 100px;
    line-height: 1.5;
    transition: border-color var(--chat-transition), box-shadow var(--chat-transition);
}

.cco-chat-input:focus {
    outline: none;
    border-color: var(--chat-accent);
    box-shadow: 0 0 0 3px rgba(139, 38, 53, 0.15);
}

.cco-chat-input::placeholder {
    color: #999;
}

.cco-chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--chat-accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--chat-transition), transform var(--chat-transition);
}

.cco-chat-send:hover:not(:disabled) {
    background: var(--chat-accent-hover);
    transform: scale(1.05);
}

.cco-chat-send:focus {
    outline: 3px solid var(--chat-accent);
    outline-offset: 2px;
}

.cco-chat-send:focus:not(:focus-visible) {
    outline: none;
}

.cco-chat-send:focus-visible {
    outline: 3px solid var(--chat-accent);
    outline-offset: 2px;
}

.cco-chat-send:disabled {
    background: var(--chat-secondary);
    cursor: not-allowed;
}

.cco-chat-send svg {
    width: 18px;
    height: 18px;
    fill: var(--chat-white);
}

/* Error State
   ========================================================================== */
.cco-chat-error {
    background: #fee;
    border: 1px solid #fcc;
    color: #c00;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 15px;
    text-align: center;
    margin: 8px 0;
}

/* Booking Confirmation Card
   ========================================================================== */
.cco-booking-card {
    background: var(--chat-white);
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--chat-shadow);
    padding: 20px;
    margin: 8px 0;
    animation: messageSlideIn 0.3s ease;
    border-left: 4px solid var(--chat-accent);
}

.cco-booking-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--chat-secondary);
}

.cco-booking-card-icon {
    width: 32px;
    height: 32px;
    background: var(--chat-accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cco-booking-card-icon svg {
    width: 18px;
    height: 18px;
    fill: var(--chat-white);
}

.cco-booking-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--chat-text);
    margin: 0;
}

.cco-booking-card-fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.cco-booking-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cco-booking-field-label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cco-booking-field-value {
    font-size: 15px;
    color: var(--chat-text);
    padding: 8px 12px;
    background: var(--chat-primary);
    border-radius: 6px;
    border: 1px solid transparent;
}

/* Editable fields */
.cco-booking-field-input {
    font-size: 15px;
    color: var(--chat-text);
    padding: 8px 12px;
    background: var(--chat-white);
    border-radius: 6px;
    border: 1px solid var(--chat-secondary);
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
}

.cco-booking-field-input:focus {
    outline: none;
    border-color: var(--chat-accent);
    box-shadow: 0 0 0 2px rgba(139, 38, 53, 0.15);
}

.cco-booking-field-input.error {
    border-color: #c00;
    background: #fff5f5;
}

.cco-booking-field-error {
    font-size: 12px;
    color: #c00;
    margin-top: 2px;
}

/* Surgery type selector */
.cco-booking-surgery-select {
    display: flex;
    gap: 8px;
}

.cco-booking-surgery-option {
    flex: 1;
    padding: 10px 16px;
    background: var(--chat-primary);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: var(--chat-text);
    transition: all 0.2s ease;
}

.cco-booking-surgery-option:hover {
    background: #e5dfd4;
}

.cco-booking-surgery-option.selected {
    background: var(--chat-accent);
    color: var(--chat-white);
    border-color: var(--chat-accent);
}

.cco-booking-card-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--chat-secondary);
}

.cco-booking-btn {
    flex: 1;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: inherit;
}

.cco-booking-btn-edit {
    background: var(--chat-primary);
    color: var(--chat-text);
    border: 1px solid var(--chat-secondary);
}

.cco-booking-btn-edit:hover {
    background: #e5dfd4;
}

.cco-booking-btn-submit {
    background: var(--chat-accent);
    color: var(--chat-white);
}

.cco-booking-btn-submit:hover:not(:disabled) {
    background: var(--chat-accent-hover);
}

.cco-booking-btn-submit:disabled {
    background: var(--chat-secondary);
    cursor: not-allowed;
}

.cco-booking-btn-cancel {
    background: transparent;
    color: #666;
    border: 1px solid var(--chat-secondary);
}

.cco-booking-btn-cancel:hover {
    background: #f5f5f5;
}

/* Booking success state */
.cco-booking-card.success {
    border-left-color: #28a745;
}

.cco-booking-card.success .cco-booking-card-icon {
    background: #28a745;
}

.cco-booking-success-message {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: #e8f5e9;
    border-radius: 8px;
    color: #2e7d32;
    font-size: 14px;
}

.cco-booking-success-message svg {
    width: 20px;
    height: 20px;
    fill: #2e7d32;
    flex-shrink: 0;
}

/* Loading state for submit button */
.cco-booking-btn-submit.loading {
    position: relative;
    color: transparent;
}

.cco-booking-btn-submit.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid var(--chat-white);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Mobile Responsive
   ========================================================================== */
@media (max-width: 480px) {
    .cco-chat-toggle {
        bottom: 16px;
        right: 12px;
        width: 190px;
    }

    .cco-chat-toggle .cco-toggle-title {
        font-size: 17px;
    }

    .cco-chat-toggle .cco-toggle-subtitle {
        font-size: 10px;
    }

    .cco-chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .cco-chat-header {
        padding: 12px 16px;
    }

    .cco-chat-messages {
        padding: 16px;
    }

    .cco-chat-input-area {
        padding: 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .cco-chat-message {
        max-width: 90%;
    }
}

/* Tablet */
@media (min-width: 481px) and (max-width: 768px) {
    .cco-chat-window {
        width: 340px;
        height: 450px;
    }
}

/* Reduced Motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .cco-chat-toggle,
    .cco-chat-window,
    .cco-chat-message,
    .cco-chat-send,
    .cco-chat-close {
        transition: none;
    }

    .cco-chat-toggle,
    .cco-chat-message {
        animation: none;
    }

    .typing-dots span {
        animation: none;
    }
}

/* High Contrast Mode
   ========================================================================== */
@media (prefers-contrast: high) {
    .cco-chat-window {
        border: 2px solid var(--chat-text);
    }

    .cco-chat-message.bot .message-content {
        border: 1px solid var(--chat-text);
    }

    .cco-chat-input {
        border-width: 2px;
    }
}

/* Print - Hide Chat Widget
   ========================================================================== */
@media print {
    .cco-chat-toggle,
    .cco-chat-window {
        display: none !important;
    }
}
