/* ============================================
   IAAPPER Widget — Complete Redesign CSS
   Large Modal with Tab System + Avatar Badge
   ============================================ */

/* Avatar Badge (bottom-right) - ALWAYS ON TOP */
.iaapper-badge {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10001;  /* Higher than modal to always stay visible */
}

.iaapper-avatar-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
    color: white;
    border: 3px solid white;
    cursor: pointer;
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    transition: all 0.3s ease;
    position: relative;
    padding: 0;
    overflow: hidden;
}

.iaapper-avatar-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.iaapper-avatar-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.iaapper-avatar-btn:active {
    transform: scale(0.95);
}

/* Badge Notification Count */
.iaapper-badge-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
}

/* Modal Overlay */
.iaapper-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9998;  /* Lower than avatar (10001) */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.iaapper-modal.iaapper-modal-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.iaapper-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    cursor: pointer;
    z-index: 1;  /* Inside modal container */
}

/* Modal Content */
.iaapper-modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    max-height: 60vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    z-index: 2;  /* Above overlay */
}

/* Fullscreen mode — slightly larger but not overwhelming */
.iaapper-modal-content.iaapper-fullscreen {
    width: 92%;
    max-width: 460px;
    max-height: 65vh;
    border-radius: 8px;
}

/* Header Blu */
.iaapper-modal-header {
    background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.iaapper-header-info {
    display: flex;
    gap: 15px;
    flex: 1;
}

.iaapper-logo {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    overflow: hidden;
    border: 2px solid white;
}

.iaapper-modal-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.iaapper-user-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.iaapper-header-text h5 {
    margin: 0 0 5px 0;
    font-size: 16px;
    font-weight: 600;
}

.iaapper-header-text p {
    margin: 0;
    font-size: 13px;
    opacity: 0.9;
}

.iaapper-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.iaapper-close-btn:hover {
    opacity: 1;
}

/* Tab Navigation */
.iaapper-tabs {
    display: flex;
    border-bottom: 2px solid #e5e7eb;
    background: #f9fafb;
}

.iaapper-tab-btn {
    flex: 1;
    padding: 15px 10px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    transition: all 0.3s ease;
    position: relative;
}

.iaapper-tab-btn:hover {
    color: #3b82f6;
    background: #f3f4f6;
}

.iaapper-tab-btn.iaapper-tab-active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
}

.iaapper-badge-label {
    font-size: 12px;
    color: #ef4444;
    font-weight: bold;
}

/* Tab Content */
.iaapper-tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.iaapper-tab-pane {
    display: none;
}

.iaapper-tab-pane.iaapper-tab-active {
    display: block;
}

/* Actions List */
.iaapper-actions-list {
    display: grid;
    gap: 12px;
}

.iaapper-action-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid #e5e7eb;
    background: white;
}

.iaapper-action-item:hover {
    background: #f9fafb;
    border-color: #3b82f6;
    transform: translateX(4px);
}

.iaapper-action-icon {
    width: 45px;
    height: 45px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    flex-shrink: 0;
}

.iaapper-action-icon.bg-danger {
    background: #ef4444;
}

.iaapper-action-icon.bg-primary {
    background: #3b82f6;
}

.iaapper-action-icon.bg-success {
    background: #10b981;
}

.iaapper-action-icon.bg-warning {
    background: #f59e0b;
}

.iaapper-action-icon.bg-info {
    background: #0ea5e9;
}

.iaapper-action-text h6 {
    margin: 0 0 3px 0;
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}

.iaapper-action-text p {
    margin: 0;
    font-size: 12px;
    color: #6b7280;
}

/* FAQ Container */
.iaapper-faq-container .accordion {
    border: none;
}

.iaapper-faq-container .accordion-item {
    border: 1px solid #e5e7eb;
    margin-bottom: 8px;
    border-radius: 6px;
}

.iaapper-faq-container .accordion-button {
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
}

.iaapper-faq-container .accordion-button:not(.collapsed) {
    background: #f3f4f6;
    color: #3b82f6;
}

.iaapper-faq-container .accordion-body {
    padding: 12px;
    font-size: 13px;
    color: #4b5563;
}

/* Search Box */
.iaapper-search-box {
    display: flex;
    gap: 8px;
    padding: 15px 20px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.iaapper-search-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: border 0.2s;
}

.iaapper-search-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.iaapper-search-btn {
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.iaapper-search-btn:hover {
    background: #2563eb;
}

/* Chat Interface */
.iaapper-chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.iaapper-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.iaapper-chat-message {
    display: flex;
    gap: 10px;
    animation: slideIn 0.3s ease-out;
}

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

.iaapper-chat-message.user {
    justify-content: flex-end;
}

.iaapper-message-bubble {
    max-width: 85%;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
    word-wrap: break-word;
}

.iaapper-message-bubble.user {
    background: #3b82f6;
    color: white;
    border-radius: 8px 2px 8px 8px;
}

.iaapper-message-bubble.ai {
    background: #e5e7eb;
    color: #1f2937;
    border-radius: 2px 8px 8px 8px;
}

.iaapper-message-bubble.system {
    background: #fef3c7;
    color: #92400e;
    font-size: 12px;
    font-style: italic;
    text-align: center;
    max-width: 100%;
}

.iaapper-chat-input-area {
    border-top: 1px solid #e5e7eb;
    padding: 12px;
    background: white;
    display: flex;
    gap: 8px;
}

.iaapper-chat-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    resize: none;
    max-height: 80px;
    outline: none;
    transition: border 0.2s;
}

.iaapper-chat-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.iaapper-chat-send-btn {
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.iaapper-chat-send-btn:hover:not(:disabled) {
    background: #2563eb;
}

.iaapper-chat-send-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    opacity: 0.5;
}

.iaapper-chat-loading {
    display: flex;
    gap: 4px;
    align-items: center;
}

.iaapper-chat-loading span {
    width: 6px;
    height: 6px;
    background: #3b82f6;
    border-radius: 50%;
    animation: pulse 1.4s infinite;
}

.iaapper-chat-loading span:nth-child(2) {
    animation-delay: 0.2s;
}

.iaapper-chat-loading span:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* Footer */
.iaapper-modal-footer {
    text-align: center;
    padding: 10px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    font-size: 11px;
    color: #9ca3af;
}

/* LEARNY Zoom Modal */
.iaapper-learny-zoom-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

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

.iaapper-learny-zoom-container {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.iaapper-learny-zoom-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    max-width: 600px;
    max-height: 600px;
}

.iaapper-learny-zoom-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 28px;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
    z-index: 10003;
}

.iaapper-learny-zoom-close:hover {
    background: #f3f4f6;
    transform: scale(1.1);
}

/* Responsive */
@media (max-width: 600px) {
    .iaapper-modal-content {
        width: 92%;
        max-width: 95%;
        max-height: 85vh;
    }

    .iaapper-avatar-btn {
        width: 70px;
        height: 70px;
        font-size: 24px;
    }

    .iaapper-header-text h5 {
        font-size: 14px;
    }

    .iaapper-header-text p {
        font-size: 12px;
    }

    .iaapper-tab-btn {
        font-size: 12px;
        padding: 12px 8px;
    }

    .iaapper-action-item {
        padding: 10px 12px;
    }

    .iaapper-action-icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .iaapper-action-text h6 {
        font-size: 13px;
    }

    .iaapper-action-text p {
        font-size: 11px;
    }
}
