﻿/**
 * Tryoshop Asistan - Frontend CSS
 * Admin onizleme ile birebir uyumlu
 */

/* TEMA OVERRIDE - Tum butonlar icin */
.ts-assistant-widget button,
.ts-assistant-widget [type="button"],
.ts-assistant-widget [type="submit"] {
    all: unset;
    box-sizing: border-box;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* CSS VARIABLES */
.ts-assistant-widget {
    --ts-primary: #667eea;
    --ts-secondary: #764ba2;
    --ts-gradient: linear-gradient(135deg, var(--ts-primary) 0%, var(--ts-secondary) 100%);
    --ts-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    --ts-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* WIDGET CONTAINER */
.ts-assistant-widget {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
    font-family: var(--ts-font);
    font-size: 14px;
    line-height: 1.5;
}

.ts-assistant-widget *,
.ts-assistant-widget *::before,
.ts-assistant-widget *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.ts-assistant-widget.ts-position-right { right: 24px; }
.ts-assistant-widget.ts-position-left { left: 24px; }

/* =====================================
   LAUNCHER BUTTON
   ===================================== */
.ts-assistant-launcher {
    width: 60px;
    height: 60px;
    border-radius: 50% !important;
    background: var(--ts-gradient) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4) !important;
    transition: all 0.3s ease;
    position: relative;
    border: none !important;
    padding: 16px !important;
}

.ts-assistant-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 32px rgba(102, 126, 234, 0.5) !important;
}

.ts-launcher-icon {
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ts-launcher-icon svg {
    width: 28px;
    height: 28px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

/* =====================================
   CHAT WINDOW
   ===================================== */
.ts-assistant-window {
    position: absolute;
    bottom: 76px;
    width: 320px;
    max-width: calc(100vw - 48px);
    background: #fff;
    border-radius: 20px;
    box-shadow: var(--ts-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.ts-assistant-window.ts-open { display: flex; }

.ts-position-right .ts-assistant-window { right: 0; }
.ts-position-left .ts-assistant-window { left: 0; }

/* =====================================
   HEADER
   ===================================== */
.ts-assistant-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
    background: var(--ts-gradient);
    color: #fff;
    position: relative;
}

.ts-assistant-header-info {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 0;
}

.ts-assistant-avatar {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.3);
}

.ts-assistant-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ts-assistant-avatar-default svg {
    width: 22px;
    height: 22px;
    color: #fff;
}

.ts-assistant-header-text {
    flex: 1;
    min-width: 0;
}

.ts-assistant-name {
    font-weight: 700;
    font-size: 15px;
    margin: 0;
    padding: 0;
}

.ts-assistant-status {
    font-size: 11px;
    opacity: 0.95;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0;
}

.ts-status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
}

/* Close Button */
.ts-assistant-close {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.2) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #fff !important;
    transition: background 0.2s;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    flex-shrink: 0;
}

.ts-assistant-close:hover {
    background: rgba(255, 255, 255, 0.3) !important;
}

.ts-assistant-close svg {
    width: 16px;
    height: 16px;
}

/* =====================================
   MESSAGES AREA
   ===================================== */
.ts-assistant-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    min-height: 350px;
    max-height: 420px;
}

.ts-assistant-messages::-webkit-scrollbar { width: 4px; }
.ts-assistant-messages::-webkit-scrollbar-track { background: transparent; }
.ts-assistant-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

/* =====================================
   MESSAGE BUBBLES
   ===================================== */
.ts-message {
    display: flex;
    gap: 10px;
    max-width: 90%;
}

.ts-message-bot { align-self: flex-start; }
.ts-message-user { align-self: flex-end; flex-direction: row-reverse; }

.ts-message-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background: var(--ts-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    overflow: hidden;
    flex-shrink: 0;
}

.ts-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ts-message-avatar svg {
    width: 16px;
    height: 16px;
}

.ts-message-user .ts-message-avatar { display: none; }

.ts-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
}

.ts-message-bot .ts-message-content {
    background: #fff;
    color: #334155;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.ts-message-user .ts-message-content {
    background: var(--ts-gradient);
    color: #fff;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.ts-message-content p { margin: 0 0 8px; }
.ts-message-content p:last-child { margin-bottom: 0; }

/* Typing Indicator */
.ts-typing-content {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 18px !important;
}

.ts-typing-dot {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: ts-typing 1.2s ease-in-out infinite;
}

.ts-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.ts-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes ts-typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* =====================================
   QUICK ACTIONS
   ===================================== */
.ts-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
    margin-top: 4px;
}

.ts-quick-action {
    padding: 10px 16px !important;
    background: #fff !important;
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 20px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    color: #475569 !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    line-height: 1.3 !important;
    white-space: nowrap !important;
}

.ts-quick-action:hover {
    border-color: var(--ts-primary) !important;
    color: var(--ts-primary) !important;
    background: rgba(102, 126, 234, 0.05) !important;
    transform: translateY(-1px);
}

/* =====================================
   INPUT AREA
   ===================================== */
.ts-assistant-input-area {
    display: flex;
    align-items: center;
    padding: 16px;
    gap: 10px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

.ts-assistant-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.ts-assistant-input {
    flex: 1;
    min-width: 0;
    padding: 12px 18px !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 24px !important;
    font-size: 13px !important;
    font-family: inherit !important;
    outline: none !important;
    background: #f8fafc !important;
    color: #1e293b !important;
    transition: border-color 0.2s, background 0.2s !important;
    line-height: 1.4 !important;
    height: auto !important;
    min-height: 42px !important;
}

.ts-assistant-input:focus {
    border-color: var(--ts-primary) !important;
    background: #fff !important;
}

.ts-assistant-input::placeholder {
    color: #64748b !important;
}

/* Send Button */
.ts-assistant-send {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    border-radius: 50% !important;
    background: var(--ts-gradient) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #fff !important;
    transition: opacity 0.2s, transform 0.2s !important;
    flex-shrink: 0 !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3) !important;
    border: none !important;
    padding: 0 !important;
    cursor: pointer !important;
}

