/**
 * Reserver Chatbot for WordPress
 * Styles for the chatbot widget
 */

:root {
    --reserver-chatbot-primary: #007bff;
    --reserver-chatbot-primary-dark: #0056b3;
    --reserver-chatbot-primary-text: #ffffff;
    --reserver-chatbot-bg: #ffffff;
    --reserver-chatbot-text: #333333;
    --reserver-chatbot-text-light: #666666;
    --reserver-chatbot-messages-bg: #f8f9fa;
    --reserver-chatbot-assistant-bubble: #ffffff;
    --reserver-chatbot-border: #e0e0e0;
    --reserver-chatbot-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --reserver-chatbot-radius: 16px;
}

/* Container */
.reserver-chatbot-container {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.reserver-chatbot-container.bottom-right {
    bottom: 20px;
    right: 20px;
}

.reserver-chatbot-container.bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Toggle Button */
.reserver-chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--reserver-chatbot-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--reserver-chatbot-shadow);
    transition: transform 0.3s ease, background-color 0.3s ease;
}

.reserver-chatbot-toggle:hover {
    transform: scale(1.05);
    background: var(--reserver-chatbot-primary-dark);
}

.reserver-chatbot-toggle svg {
    width: 28px;
    height: 28px;
    fill: var(--reserver-chatbot-primary-text);
}

.reserver-chatbot-toggle .icon-close {
    display: none;
}

.reserver-chatbot-container.open .reserver-chatbot-toggle .icon-chat {
    display: none;
}

.reserver-chatbot-container.open .reserver-chatbot-toggle .icon-close {
    display: block;
}

