/**
 * VoiceCart - Estilos principales
 * Design moderno, accesible y mobile-first
 */

/* ===========================
   Variables CSS
   =========================== */
:root {
    --voicecart-primary: #6366f1;
    --voicecart-primary-dark: #4f46e5;
    --voicecart-success: #10b981;
    --voicecart-error: #ef4444;
    --voicecart-warning: #f59e0b;
    --voicecart-white: #ffffff;
    --voicecart-black: #1f2937;
    --voicecart-gray-100: #f3f4f6;
    --voicecart-gray-200: #e5e7eb;
    --voicecart-gray-300: #d1d5db;
    --voicecart-gray-700: #374151;
    --voicecart-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --voicecart-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --voicecart-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --voicecart-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --voicecart-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===========================
   Reset y Base
   =========================== */
.voicecart-btn,
.voicecart-fab,
#voicecart-panel * {
    box-sizing: border-box;
}

/* ===========================
   Botón Inline (Shortcode)
   =========================== */
.voicecart-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    color: var(--voicecart-white);
    background: linear-gradient(135deg, var(--voicecart-primary) 0%, var(--voicecart-primary-dark) 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--voicecart-transition);
    box-shadow: var(--voicecart-shadow-md);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.voicecart-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--voicecart-shadow-lg);
}

.voicecart-btn:active {
    transform: translateY(0);
}

.voicecart-btn.listening {
    background: linear-gradient(135deg, var(--voicecart-error) 0%, #dc2626 100%);
    animation: pulse 1.5s ease-in-out infinite;
}

.voicecart-icon {
    font-size: 20px;
    animation: bounce 2s ease-in-out infinite;
}

/* Tamaños de botón */
.voicecart-btn-small {
    padding: 8px 16px;
    font-size: 14px;
}

.voicecart-btn-large {
    padding: 16px 32px;
    font-size: 18px;
}

/* ===========================
   Widget Flotante
   =========================== */
#voicecart-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

/* Botón FAB */
.voicecart-fab {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--voicecart-primary) 0%, var(--voicecart-primary-dark) 100%);
    border: none;
    cursor: pointer;
    box-shadow: var(--voicecart-shadow-xl);
    transition: var(--voicecart-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.voicecart-fab::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.5s ease;
}

.voicecart-fab:hover::before {
    transform: translate(-50%, -50%) scale(1.5);
}

.voicecart-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.voicecart-fab.active {
    background: linear-gradient(135deg, var(--voicecart-primary-dark) 0%, var(--voicecart-primary) 100%);
}

.voicecart-fab.listening {
    animation: pulse 1.5s ease-in-out infinite;
}

.voicecart-fab-icon {
    font-size: 28px;
    z-index: 1;
}

/* Badge de contador */
.voicecart-cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--voicecart-error);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: scaleIn 0.3s ease;
}

/* ===========================
   Panel Principal
   =========================== */
.voicecart-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    background: var(--voicecart-white);
    border-radius: 16px;
    box-shadow: var(--voicecart-shadow-xl);
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

/* Header del panel */
.voicecart-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--voicecart-primary) 0%, var(--voicecart-primary-dark) 100%);
    color: var(--voicecart-white);
}

.voicecart-panel-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.voicecart-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    transition: var(--voicecart-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.voicecart-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Body del panel */
.voicecart-panel-body {
    padding: 24px;
}

/* ===========================
   Estado y Animación
   =========================== */
.voicecart-status {
    text-align: center;
    padding: 32px 16px;
    cursor: pointer;
    border-radius: 12px;
    transition: var(--voicecart-transition);
    margin-bottom: 20px;
    background: var(--voicecart-gray-100);
}

.voicecart-status:hover {
    background: var(--voicecart-gray-200);
}

.voicecart-status.listening {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(79, 70, 229, 0.1) 100%);
}

.voicecart-status.processing {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(217, 119, 6, 0.1) 100%);
}

.voicecart-status.error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(220, 38, 38, 0.1) 100%);
}

.voicecart-status.success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(5, 150, 105, 0.1) 100%);
}

/* Animación de pulso */
.voicecart-animation {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
}

.voicecart-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--voicecart-primary);
}

.voicecart-status.listening .voicecart-pulse {
    animation: pulseRing 1.5s ease-out infinite;
}