.ts-assistant-send:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.ts-assistant-send svg {
    width: 18px;
    height: 18px;
}

.ts-assistant-powered {
    display: none;
}

/* =====================================
   ORDER FORM
   ===================================== */
.ts-form-intro {
    font-size: 13px;
    color: #475569;
    margin-bottom: 12px;
    font-weight: 500;
}

.ts-order-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ts-order-form .ts-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ts-order-form label {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
}

.ts-order-form input {
    padding: 12px 14px !important;
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 12px !important;
    font-size: 14px !important;
    font-family: inherit !important;
    outline: none !important;
    transition: border-color 0.2s !important;
    background: #fff !important;
    color: #1e293b !important;
}

.ts-order-form input:focus {
    border-color: var(--ts-primary) !important;
}

.ts-order-form input::placeholder {
    color: #94a3b8 !important;
}

.ts-order-submit {
    padding: 12px 16px !important;
    background: var(--ts-gradient) !important;
    color: #fff !important;
    border-radius: 12px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    transition: opacity 0.2s !important;
    margin-top: 4px;
    border: none !important;
    cursor: pointer !important;
}

.ts-order-submit:hover { opacity: 0.9; }

/* =====================================
   ORDER DETAILS CARD
   ===================================== */
.ts-order-detail-card {
    background: #f8fafc;
    border-radius: 14px;
    padding: 14px;
    margin-top: 10px;
    border: 1px solid #e2e8f0;
}

.ts-order-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e2e8f0;
}

.ts-order-detail-id {
    font-weight: 700;
    font-size: 14px;
    color: #1e293b;
}

.ts-order-detail-status {
    padding: 5px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.ts-status-pending { background: #fef3c7; color: #92400e; }
.ts-status-processing { background: #dbeafe; color: #1e40af; }
.ts-status-on-hold { background: #f3e8ff; color: #6b21a8; }
.ts-status-completed { background: #d1fae5; color: #065f46; }
.ts-status-cancelled, .ts-status-failed { background: #fee2e2; color: #991b1b; }
.ts-status-shipped { background: #cffafe; color: #0e7490; }

.ts-order-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.ts-order-item {
    display: flex;
    gap: 10px;
    padding: 8px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.ts-item-image {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 8px;
    overflow: hidden;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ts-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ts-item-no-image { font-size: 20px; }

.ts-item-info { flex: 1; min-width: 0; }

.ts-item-name {
    font-weight: 600;
    font-size: 13px;
    color: #1e293b;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ts-item-meta {
    font-size: 12px;
    color: #64748b;
}

.ts-order-summary {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 10px;
    border-top: 1px solid #e2e8f0;
}

.ts-order-summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #64748b;
}

.ts-order-summary-row strong {
    color: #1e293b;
    font-weight: 700;
}

.ts-tracking-row {
    background: #f0fdf4;
    margin: 6px -14px;
    padding: 8px 14px;
}

.ts-tracking-number {
    font-family: monospace;
    font-weight: 600;
    color: #059669;
}

.ts-tracking-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #fff;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    margin-top: 8px;
    transition: opacity 0.2s;
}

.ts-tracking-link:hover { opacity: 0.9; }

/* =====================================
   WHATSAPP BUTTON
   ===================================== */
.ts-whatsapp-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 18px;
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    color: #fff;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    width: 100%;
    margin-top: 10px;
    transition: opacity 0.2s;
}

.ts-whatsapp-btn:hover { opacity: 0.9; }

.ts-whatsapp-btn svg {
    width: 20px;
    height: 20px;
}

/* =====================================
   MOBILE STYLES
   ===================================== */
@media (max-width: 480px) {
    .ts-assistant-widget { bottom: 70px; }
    .ts-assistant-widget.ts-position-right { right: 16px; }
    .ts-assistant-widget.ts-position-left { left: 16px; }
    
    .ts-assistant-window {
        position: fixed !important;
        width: 100vw !important;
        height: 100dvh !important;
        max-width: 100vw !important;
        max-height: 100dvh !important;
        inset: 0 !important;
        border-radius: 0;
        z-index: 9999999;
    }
    
    .ts-assistant-messages {
        max-height: none;
        flex: 1;
    }
    
    .ts-assistant-header {
        padding: 16px;
        padding-top: max(16px, env(safe-area-inset-top));
    }
    
    .ts-assistant-close {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
    }
    
    .ts-assistant-close svg { width: 18px; height: 18px; }
    
    .ts-assistant-input-area {
        padding: 14px 16px;
        padding-bottom: max(14px, env(safe-area-inset-bottom));
    }
    
    .ts-quick-action {
        padding: 8px 14px !important;
        font-size: 12px !important;
    }
}

@media (max-width: 360px) {
    .ts-assistant-widget { bottom: 12px; }
    .ts-assistant-widget.ts-position-right { right: 12px; }
    .ts-assistant-widget.ts-position-left { left: 12px; }
    
    .ts-assistant-launcher { width: 52px; height: 52px; }
    .ts-launcher-icon svg { width: 24px; height: 24px; }
}

@media print {
    .ts-assistant-widget { display: none !important; }
}
