/* css/shop_ai_chat.css - Стилі для Етапу 5 */

:root {
    --shop-primary: var(--color-theme, #1e3a5f);
    --shop-bg: #0a0f1c;
    --shop-surface: #1e293b;
    --shop-text: #e2e8f0;
    --shop-muted: #94a3b8;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--shop-bg);
    color: var(--shop-text);
    font-family: 'Inter', -apple-system, sans-serif;
    overflow: hidden;
}

/* === SPLASH SCREEN === */
.splash-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, var(--shop-bg) 0%, var(--shop-primary) 150%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}
.splash-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}
.splash-content {
    text-align: center;
    animation: bounceIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.splash-avatar-wrapper {
    width: 100px;
    height: 100px;
    margin: 0 auto 20px;
    border-radius: 50%;
    padding: 4px;
    background: linear-gradient(135deg, #fff, var(--shop-primary));
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}
.splash-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background: var(--shop-surface);
}
.splash-content h2 {
    margin: 0 0 15px 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.loader {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto 10px;
}
.splash-content p {
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
}

/* === CHAT CONTAINER === */
#ai-chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
}

.hidden { display: none !important; }

/* Шапка */
.chat-header {
    background: var(--shop-surface);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--shop-primary);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 10;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--shop-primary);
}
.header-info {
    display: flex;
    flex-direction: column;
}
.assistant-name {
    font-weight: 600;
    font-size: 1rem;
    color: #fff;
}
.online-status {
    font-size: 0.75rem;
    color: #4ade80;
    display: flex;
    align-items: center;
    gap: 4px;
}
.dot {
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 5px #4ade80;
}

.header-action {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--shop-text);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.header-action:hover {
    background: var(--shop-primary);
    border-color: var(--shop-primary);
}
.badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    font-weight: bold;
    padding: 2px 5px;
    border-radius: 10px;
    border: 2px solid var(--shop-surface);
}

/* Зона повідомлень */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}
.message {
    display: flex;
    gap: 10px;
    max-width: 90%;
    animation: fadeInUp 0.3s ease;
}
.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}
.message-content {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-break: break-word;
}
.ai-message .message-content {
    background: var(--shop-surface);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255,255,255,0.05);
}
.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.user-message .message-content {
    background: var(--shop-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.message.loading .message-content {
    opacity: 0.7;
}
.message-time {
    font-size: 0.65rem;
    color: var(--shop-muted, #94a3b8);
    margin-top: 4px;
}
.ai-message .message-time {
    text-align: left;
    margin-left: 4px;
}
.user-message .message-time {
    text-align: right;
    margin-right: 4px;
}

/* Прев'ю фото */
.image-preview {
    padding: 8px 16px;
    background: rgba(255,255,255,0.02);
    border-top: 1px solid rgba(255,255,255,0.05);
}
.file-preview-box {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--shop-surface);
    padding: 6px;
    border-radius: 8px;
    position: relative;
}
.file-preview-box img {
    height: 50px;
    border-radius: 4px;
}
.remove-img {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ef4444;
    color: #fff;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Зона вводу */
.chat-input-area {
    position: relative;
    padding: 10px 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    background: var(--shop-bg);
    border-top: 1px solid rgba(255,255,255,0.05);
}

/* Меню вкладень */
.attachment-menu {
    position: absolute;
    bottom: 100%;
    left: 16px;
    margin-bottom: 10px;
    background: var(--shop-surface);
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    display: flex;
    gap: 20px;
    z-index: 100;
    animation: fadeInUp 0.2s ease;
}
.attach-item {
    background: transparent;
    border: none;
    color: var(--shop-text);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0;
}
.attach-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--shop-primary);
    transition: background 0.2s;
}
.attach-item:hover .attach-icon {
    background: rgba(255,255,255,0.1);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--shop-surface);
    padding: 8px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.1);
}
.input-wrapper:focus-within {
    border-color: var(--shop-primary);
}
.input-action-btn {
    background: transparent;
    border: none;
    color: var(--shop-muted);
    font-size: 1.2rem;
    padding: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}
.input-action-btn:hover { color: #fff; }

#attach-btn i {
    transition: transform 0.3s ease;
}
#attach-btn.active i {
    transform: rotate(45deg);
}