.voicecart-status.processing .voicecart-pulse {
    background: var(--voicecart-warning);
    animation: spin 1s linear infinite;
}

.voicecart-status-text {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    color: var(--voicecart-gray-700);
}

/* ===========================
   Transcripción
   =========================== */
.voicecart-transcript {
    background: var(--voicecart-gray-100);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: none;
    animation: fadeIn 0.3s ease;
}

.voicecart-transcript p {
    margin: 0;
    color: var(--voicecart-gray-700);
    font-size: 14px;
}

.voicecart-transcript strong {
    color: var(--voicecart-black);
}

/* ===========================
   Producto agregado
   =========================== */
.voicecart-product-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--voicecart-white);
    padding: 16px;
    border-radius: 12px;
    border: 2px solid var(--voicecart-success);
    animation: scaleIn 0.3s ease;
}

.voicecart-product-card img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
}

.voicecart-product-info h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--voicecart-black);
}

.voicecart-product-info .price {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--voicecart-success);
}

/* ===========================
   Sugerencias
   =========================== */
.voicecart-suggestions {
    background: var(--voicecart-gray-100);
    padding: 16px;
    border-radius: 12px;
    font-size: 13px;
}

.voicecart-suggestions p {
    margin: 0 0 8px 0;
    color: var(--voicecart-gray-700);
}

.voicecart-suggestions ul {
    margin: 0;
    padding-left: 20px;
}

.voicecart-suggestions li {
    color: var(--voicecart-gray-700);
    margin-bottom: 4px;
    font-style: italic;
}

/* ===========================
   Notificaciones Toast
   =========================== */
.voicecart-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 400px;
    background: var(--voicecart-white);
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: var(--voicecart-shadow-xl);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    transform: translateX(calc(100% + 40px));
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.voicecart-notification.show {
    transform: translateX(0);
}

.voicecart-notification-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    flex-shrink: 0;
}

.voicecart-notification-success .voicecart-notification-icon {
    background: var(--voicecart-success);
    color: white;
}

.voicecart-notification-error .voicecart-notification-icon {
    background: var(--voicecart-error);
    color: white;
}

.voicecart-notification-info .voicecart-notification-icon {
    background: var(--voicecart-primary);
    color: white;
}

.voicecart-notification-message {
    flex: 1;
    font-size: 14px;
    color: var(--voicecart-black);
}

/* ===========================
   Animaciones
   =========================== */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@keyframes pulseRing {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

@keyframes spin {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===========================
   Responsive Design
   =========================== */
@media (max-width: 768px) {
    #voicecart-widget {
        bottom: 16px;
        right: 16px;
    }

    .voicecart-fab {
        width: 56px;
        height: 56px;
    }

    .voicecart-fab-icon {
        font-size: 24px;
    }

    .voicecart-panel {
        width: calc(100vw - 32px);
        bottom: 76px;
    }

    .voicecart-notification {
        top: 16px;
        right: 16px;
        left: 16px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .voicecart-panel-body {
        padding: 16px;
    }

    .voicecart-status {
        padding: 24px 12px;
    }

    .voicecart-animation {
        width: 60px;
        height: 60px;
    }

    .voicecart-pulse {
        width: 48px;
        height: 48px;
    }
}

/* ===========================
   Accesibilidad
   =========================== */
.voicecart-btn:focus,
.voicecart-fab:focus,
.voicecart-close:focus {
    outline: 3px solid var(--voicecart-primary);
    outline-offset: 2px;
}

/* Reducir animaciones para usuarios que lo prefieren */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Alto contraste */
@media (prefers-contrast: high) {
    .voicecart-btn,
    .voicecart-fab {
        border: 2px solid currentColor;
    }
}

/* Modo oscuro */
@media (prefers-color-scheme: dark) {
    :root {
        --voicecart-white: #1f2937;
        --voicecart-black: #f9fafb;
        --voicecart-gray-100: #374151;
        --voicecart-gray-200: #4b5563;
        --voicecart-gray-700: #e5e7eb;
    }

    .voicecart-panel {
        border: 1px solid var(--voicecart-gray-200);
    }

    .voicecart-notification {
        border: 1px solid var(--voicecart-gray-200);
    }
}