/* ═══════════════════════════════════════════
   Amina Support Chat Widget v0.5.5
   Brand: #1a1a1a, #FFAD6C, white
   Button-driven flow (Mavenoid-style)
   ═══════════════════════════════════════════ */

#amina-chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #1a1a1a;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s ease, background .2s ease;
}
#amina-chat-toggle:hover { transform: scale(1.08); background: #2a2a2a; }
#amina-chat-toggle svg { width: 26px; height: 26px; fill: #FFAD6C; transition: transform .2s ease; }
#amina-chat-toggle.open svg { transform: rotate(90deg); }

/* ── Panel ── */
#amina-chat-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: 99998;
    width: 420px;
    max-width: calc(100vw - 32px);
    height: 70vh;
    min-height: 500px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0,0,0,.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(.96);
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
}
#amina-chat-panel.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Header ── */
.amina-chat-header {
    background: #1a1a1a;
    color: #fff;
    padding: 16px 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.amina-chat-header .amina-dot {
    width: 8px; height: 8px; border-radius: 50%; background: #4ade80; flex-shrink: 0;
}

/* ── Messages area ── */
.amina-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}
.amina-chat-messages::-webkit-scrollbar { width: 4px; }
.amina-chat-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* ── Bubbles ── */
.amina-msg {
    max-width: 90%;
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
}
.amina-msg.assistant {
    background: #f3f4f6;
    color: #1a1a1a;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.amina-msg.user {
    background: #1a1a1a;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.amina-msg a { color: #FFAD6C; text-decoration: underline; }

/* ── Product image cards ── */
.amina-product-images {
    display: flex;
    gap: 10px;
    padding: 4px 0;
    overflow-x: auto;
    align-self: flex-start;
}
.amina-product-card {
    flex: 0 0 auto;
    width: 120px;
    background: #f8f8f8;
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    border: 1.5px solid #e5e7eb;
}
.amina-product-card img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 6px;
}
.amina-product-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #1a1a1a;
}

/* ── Button group (clickable options) ── */
.amina-button-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-self: flex-start;
    width: 100%;
    max-width: 95%;
}
.amina-choice-btn {
    display: block;
    width: 100%;
    text-align: left;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    color: #1a1a1a;
    cursor: pointer;
    transition: border-color .15s, background .15s, transform .1s;
}
.amina-choice-btn:hover {
    border-color: #FFAD6C;
    background: #fff8f0;
}
.amina-choice-btn:active {
    transform: scale(0.98);
}
.amina-choice-btn:disabled {
    opacity: .45;
    cursor: default;
    background: #f9fafb;
    border-color: #e5e7eb;
}
/* Dim used button groups */
.amina-buttons-used {
    opacity: .5;
    pointer-events: none;
}
.amina-buttons-used .amina-choice-btn {
    cursor: default;
}

/* ── Image buttons (product selection) ── */
.amina-choice-btn-img {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
}
.amina-choice-btn-img img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 6px;
    background: #f8f8f8;
}
.amina-choice-btn-img span {
    font-size: 14px;
    font-weight: 500;
}

/* ── Typing indicator ── */
.amina-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    align-self: flex-start;
}
.amina-typing span {
    width: 7px; height: 7px; border-radius: 50%; background: #9ca3af;
    animation: amina-bounce .6s infinite alternate;
}
.amina-typing span:nth-child(2) { animation-delay: .15s; }
.amina-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes amina-bounce { to { transform: translateY(-4px); opacity: .5; } }

