/**
 * Valley Virtual Assistant - Frontend Styles
 */

/* Chat Widget Container */
#vva-chat-widget {
    position: fixed;
    z-index: 2147483647;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif;
    pointer-events: none;
}

#vva-chat-widget * {
    pointer-events: auto;
}

#vva-chat-widget.vva-widget-bottom-right {
    bottom: 20px;
    right: 20px;
}

#vva-chat-widget.vva-widget-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Chat Toggle Button */
.vva-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--vva-primary-color, #e91e63);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.vva-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.vva-chat-toggle svg {
    width: 28px;
    height: 28px;
    color: white;
    transition: opacity 0.2s;
}

.vva-chat-toggle .vva-icon-close {
    position: absolute;
    opacity: 0;
}

.vva-chat-toggle.active .vva-icon-chat {
    opacity: 0;
}

.vva-chat-toggle.active .vva-icon-close {
    opacity: 1;
}

/* Chat Window */
.vva-chat-window {
    position: fixed;
    bottom: 90px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    -webkit-overflow-scrolling: touch;
}

.vva-widget-bottom-right .vva-chat-window {
    right: 20px;
}

.vva-widget-bottom-left .vva-chat-window {
    left: 20px;
}

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

/* Age Disclaimer */
.vva-age-disclaimer {
    position: fixed;
    bottom: 90px;
    width: 380px;
    max-width: calc(100vw - 40px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    transition: all 0.3s ease;
    opacity: 0;
    transform: scale(0.9) translateY(20px);
}

.vva-widget-bottom-right .vva-age-disclaimer {
    right: 20px;
}

.vva-widget-bottom-left .vva-age-disclaimer {
    left: 20px;
}

.vva-age-disclaimer.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.vva-disclaimer-content {
    padding: 32px 24px;
    text-align: center;
}

.vva-disclaimer-icon {
    margin: 0 auto 20px;
    color: #ff9800;
}

.vva-disclaimer-content h3 {
    margin: 0 0 16px;
    font-size: 22px;
    font-weight: 700;
    color: #1d2327;
}

.vva-disclaimer-content p {
    margin: 0 0 12px;
    font-size: 15px;
    line-height: 1.6;
    color: #666;
}

.vva-disclaimer-content p strong {
    color: #d32f2f;
    font-size: 16px;
}

.vva-disclaimer-privacy {
    font-size: 13px !important;
    color: #999 !important;
    margin-top: 20px !important;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.vva-disclaimer-buttons {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.vva-btn-confirm,
.vva-btn-decline {
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.vva-btn-confirm {
    background: var(--vva-primary-color, #e91e63);
    color: white;
}

.vva-btn-confirm:hover {
    background: var(--vva-primary-color-dark, #c2185b);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(233, 30, 99, 0.3);
}

.vva-btn-decline {
    background: #f5f5f5;
    color: #666;
}

.vva-btn-decline:hover {
    background: #e0e0e0;
}

/* Chat Header */
.vva-chat-header {
    background: var(--vva-primary-color, #e91e63);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.vva-assistant-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.vva-assistant-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.vva-assistant-details h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.vva-assistant-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    opacity: 0.9;
}

.vva-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.vva-minimize {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.vva-minimize:hover {
    background: rgba(255, 255, 255, 0.2);
}

.vva-minimize svg {
    width: 20px;
    height: 20px;
}

/* Messages Container */
.vva-messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #f5f5f5;
    -webkit-overflow-scrolling: touch;
}

.vva-message {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
    align-items: flex-start;
}

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

.vva-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.vva-message-content {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 75%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
}

.vva-message-user .vva-message-content {
    background: var(--vva-primary-color, #e91e63);
    color: white;
    margin-left: auto;
}

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

/* Assistant message structure with buttons */
.vva-message-assistant {
    flex-wrap: wrap;
}

.vva-message-assistant .vva-quick-buttons {
    margin-left: 42px; /* Align with message content (avatar width + gap) */
    max-width: calc(75% - 10px);
}

.vva-message-content p {
    margin: 0;
    line-height: 1.5;
    font-size: 14px;
}

.vva-message-content p + p {
    margin-top: 8px;
}

/* Typing Indicator */
.vva-typing-indicator {
    display: flex;
    gap: 10px;
    padding: 0 20px;
    margin-bottom: 10px;
}

.vva-typing-content {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.vva-typing-message {
    font-size: 13px;
    color: #666;
    font-style: italic;
}

.vva-typing-dots {
    display: flex;
    gap: 4px;
}

.vva-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input Area */
.vva-chat-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

#vva-chat-form {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.vva-message-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;
    min-height: 44px;
}

.vva-message-input:focus {
    border-color: var(--vva-primary-color, #e91e63);
}

.vva-send-button {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    background: var(--vva-primary-color, #e91e63);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.vva-send-button:hover {
    background: var(--vva-primary-color-dark, #c2185b);
}

.vva-send-button svg {
    width: 20px;
    height: 20px;
}

.vva-send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Privacy Note */
.vva-privacy-note {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #666;
    justify-content: center;
}

.vva-privacy-note svg {
    color: #4caf50;
}

/* Tablet Responsiveness */
@media (max-width: 768px) {
    .vva-chat-window {
        width: 360px;
        max-width: calc(100vw - 40px);
    }

    .vva-product-image {
        height: 160px;
    }

    .vva-message-assistant .vva-products-container {
        max-width: 100%;
    }
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    #vva-chat-widget.vva-widget-bottom-right {
        right: 10px;
        bottom: 10px;
    }

    #vva-chat-widget.vva-widget-bottom-left {
        left: 10px;
        bottom: 10px;
    }

    .vva-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        max-height: calc(100vh - 80px);
        bottom: 70px;
        border-radius: 12px;
    }

    .vva-widget-bottom-right .vva-chat-window {
        right: 10px;
        left: auto;
    }

    .vva-widget-bottom-left .vva-chat-window {
        left: 10px;
        right: auto;
    }

    .vva-chat-input-area {
        padding: 12px;
    }

    .vva-message-input {
        font-size: 16px;
        padding: 10px 14px;
    }

    .vva-age-disclaimer {
        width: calc(100vw - 20px);
    }

    .vva-widget-bottom-right .vva-age-disclaimer {
        right: 10px;
        left: auto;
    }

    .vva-widget-bottom-left .vva-age-disclaimer {
        left: 10px;
        right: auto;
    }

    .vva-chat-toggle {
        width: 50px;
        height: 50px;
    }

    .vva-chat-toggle svg {
        width: 24px;
        height: 24px;
    }

    .vva-messages-container {
        padding: 12px;
    }

    .vva-message-content {
        max-width: 85%;
        font-size: 13px;
    }
}

/* Scrollbar Styling */
.vva-messages-container::-webkit-scrollbar {
    width: 6px;
}

.vva-messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.vva-messages-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.vva-messages-container::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Product Cards */
.vva-products-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
    width: 100%;
}

.vva-product-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.3s ease;
    min-width: 0;
}

.vva-product-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.vva-product-image {
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: #f9f9f9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vva-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.vva-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 14px;
    background: #f5f5f5;
}

/* Add to Cart Button - Primary (WooCommerce Best Practices) */
.vva-add-to-cart-primary {
    width: 100%;
    padding: 16px 24px;
    margin: 16px;
    margin-bottom: 12px;
    background: var(--vva-primary-color, #e91e63);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    min-height: 52px;
    box-shadow: 0 2px 8px rgba(233, 30, 99, 0.25);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.vva-add-to-cart-primary:hover:not(:disabled) {
    background: var(--vva-primary-color-dark, #c2185b);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(233, 30, 99, 0.4);
}

.vva-add-to-cart-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(233, 30, 99, 0.25);
}

.vva-add-to-cart-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

.vva-add-to-cart-primary.added {
    background: #4caf50;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.vva-add-to-cart-primary.error {
    background: #f44336;
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

.vva-cart-icon {
    font-size: 18px;
    margin-right: 8px;
    vertical-align: middle;
}

/* Product Info - Below Add to Cart */
.vva-product-info {
    padding: 0 16px 12px 16px;
    display: flex;
    flex-direction: column;
}

.vva-product-name {
    font-size: 16px;
    font-weight: 600;
    color: #1d2327;
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.vva-product-price {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
    flex-wrap: wrap;
}

.vva-price-current,
.vva-price-sale {
    font-size: 20px;
    font-weight: 700;
    color: var(--vva-primary-color, #e91e63);
}

.vva-price-regular {
    font-size: 16px;
    color: #999;
}

.vva-price-regular del {
    text-decoration: line-through;
}

/* Product Description */
.vva-product-description {
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.6;
    color: #555;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
}

.vva-product-description p {
    margin: 0 0 8px 0;
}

.vva-product-description p:last-child {
    margin-bottom: 0;
}

.vva-product-description ul,
.vva-product-description ol {
    margin: 8px 0;
    padding-left: 20px;
}

.vva-product-description li {
    margin: 4px 0;
}

/* View Product Link */
.vva-product-link {
    display: block;
    text-align: center;
    padding: 12px 16px;
    margin: 12px 16px 16px 16px;
    color: #666;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    min-height: 44px;
    line-height: 20px;
}

.vva-product-link:hover {
    color: var(--vva-primary-color, #e91e63);
    border-color: var(--vva-primary-color, #e91e63);
    background: rgba(233, 30, 99, 0.05);
    transform: translateX(2px);
}

/* Remove old product-actions class since we're restructuring */
.vva-product-actions {
    display: none;
}

/* Legacy button styles (for backwards compatibility) */
.vva-add-to-cart-btn:not(.vva-add-to-cart-primary) {
    width: 100%;
    padding: 12px 20px;
    background: var(--vva-primary-color, #e91e63);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    min-height: 44px;
}

/* Product Cards in Message */
.vva-message-assistant .vva-products-container {
    width: 100%;
    margin-left: 0;
    max-width: 100%;
}

/* Tablet Product Cards */
@media (max-width: 768px) {
    .vva-products-container {
        gap: 12px;
    }

    .vva-message-assistant .vva-products-container {
        margin-left: 0;
    }

    .vva-product-image {
        height: 200px;
    }
}

/* Mobile Product Cards */
@media (max-width: 480px) {
    .vva-products-container {
        gap: 10px;
        margin-left: 0;
    }

    .vva-product-card {
        max-width: 100%;
        width: 100%;
    }

    .vva-product-image {
        height: 180px;
    }

    .vva-message-assistant .vva-products-container {
        max-width: 100%;
        margin-left: 0;
        width: 100%;
    }

    .vva-product-name {
        font-size: 14px;
    }

    .vva-add-to-cart-btn {
        font-size: 13px;
        padding: 10px 16px;
    }

    .vva-product-link {
        font-size: 12px;
        padding: 8px 12px;
    }
}

/* Quick Reply Buttons */
.vva-quick-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
    padding: 0;
    width: 100%;
}

.vva-quick-button {
    background: #fff;
    border: 1px solid var(--vva-primary-color, #e91e63);
    color: var(--vva-primary-color, #e91e63);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    outline: none;
    width: 100%;
    max-width: 100%;
}

.vva-quick-button:hover:not(:disabled) {
    background: var(--vva-primary-color, #e91e63);
    color: #fff;
    transform: translateX(4px);
    box-shadow: 0 2px 6px rgba(233, 30, 99, 0.2);
}

.vva-quick-button:active:not(:disabled) {
    transform: translateX(0);
}

.vva-quick-button:disabled,
.vva-quick-button.clicked {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f5f5f5;
    border-color: #ddd;
    color: #999;
}

.vva-quick-button.clicked {
    background: var(--vva-primary-color, #e91e63);
    color: #fff;
    opacity: 0.6;
}

/* Tablet Quick Buttons */
@media (max-width: 768px) {
    .vva-message-assistant .vva-quick-buttons {
        margin-left: 42px;
        max-width: 100%;
    }
}

/* Mobile Quick Buttons */
@media (max-width: 480px) {
    .vva-quick-button {
        font-size: 11px;
        padding: 5px 10px;
    }

    .vva-message-assistant .vva-quick-buttons {
        margin-left: 0;
        max-width: 100%;
    }
}