/* Chat Window */
.reserver-chatbot-window {
    position: absolute;
    bottom: 80px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 500px;
    min-height: 300px;
    max-height: calc(100vh - 120px);
    background: var(--reserver-chatbot-bg);
    border-radius: var(--reserver-chatbot-radius);
    box-shadow: var(--reserver-chatbot-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

/* Resize Handle */
.reserver-chatbot-resize-handle {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 12px;
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    background: transparent;
    transition: background 0.2s;
}

.reserver-chatbot-resize-handle:hover,
.reserver-chatbot-resize-handle.active {
    background: rgba(0, 0, 0, 0.05);
}

.reserver-chatbot-resize-handle::after {
    content: '';
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 2px;
    transition: background 0.2s;
}

.reserver-chatbot-resize-handle:hover::after,
.reserver-chatbot-resize-handle.active::after {
    background: rgba(255, 255, 255, 0.8);
}

/* Prevent text selection while resizing */
.reserver-chatbot-resizing {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.reserver-chatbot-resizing * {
    cursor: ns-resize !important;
}

.reserver-chatbot-container.bottom-right .reserver-chatbot-window {
    right: 0;
}

.reserver-chatbot-container.bottom-left .reserver-chatbot-window {
    left: 0;
}

.reserver-chatbot-container.open .reserver-chatbot-window {
    display: flex;
    animation: reserver-chatbot-slide-up 0.3s ease;
}

@keyframes reserver-chatbot-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.reserver-chatbot-header {
    background: var(--reserver-chatbot-primary);
    color: var(--reserver-chatbot-primary-text);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.reserver-chatbot-header-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.reserver-chatbot-header-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.reserver-chatbot-header-logo svg {
    width: 24px;
    height: 24px;
    fill: var(--reserver-chatbot-primary-text);
}

.reserver-chatbot-header-info {
    flex: 1;
}

.reserver-chatbot-header-title {
    font-weight: 600;
    font-size: 16px;
    margin: 0;
}

.reserver-chatbot-header-subtitle {
    font-size: 12px;
    opacity: 0.9;
    margin: 0;
}

.reserver-chatbot-header-close {
    background: none;
    border: none;
    color: var(--reserver-chatbot-primary-text);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.reserver-chatbot-header-close:hover {
    opacity: 1;
}

.reserver-chatbot-header-close svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Messages Area */
.reserver-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--reserver-chatbot-messages-bg);
}

/* Message Bubbles */
.reserver-chatbot-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    animation: reserver-chatbot-message-appear 0.2s ease;
}

@keyframes reserver-chatbot-message-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.reserver-chatbot-message.assistant {
    background: var(--reserver-chatbot-assistant-bubble);
    color: var(--reserver-chatbot-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.reserver-chatbot-message.user {
    background: var(--reserver-chatbot-primary);
    color: var(--reserver-chatbot-primary-text);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.reserver-chatbot-message p {
    margin: 0 0 8px 0;
}

.reserver-chatbot-message p:last-child {
    margin-bottom: 0;
}

.reserver-chatbot-message a {
    color: inherit;
    text-decoration: underline;
}

.reserver-chatbot-message.user a {
    color: var(--reserver-chatbot-primary-text);
}

/* Typing Indicator */
.reserver-chatbot-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--reserver-chatbot-assistant-bubble);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.reserver-chatbot-typing span {
    width: 8px;
    height: 8px;
    background: var(--reserver-chatbot-primary);
    border-radius: 50%;
    animation: reserver-chatbot-typing-bounce 1.4s ease-in-out infinite;
}

.reserver-chatbot-typing span:nth-child(1) {
    animation-delay: 0s;
}

.reserver-chatbot-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.reserver-chatbot-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes reserver-chatbot-typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Input Area */
.reserver-chatbot-input {
    padding: 12px 16px;
    border-top: 1px solid var(--reserver-chatbot-border);
    display: flex;
    gap: 8px;
    background: var(--reserver-chatbot-bg);
    flex-shrink: 0;
}

.reserver-chatbot-input-field {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--reserver-chatbot-border);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: var(--reserver-chatbot-bg);
    color: var(--reserver-chatbot-text);
}

.reserver-chatbot-input-field::placeholder {
    color: var(--reserver-chatbot-text-light);
}

.reserver-chatbot-input-field:focus {
    border-color: var(--reserver-chatbot-primary);
}

.reserver-chatbot-input-field:disabled {
    background: #f5f5f5;
}

.reserver-chatbot-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--reserver-chatbot-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, transform 0.1s;
}

.reserver-chatbot-send-btn:hover:not(:disabled) {
    background: var(--reserver-chatbot-primary-dark);
}

.reserver-chatbot-send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.reserver-chatbot-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.reserver-chatbot-send-btn svg {
    width: 20px;
    height: 20px;
    fill: var(--reserver-chatbot-primary-text);
}

/* Error Message */
.reserver-chatbot-error {
    background: #fee;
    color: #c00;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    text-align: center;
    margin: 8px 0;
}

/* Powered By */
.reserver-chatbot-powered {
    text-align: center;
    padding: 8px;
    font-size: 11px;
    color: var(--reserver-chatbot-text-light);
    background: var(--reserver-chatbot-bg);
    border-top: 1px solid var(--reserver-chatbot-border);
}

.reserver-chatbot-powered a {
    color: var(--reserver-chatbot-primary);
    text-decoration: none;
}

/* Tablet Responsiveness */
@media (max-width: 768px) {
    .reserver-chatbot-window {
        width: calc(100vw - 40px);
        max-width: 400px;
    }
}

/* Mobile Responsiveness - Fullscreen on smartphones */
@media (max-width: 480px) {
    .reserver-chatbot-container {
        bottom: 0 !important;
        right: 0 !important;
        left: auto !important;
    }

    .reserver-chatbot-container.bottom-left {
        left: 0 !important;
        right: auto !important;
    }

    .reserver-chatbot-toggle {
        width: 56px;
        height: 56px;
        margin: 16px;
    }

    /* Fullscreen chat window on mobile */
    .reserver-chatbot-container.open .reserver-chatbot-toggle {
        display: none;
    }

    .reserver-chatbot-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        z-index: 999999;
    }

    .reserver-chatbot-container.bottom-right .reserver-chatbot-window,
    .reserver-chatbot-container.bottom-left .reserver-chatbot-window {
        left: 0 !important;
        right: 0 !important;
    }

    /* Adjust header for fullscreen */
    .reserver-chatbot-header {
        padding: 12px 16px;
        padding-top: max(12px, env(safe-area-inset-top));
    }

    /* Show close button more prominently on mobile */
    .reserver-chatbot-header-close {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .reserver-chatbot-header-close svg {
        width: 24px;
        height: 24px;
    }

    /* Messages area adjustments */
    .reserver-chatbot-messages {
        padding: 12px;
    }

    .reserver-chatbot-message {
        max-width: 90%;
    }

    /* Input area adjustments for safe area */
    .reserver-chatbot-input {
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    /* Powered by adjustments */
    .reserver-chatbot-powered {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }

    /* Hide resize handle on mobile - not needed for fullscreen */
    .reserver-chatbot-resize-handle {
        display: none;
    }
}

/* Extra small devices (very small phones) */
@media (max-width: 360px) {
    .reserver-chatbot-header {
        padding: 10px 12px;
        gap: 8px;
    }

    .reserver-chatbot-header-logo {
        width: 36px;
        height: 36px;
    }

    .reserver-chatbot-header-title {
        font-size: 15px;
    }

    .reserver-chatbot-header-subtitle {
        font-size: 11px;
    }

    .reserver-chatbot-input-field {
        padding: 8px 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .reserver-chatbot-send-btn {
        width: 40px;
        height: 40px;
    }
}
