/**
 * JPsicologo Chatbot Widget Styles
 * Diseño premium con glassmorphism y animaciones suaves
 */

/* ============================================
   VARIABLES
============================================ */
:root {
    --jp-primary: #009c8c;
    --jp-primary-dark: #007a6c;
    --jp-primary-light: #00b89c;
    --jp-bg-dark: #1a1a2e;
    --jp-bg-light: #ffffff;
    --jp-text-dark: #1a1a2e;
    --jp-text-light: #6b7280;
    --jp-text-white: #ffffff;
    --jp-border: #e5e7eb;
    --jp-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --jp-shadow-hover: 0 15px 50px rgba(0, 0, 0, 0.2);
    --jp-radius: 16px;
    --jp-radius-sm: 12px;
    --jp-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   WIDGET CONTAINER
============================================ */
#jp-chatbot {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* ============================================
   TOGGLE BUTTON
============================================ */
#jp-chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--jp-primary) 0%, var(--jp-primary-dark) 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--jp-shadow);
    transition: var(--jp-transition);
    position: relative;
}

#jp-chatbot-toggle:hover {
    transform: scale(1.05);
    box-shadow: var(--jp-shadow-hover);
}

#jp-chatbot-toggle:active {
    transform: scale(0.98);
}

#jp-chatbot-toggle svg {
    width: 28px;
    height: 28px;
    color: var(--jp-text-white);
    transition: var(--jp-transition);
}

.jp-notification-dot {
    position: absolute;
    top: 0;
    right: 0;
    width: 16px;
    height: 16px;
    background: #ef4444;
    border-radius: 50%;
    border: 3px solid white;
    animation: jp-pulse 2s infinite;
}

@keyframes jp-pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

/* ============================================
   CHAT WINDOW
============================================ */
#jp-chatbot-window {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: var(--jp-bg-light);
    border-radius: var(--jp-radius);
    box-shadow: var(--jp-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: jp-slideIn 0.3s ease-out;
}

@keyframes jp-slideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ============================================
   HEADER
============================================ */
.jp-header {
    background: linear-gradient(135deg, var(--jp-primary) 0%, var(--jp-primary-dark) 100%);
    color: var(--jp-text-white);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.jp-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.jp-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    position: relative;
}

.jp-status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid var(--jp-primary);
}

.jp-header-text {
    display: flex;
    flex-direction: column;
}

.jp-header-text strong {
    font-size: 15px;
    font-weight: 600;
}

.jp-header-text span {
    font-size: 12px;
    opacity: 0.85;
}

#jp-minimize {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--jp-transition);
    color: white;
}

#jp-minimize:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ============================================
   MESSAGES AREA
============================================ */
#jp-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f9fafb;
}

#jp-messages::-webkit-scrollbar {
    width: 6px;
}

#jp-messages::-webkit-scrollbar-track {
    background: transparent;
}

#jp-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

/* ============================================
   MESSAGE BUBBLES
============================================ */
.jp-message {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: jp-fadeIn 0.3s ease-out;
}

@keyframes jp-fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.jp-message-bot {
    align-self: flex-start;
}

.jp-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.jp-message-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    background: linear-gradient(135deg, var(--jp-primary) 0%, var(--jp-primary-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 10px;
    font-weight: 600;
}

.jp-message-content {
    padding: 12px 16px;
    border-radius: var(--jp-radius-sm);
    line-height: 1.5;
}

.jp-message-bot .jp-message-content {
    background: var(--jp-bg-light);
    color: var(--jp-text-dark);
    border: 1px solid var(--jp-border);
    border-bottom-left-radius: 4px;
}

.jp-message-user .jp-message-content {
    background: linear-gradient(135deg, var(--jp-primary) 0%, var(--jp-primary-dark) 100%);
    color: var(--jp-text-white);
    border-bottom-right-radius: 4px;
}

.jp-message-content a {
    color: var(--jp-primary);
    text-decoration: underline;
}

.jp-message-user .jp-message-content a {
    color: white;
}

/* ============================================
   TYPING INDICATOR
============================================ */
.jp-typing .jp-message-content {
    padding: 12px 20px;
}

.jp-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.jp-typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--jp-text-light);
    border-radius: 50%;
    animation: jp-bounce 1.4s infinite ease-in-out both;
}

