/**
 * Reservas Plugin - Estilos Principales
 *
 * Layout con calendario a la izquierda y chatbot a la derecha
 */

/* ========================================
   Variables CSS
   ======================================== */
:root {
    --reservas-primary-color: #2271b1;
    --reservas-secondary-color: #135e96;
    --reservas-success-color: #00a32a;
    --reservas-error-color: #d63638;
    --reservas-warning-color: #dba617;
    --reservas-bg-color: #ffffff;
    --reservas-border-color: #c3c4c7;
    --reservas-text-color: #1d2327;
    --reservas-text-muted: #50575e;
    --reservas-bg-light: #f0f0f1;
    --reservas-bot-message-bg: #f0f0f1;
    --reservas-user-message-bg: #2271b1;
    --reservas-user-message-text: #ffffff;
    --reservas-border-radius: 8px;
    --reservas-spacing: 16px;
}

/* ========================================
   Layout Principal
   ======================================== */
.reservas-plugin-wrapper {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--reservas-spacing);
    box-sizing: border-box;
}

.reservas-plugin-container {
    display: flex;
    gap: var(--reservas-spacing);
    align-items: flex-start;
}

/* ========================================
   Lado del Calendario (Izquierda)
   ======================================== */
.reservas-plugin-calendar-side {
    flex: 0 0 60%;
    min-width: 0;
}

.reservas-calendar-wrapper {
    background: var(--reservas-bg-color);
    border: 1px solid var(--reservas-border-color);
    border-radius: var(--reservas-border-radius);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.reservas-calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--reservas-spacing);
    border-bottom: 1px solid var(--reservas-border-color);
    background: var(--reservas-bg-light);
}

.reservas-calendar-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--reservas-text-color);
}

.reservas-calendar-refresh {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--reservas-primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color 0.2s ease;
}

.reservas-calendar-refresh:hover {
    background: var(--reservas-secondary-color);
}

.reservas-calendar-refresh:disabled {
    background: var(--reservas-text-muted);
    cursor: not-allowed;
    opacity: 0.7;
}

.reservas-calendar-container {
    position: relative;
    background: var(--reservas-bg-color);
}

.reservas-calendar-iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: none;
}

.reservas-calendar-footer {
    padding: var(--reservas-spacing);
    border-top: 1px solid var(--reservas-border-color);
    text-align: center;
}

.reservas-calendar-loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--reservas-text-muted);
    font-size: 0.875rem;
}

.reservas-calendar-loading .dashicons {
    animation: rotate 2s linear infinite;
}

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

/* Estado no configurado */
.reservas-calendar-not-configured {
    padding: 48px var(--reservas-spacing);
    text-align: center;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reservas-calendar-placeholder .dashicons {
    display: block;
    margin: 0 auto 16px;
}

.reservas-calendar-placeholder h3 {
    margin: 0 0 8px;
    font-size: 1.25rem;
}

.reservas-calendar-placeholder p {
    color: var(--reservas-text-muted);
    margin-bottom: 16px;
}

/* ========================================
   Lado del Chatbot (Derecha)
   ======================================== */
.reservas-plugin-chatbot-side {
    flex: 1;
    min-width: 320px;
}

.reservas-chatbot-wrapper {
    background: var(--reservas-bg-color);
    border: 1px solid var(--reservas-border-color);
    border-radius: var(--reservas-border-radius);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    height: 600px;
}

/* Header del Chatbot */
.reservas-chatbot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--reservas-spacing);
    border-bottom: 1px solid var(--reservas-border-color);
    background: var(--reservas-bg-light);
}

.reservas-chatbot-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.reservas-chatbot-avatar {
    width: 40px;
    height: 40px;
    background: var(--reservas-primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.reservas-chatbot-avatar .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.reservas-chatbot-title h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--reservas-text-color);
}

.reservas-chatbot-status {
    font-size: 0.75rem;
    color: var(--reservas-text-muted);
    display: block;
    margin-top: 2px;
}

.reservas-chatbot-status.online {
    color: var(--reservas-success-color);
}

.reservas-chatbot-status.offline {
    color: var(--reservas-error-color);
}

.reservas-chatbot-actions {
    display: flex;
    gap: 8px;
}

.reservas-chatbot-clear {
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--reservas-text-muted);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.reservas-chatbot-clear:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--reservas-text-color);
}

/* Contenedor de Mensajes */
.reservas-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--reservas-spacing);
    background: var(--reservas-bg-color);
    scroll-behavior: smooth;
}

.reservas-chatbot-welcome {
    padding: var(--reservas-spacing);
    background: var(--reservas-bot-message-bg);
    border-radius: var(--reservas-border-radius);
    margin-bottom: var(--reservas-spacing);
}

/* Mensajes */
.reservas-chatbot-message {
    display: flex;
    gap: 8px;
    margin-bottom: var(--reservas-spacing);
    animation: messageSlideIn 0.3s ease;
}

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

.reservas-chatbot-message.user-message {
    flex-direction: row-reverse;
}