#ai-user-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--shop-text);
    resize: none;
    outline: none;
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.4;
    max-height: 100px;
    padding: 6px 0;
}
#ai-user-input::placeholder { color: var(--shop-muted); }

#send-btn, #voice-input-btn {
    display: flex;
}
#send-btn.hidden, #voice-input-btn.hidden {
    display: none !important;
}

#send-btn {
    background: var(--shop-primary);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s;
}
#send-btn:active { transform: scale(0.9); }

.voice-btn.recording {
    color: #ef4444;
    animation: pulse 1.5s infinite;
}

/* Модальне вікно сканера */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
}
.modal-content {
    position: relative;
    background: var(--shop-surface);
    width: 100%;
    max-width: 400px;
    border-radius: 16px;
    overflow: hidden;
    z-index: 1001;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.modal-header h3 { margin: 0; font-size: 1.1rem; }
.close-btn { background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; padding: 0; line-height: 1; }

@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes bounceIn {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }

/* === CART MODAL === */
.cart-modal-content {
    display: flex;
    flex-direction: column;
    max-height: 90vh; /* Збільшено з 80vh для більшого простору */
}
.cart-scrollable-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.cart-items {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.cart-item {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.cart-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}
.cart-item-name {
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.3;
}
.cart-item-price {
    font-weight: bold;
    color: var(--shop-primary);
    white-space: nowrap;
}
.cart-item-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.cart-qty-wrapper {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    overflow: hidden;
}
.cart-qty-btn {
    background: transparent;
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.cart-qty-btn:active { background: rgba(255,255,255,0.1); }
.cart-qty-input {
    width: 40px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: bold;
    background: transparent;
    border: none;
    color: #fff;
    outline: none;
    -moz-appearance: textfield;
}
.cart-qty-input::-webkit-outer-spin-button,
.cart-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.cart-remove-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-delivery-info {
    padding: 12px 16px;
    background: rgba(74, 222, 128, 0.1);
    border-top: 1px solid rgba(74, 222, 128, 0.2);
    border-bottom: 1px solid rgba(74, 222, 128, 0.2);
    font-size: 0.9rem;
}
.delivery-title {
    font-weight: bold;
    color: #4ade80;
    margin-bottom: 4px;
}

.cart-footer {
    padding: 16px;
    background: rgba(255,255,255,0.02);
    border-top: 1px solid rgba(255,255,255,0.05);
}
.cart-total {
    font-size: 1.1rem;
    font-weight: bold;
    text-align: right;
    margin-bottom: 16px;
}
.cart-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.cart-btn-action {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s;
}
.cart-btn-action:active { transform: scale(0.98); }
.btn-delivery {
    background: rgba(255,255,255,0.1);
    color: #fff;
}
.btn-save {
    background: rgba(255,255,255,0.1);
    color: #fff;
}
.btn-checkout {
    background: var(--shop-primary);
    color: #fff;
}
.btn-clear {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    margin-top: 10px;
}

/* === AUTH BUTTONS === */
.auth-buttons-container {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-top: 1px solid rgba(255,255,255,0.05);
}
.auth-hint {
    font-size: 0.85rem;
    color: var(--shop-muted);
    text-align: center;
    margin: 0 0 8px 0;
}
.auth-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.telegram-btn {
    background: #2AABEE;
    color: #fff;
}
.google-btn {
    background: #fff;
    color: #757575;
    border: 1px solid #ddd;
}

/* === TOASTS === */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 90%;
    max-width: 400px;
}
.toast {
    background: var(--shop-surface);
    color: #fff;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    border-left: 4px solid #4ade80;
    animation: slideDown 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
}
.toast.fade-out {
    animation: slideUp 0.3s ease forwards;
}

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

/* === AI INTERACTIVE LIST === */
.ai-interactive-list {
    list-style: none;
    padding: 0;
    margin: 10px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ai-interactive-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.ai-interactive-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--shop-primary);
    transform: translateY(-1px);
}
.ai-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ai-item-name {
    font-weight: 500;
    font-size: 0.9rem;
}
.ai-item-price {
    font-weight: bold;
    color: #4ade80;
    font-size: 0.95rem;
    white-space: nowrap;
}

.new-chat-btn {
    position: relative;
}
.new-chat-btn i {
    font-size: 16px;
}