.jp-typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.jp-typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.jp-typing-dots span:nth-child(3) {
    animation-delay: 0s;
}

@keyframes jp-bounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
   QUICK REPLIES
============================================ */
#jp-quick-replies {
    padding: 0 16px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: #f9fafb;
}

#jp-quick-replies:empty {
    display: none;
}

.jp-quick-reply {
    background: var(--jp-bg-light);
    border: 1px solid var(--jp-primary);
    color: var(--jp-primary);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: var(--jp-transition);
    white-space: nowrap;
}

.jp-quick-reply:hover {
    background: var(--jp-primary);
    color: var(--jp-text-white);
}

/* ============================================
   INPUT AREA
============================================ */
.jp-input-area {
    padding: 12px 16px;
    background: var(--jp-bg-light);
    border-top: 1px solid var(--jp-border);
    display: flex;
    gap: 8px;
    align-items: center;
}

#jp-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--jp-border);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: var(--jp-transition);
    font-family: inherit;
}

#jp-input:focus {
    border-color: var(--jp-primary);
    box-shadow: 0 0 0 3px rgba(0, 156, 140, 0.1);
}

#jp-input::placeholder {
    color: #9ca3af;
}

#jp-send {
    width: 44px;
    height: 44px;
    min-width: 44px;
    background: linear-gradient(135deg, var(--jp-primary) 0%, var(--jp-primary-dark) 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: var(--jp-transition);
}

#jp-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 156, 140, 0.35);
}

#jp-send:active {
    transform: scale(0.98);
}

/* ============================================
   FOOTER
============================================ */
.jp-footer {
    padding: 8px 16px;
    text-align: center;
    background: var(--jp-bg-light);
    border-top: 1px solid var(--jp-border);
}

.jp-footer a {
    color: var(--jp-text-light);
    text-decoration: none;
    font-size: 11px;
}

.jp-footer a:hover {
    color: var(--jp-primary);
}

/* ============================================
   UTILITY CLASSES
============================================ */
.jp-hidden {
    display: none !important;
}

/* ============================================
   MOBILE RESPONSIVE
============================================ */
@media (max-width: 480px) {
    #jp-chatbot {
        bottom: 10px;
        right: 10px;
    }

    #jp-chatbot-toggle {
        width: 56px;
        height: 56px;
    }

    #jp-chatbot-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        max-height: calc(100vh - 80px);
        bottom: 70px;
        right: 0;
        border-radius: var(--jp-radius) var(--jp-radius) 0 0;
    }

    .jp-message {
        max-width: 90%;
    }
}

/* ============================================
   BOOKING WIDGET (PRO)
============================================ */
.jp-slots-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 8px;
    width: 100%;
}

.jp-slot-btn {
    background: white;
    border: 1px solid var(--jp-primary);
    color: var(--jp-primary);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: var(--jp-transition);
    text-align: center;
}

.jp-slot-btn:hover {
    background: var(--jp-primary);
    color: white;
}

.jp-booking-day {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 13px;
    color: var(--jp-text-dark);
    margin-top: 8px;
    display: block;
}

/* ============================================
   LEAD FORM (PRO)
============================================ */
.jp-lead-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    width: 100%;
    background: white;
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--jp-border);
}

.jp-lead-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--jp-text-dark);
    margin-bottom: 4px;
}

.jp-lead-input {
    padding: 10px;
    border: 1px solid var(--jp-border);
    border-radius: 8px;
    font-size: 13px;
    width: 100%;
    /* Cambiado a 100% para ocupar el contenedor */
    box-sizing: border-box;
    /* Importante para padding */
    outline: none;
    transition: var(--jp-transition);
    font-family: inherit;
}

.jp-lead-input:focus {
    border-color: var(--jp-primary);
    box-shadow: 0 0 0 2px rgba(0, 156, 140, 0.1);
}

.jp-lead-submit {
    background: linear-gradient(135deg, var(--jp-primary) 0%, var(--jp-primary-dark) 100%);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: var(--jp-transition);
    text-align: center;
    margin-top: 4px;
}

.jp-lead-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 156, 140, 0.25);
}

/* ============================================
   DARK MODE (FUTURE)
============================================ */
@media (prefers-color-scheme: dark) {
    /* TODO: Implementar dark mode si es necesario */
}