/* ── Input area (hidden by default, shown on "Something else") ── */
.amina-chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    background: #fff;
    transition: opacity .2s;
}
.amina-chat-input-area.amina-hidden {
    display: none;
}
.amina-chat-input-area input {
    flex: 1;
    border: 1.5px solid #e5e7eb;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
}
.amina-chat-input-area input:focus { border-color: #FFAD6C; }
.amina-chat-input-area button {
    width: 40px; height: 40px; border-radius: 50%; background: #1a1a1a;
    border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: background .15s;
}
.amina-chat-input-area button:hover { background: #333; }
.amina-chat-input-area button svg { width: 18px; height: 18px; fill: #FFAD6C; }
.amina-chat-input-area button:disabled { opacity: .4; cursor: not-allowed; }

/* ── Escalation form ── */
.amina-escalation-form {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #fefce8;
    border-radius: 12px;
    border: 1px solid #fde68a;
    align-self: flex-start;
    width: 100%;
    max-width: 95%;
}
.amina-escalation-form label {
    font-size: 12px; font-weight: 600; color: #1a1a1a;
}
.amina-escalation-form input {
    border: 1.5px solid #d1d5db; border-radius: 8px; padding: 8px 12px;
    font-size: 14px; width: 100%; box-sizing: border-box;
}
.amina-escalation-form button {
    background: #1a1a1a; color: #fff; border: none; border-radius: 8px;
    padding: 10px; font-size: 14px; font-weight: 600; cursor: pointer;
    transition: background .15s;
}
.amina-escalation-form button:hover { background: #333; }
.amina-escalation-form button:disabled { opacity: .5; cursor: not-allowed; }

/* ── Mobile ── */
@media (max-width: 480px) {
    #amina-chat-panel {
        bottom: 0; right: 0; width: 100vw; height: 100vh;
        max-height: 100vh; border-radius: 0;
    }
    #amina-chat-toggle { bottom: 16px; right: 16px; }
    .amina-product-card { width: 100px; }
    .amina-product-card img { width: 60px; height: 60px; }
}

/* ═══════════════════════════════════════════
   v0.5.5 additions: AI disclosure badge + privacy footer
   ═══════════════════════════════════════════ */

/* "AI" badge in header — required signal under EU AI Act Art. 50 */
.amina-ai-badge {
    margin-left: auto;
    background: rgba(255, 173, 108, 0.18);
    color: #FFAD6C;
    border: 1px solid rgba(255, 173, 108, 0.4);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    line-height: 1.4;
    cursor: help;
}

/* Privacy footer at bottom of chat panel */
.amina-chat-footer {
    padding: 8px 16px;
    border-top: 1px solid #e5e7eb;
    background: #fafafa;
    flex-shrink: 0;
    font-size: 11px;
    text-align: center;
    line-height: 1.4;
}
.amina-chat-footer a {
    color: #6b7280;
    text-decoration: none;
}
.amina-chat-footer a:hover {
    color: #1a1a1a;
    text-decoration: underline;
}

/* ═══════════════════════════════════════════
   v0.5.6 additions: animations + chat label + selected state + cancel button
   ═══════════════════════════════════════════ */

/* ─── Floating "amina support" label next to toggle ─── */
#amina-chat-label {
    position: fixed;
    bottom: 32px;
    right: 92px;
    z-index: 99998;
    background: #1a1a1a;
    color: #fff;
    border: none;
    padding: 10px 16px 10px 14px;
    border-radius: 22px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    opacity: 0;
    transform: translateX(20px) scale(0.92);
    transition: opacity .35s ease, transform .35s ease, background .2s ease;
    white-space: nowrap;
    line-height: 1;
}
#amina-chat-label.amina-show {
    opacity: 1;
    transform: translateX(0) scale(1);
}
#amina-chat-label:hover { background: #2a2a2a; }
#amina-chat-label:active { transform: translateX(0) scale(0.97); transition: transform .08s ease; }
#amina-chat-label .amina-label-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    flex-shrink: 0;
    animation: amina-dot-pulse 2.4s ease-in-out infinite;
}
@keyframes amina-dot-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55); }
    50%      { box-shadow: 0 0 0 7px rgba(74, 222, 128, 0); }
}
/* On phones, hide the label to save space (icon alone is enough) */
@media (max-width: 480px) {
    #amina-chat-label { display: none; }
}

/* ─── Toggle button: entrance bounce + click feedback ─── */
#amina-chat-toggle {
    animation: amina-toggle-in .5s cubic-bezier(.34, 1.56, .64, 1) .2s both;
}
@keyframes amina-toggle-in {
    from { opacity: 0; transform: scale(0); }
    to   { opacity: 1; transform: scale(1); }
}
#amina-chat-toggle:active {
    transform: scale(0.94);
    transition: transform .08s ease;
}

/* ─── Panel: a touch more spring on open ─── */
#amina-chat-panel {
    transition: opacity .25s ease, transform .35s cubic-bezier(.34, 1.35, .64, 1);
}