.reservas-chatbot-message-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.reservas-chatbot-message .reservas-chatbot-message-avatar {
    background: var(--reservas-primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reservas-chatbot-message.user-message .reservas-chatbot-message-avatar {
    background: #8c8f94;
}

.reservas-chatbot-message-avatar .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.reservas-chatbot-message-content {
    flex: 1;
    max-width: 80%;
    padding: 10px 14px;
    border-radius: var(--reservas-border-radius);
    font-size: 0.875rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.reservas-chatbot-message.bot-message .reservas-chatbot-message-content {
    background: var(--reservas-bot-message-bg);
    color: var(--reservas-text-color);
}

.reservas-chatbot-message.user-message .reservas-chatbot-message-content {
    background: var(--reservas-user-message-bg);
    color: var(--reservas-user-message-text);
}

.reservas-chatbot-message-time {
    font-size: 0.7rem;
    color: var(--reservas-text-muted);
    margin-top: 4px;
}

.reservas-chatbot-message.user-message .reservas-chatbot-message-time {
    text-align: right;
}

/* Indicador de escritura */
.reservas-chatbot-typing .reservas-chatbot-message-content {
    padding: 12px 16px;
}

.reservas-chatbot-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

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

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

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

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Mensaje de error */
.reservas-chatbot-error {
    background: #fee;
    color: var(--reservas-error-color);
    border: 1px solid #fcc;
}

/* Input del Chatbot */
.reservas-chatbot-input-container {
    border-top: 1px solid var(--reservas-border-color);
    padding: var(--reservas-spacing);
    background: var(--reservas-bg-light);
}

.reservas-chatbot-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.reservas-chatbot-input {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    padding: 10px 14px;
    border: 1px solid var(--reservas-border-color);
    border-radius: var(--reservas-border-radius);
    font-size: 0.875rem;
    font-family: inherit;
    resize: none;
    line-height: 1.4;
    transition: border-color 0.2s ease;
}

.reservas-chatbot-input:focus {
    outline: none;
    border-color: var(--reservas-primary-color);
}

.reservas-chatbot-input:disabled {
    background: var(--reservas-bg-light);
    cursor: not-allowed;
}

.reservas-chatbot-send {
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--reservas-primary-color);
    color: white;
    border: none;
    border-radius: var(--reservas-border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color 0.2s ease;
}

.reservas-chatbot-send:hover:not(:disabled) {
    background: var(--reservas-secondary-color);
}

.reservas-chatbot-send:disabled,
.reservas-button-disabled {
    background: var(--reservas-text-muted);
    cursor: not-allowed;
    opacity: 0.7;
}

.reservas-chatbot-send .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.reservas-chatbot-footer {
    margin-top: 8px;
    text-align: center;
}

.reservas-chatbot-footer small {
    font-size: 0.7rem;
    color: var(--reservas-text-muted);
}

/* Estado no configurado del chatbot */
.reservas-chatbot-not-configured {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    padding: var(--reservas-spacing);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.reservas-chatbot-not-configured p {
    margin-bottom: 16px;
    font-size: 0.875rem;
    color: var(--reservas-text-muted);
}

/* ========================================
   Diseño Responsive
   ======================================== */
@media (max-width: 1024px) {
    .reservas-plugin-calendar-side {
        flex: 0 0 55%;
    }

    .reservas-plugin-chatbot-side {
        flex: 1;
        min-width: 280px;
    }

    .reservas-chatbot-wrapper {
        height: 500px;
    }
}

@media (max-width: 768px) {
    .reservas-plugin-container {
        flex-direction: column;
    }

    .reservas-plugin-calendar-side,
    .reservas-plugin-chatbot-side {
        flex: 1;
        width: 100%;
        min-width: 0;
    }

    .reservas-calendar-container {
        height: 400px !important;
    }

    .reservas-chatbot-wrapper {
        height: 450px;
    }

    .reservas-chatbot-message-content {
        max-width: 85%;
    }
}

@media (max-width: 480px) {
    .reservas-plugin-wrapper {
        padding: 8px;
    }

    .reservas-plugin-container {
        gap: 8px;
    }

    .reservas-calendar-header,
    .reservas-chatbot-header {
        padding: 12px;
    }

    .reservas-calendar-header h2 {
        font-size: 1rem;
    }

    .reservas-calendar-container {
        height: 300px !important;
    }

    .reservas-chatbot-wrapper {
        height: 400px;
    }

    .reservas-chatbot-message-avatar {
        width: 28px;
        height: 28px;
    }

    .reservas-chatbot-avatar {
        width: 36px;
        height: 36px;
    }

    .reservas-chatbot-message-content {
        max-width: 90%;
        font-size: 0.8rem;
    }
}

/* ========================================
   Animaciones y Transiciones
   ======================================== */
.rotating {
    animation: rotate 2s linear infinite;
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

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

/* ========================================
   Scrollbar Personalizado
   ======================================== */
.reservas-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.reservas-chatbot-messages::-webkit-scrollbar-track {
    background: var(--reservas-bg-light);
    border-radius: 3px;
}

.reservas-chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--reservas-border-color);
    border-radius: 3px;
}

.reservas-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #8c8f94;
}

/* ========================================
   Utilidades
   ======================================== */
.reservas-hidden {
    display: none !important;
}

.reservas-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
