/**
 * Support Widget Styles
 * Widget flottante non invasivo per supporto AI + ticketing
 */

/* Container principale */
.support-widget {
    position: fixed;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
}

.support-widget.bottom-right {
    bottom: 20px;
    right: 20px;
}

.support-widget.bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Floating Button */
.support-widget-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.support-widget-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(37, 99, 235, 0.5);
}

.support-widget-btn.active {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 4px 20px rgba(220, 38, 38, 0.4);
}

.support-widget-btn .support-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Panel */
.support-widget-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px;
    max-height: 520px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: supportSlideUp 0.3s ease;
}

.support-widget.bottom-left .support-widget-panel {
    right: auto;
    left: 0;
}

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

/* Header */
.support-widget-header {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.support-widget-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 16px;
}

.support-widget-title i {
    font-size: 20px;
}

.support-widget-actions {
    display: flex;
    gap: 8px;
}

.support-widget-actions button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.support-widget-actions button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Tabs */
.support-widget-tabs {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.support-tab {
    flex: 1;
    padding: 12px;
    background: #f9fafb;
    border: none;
    color: #6b7280;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.support-tab:hover {
    background: #f3f4f6;
}

.support-tab.active {
    background: white;
    color: #2563eb;
    font-weight: 600;
}

.support-tab i {
    font-size: 16px;
}

/* Tab content */
.support-tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.support-tab-content.active {
    display: flex;
}

/* Chat Messages */
.support-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: 300px;
}

.support-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    line-height: 1.5;
    animation: supportFadeIn 0.3s ease;
    word-wrap: break-word;
}

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

.support-message.user {
    align-self: flex-end;
    background: #2563eb;
    color: white;
    border-bottom-right-radius: 4px;
}

.support-message.ai {
    align-self: flex-start;
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}

.support-message.system {
    align-self: center;
    background: #fef3c7;
    color: #92400e;
    font-size: 12px;
    padding: 8px 12px;
}

/* Typing indicator */
.support-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #f3f4f6;
    border-radius: 12px;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.support-typing span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: supportTypingBounce 1.4s infinite ease-in-out;
}

.support-typing span:nth-child(1) { animation-delay: 0s; }
.support-typing span:nth-child(2) { animation-delay: 0.2s; }
.support-typing span:nth-child(3) { animation-delay: 0.4s; }

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

/* Chat Input */
.support-chat-input {
    display: flex;
    padding: 12px;
    border-top: 1px solid #e5e7eb;
    gap: 8px;
    flex-shrink: 0;
    background: white;
}

.support-chat-input input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    outline: none;
    font-size: 14px;
    transition: border-color 0.2s;
}

.support-chat-input input:focus {
    border-color: #2563eb;
}

.support-chat-input input::placeholder {
    color: #9ca3af;
}

#support-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #2563eb;
    border: none;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#support-send-btn:hover {
    background: #1d4ed8;
}

#support-send-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* Powered by */
.support-powered-by {
    text-align: center;
    padding: 8px;
    font-size: 11px;
    color: #9ca3af;
    border-top: 1px solid #f3f4f6;
    flex-shrink: 0;
}

/* Create Ticket Suggestion */
.support-create-ticket-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    margin: 0 16px 12px;
    background: #f3f4f6;
    border: 1px dashed #d1d5db;
    border-radius: 8px;
    color: #4b5563;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.support-create-ticket-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

/* Ticket Form */
.support-ticket-form {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.support-ticket-form .form-group {
    margin-bottom: 16px;
}

.support-ticket-form label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}

.support-ticket-form input,
.support-ticket-form select,
.support-ticket-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.support-ticket-form input:focus,
.support-ticket-form select:focus,
.support-ticket-form textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.support-ticket-form textarea {
    resize: vertical;
    min-height: 80px;
}

.support-submit-btn {
    width: 100%;
    padding: 12px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
}

.support-submit-btn:hover {
    background: #1d4ed8;
}

.support-submit-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* Success message */
.support-success {
    padding: 32px 24px;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.support-success-icon {
    width: 64px;
    height: 64px;
    background: #d1fae5;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.support-success-icon i {
    font-size: 32px;
    color: #10b981;
}

.support-success h4 {
    color: #1f2937;
    margin: 0 0 8px 0;
    font-size: 18px;
}

.support-success p {
    color: #6b7280;
    font-size: 14px;
    margin: 0 0 8px 0;
}

.support-success .ticket-number {
    font-size: 20px;
    font-weight: 700;
    color: #2563eb;
    font-family: monospace;
}

.support-success .back-btn {
    margin-top: 16px;
    padding: 10px 20px;
    background: #f3f4f6;
    border: none;
    border-radius: 8px;
    color: #4b5563;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.support-success .back-btn:hover {
    background: #e5e7eb;
}

/* Alert messages */
.support-alert {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
}

.support-alert.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.support-alert.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .support-widget-panel {
        width: calc(100vw - 32px);
        max-height: 70vh;
        bottom: 70px;
        right: 16px;
    }

    .support-widget.bottom-right {
        right: 16px;
        bottom: 16px;
    }

    .support-widget.bottom-left {
        left: 16px;
        bottom: 16px;
    }

    .support-widget.bottom-left .support-widget-panel {
        left: auto;
        right: 0;
    }

    .support-widget-btn {
        width: 52px;
        height: 52px;
        font-size: 22px;
    }

    .support-chat-messages {
        max-height: 200px;
    }
}

/* Hide widget on very small screens or when printing */
@media print {
    .support-widget {
        display: none !important;
    }
}