/* ─── AI badge: subtle entrance ─── */
.amina-ai-badge {
    animation: amina-fade-in .4s ease .3s both;
}

/* ─── Header status dot: gentle pulse ─── */
.amina-chat-header .amina-dot {
    animation: amina-dot-pulse 2.4s ease-in-out infinite;
}

/* ─── Message bubble entrance ─── */
.amina-msg.assistant,
.amina-msg.user,
.amina-product-images,
.amina-typing,
.amina-escalation-form {
    animation: amina-msg-in .3s ease both;
}
@keyframes amina-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── Button group: stagger fade-in ─── */
.amina-button-group .amina-choice-btn {
    animation: amina-btn-in .3s ease both;
}
.amina-button-group .amina-choice-btn:nth-child(1) { animation-delay: .04s; }
.amina-button-group .amina-choice-btn:nth-child(2) { animation-delay: .08s; }
.amina-button-group .amina-choice-btn:nth-child(3) { animation-delay: .12s; }
.amina-button-group .amina-choice-btn:nth-child(4) { animation-delay: .16s; }
.amina-button-group .amina-choice-btn:nth-child(5) { animation-delay: .20s; }
.amina-button-group .amina-choice-btn:nth-child(6) { animation-delay: .24s; }
.amina-button-group .amina-choice-btn:nth-child(7) { animation-delay: .28s; }
.amina-button-group .amina-choice-btn:nth-child(8) { animation-delay: .32s; }
.amina-button-group .amina-choice-btn:nth-child(9) { animation-delay: .36s; }
.amina-button-group .amina-choice-btn:nth-child(n+10) { animation-delay: .40s; }
@keyframes amina-btn-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── Choice button: smoother transitions, stronger press ─── */
.amina-choice-btn {
    transition: border-color .15s, background .15s, color .15s, transform .1s, opacity .25s;
}
.amina-choice-btn:active:not(:disabled) {
    transform: scale(.97);
}

/* ─── Selected state: confirms the choice the user made ─── */
.amina-choice-btn.amina-choice-selected {
    background: #1a1a1a !important;
    color: #fff !important;
    border-color: #1a1a1a !important;
    opacity: 1 !important;
    cursor: default;
    animation: amina-choice-confirm .35s ease;
}
.amina-choice-btn.amina-choice-selected:hover {
    background: #1a1a1a !important;
    border-color: #1a1a1a !important;
}
@keyframes amina-choice-confirm {
    0%   { transform: scale(1); }
    45%  { transform: scale(.96); }
    100% { transform: scale(1); }
}
/* When a group has been used, the selected button stays solid even though the group is dimmed */
.amina-buttons-used { opacity: 1; }
.amina-buttons-used .amina-choice-btn:not(.amina-choice-selected) { opacity: .45; }

/* ─── Cancel (×) button on input area ─── */
#amina-input-cancel {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid #e5e7eb;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #6b7280;
    padding: 0;
    transition: background .15s, border-color .15s, color .15s, transform .08s ease;
}
#amina-input-cancel:hover {
    background: #f3f4f6;
    color: #1a1a1a;
    border-color: #d1d5db;
}
#amina-input-cancel:active {
    transform: scale(.92);
}
#amina-input-cancel svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

/* ─── Send button: press feedback ─── */
#amina-send {
    transition: background .2s, transform .08s ease;
}
#amina-send:active {
    transform: scale(.94);
}

/* ─── Generic helpers ─── */
@keyframes amina-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ─── Respect prefers-reduced-motion ─── */
@media (prefers-reduced-motion: reduce) {
    #amina-chat-toggle,
    .amina-msg.assistant,
    .amina-msg.user,
    .amina-product-images,
    .amina-typing,
    .amina-escalation-form,
    .amina-button-group .amina-choice-btn,
    .amina-ai-badge,
    .amina-chat-header .amina-dot,
    #amina-chat-label .amina-label-dot,
    .amina-choice-btn.amina-choice-selected {
        animation: none !important;
    }
    #amina-chat-toggle, #amina-chat-label.amina-show {
        opacity: 1 !important;
        transform: none !important;
    }
}
