/* AI Chat Widget - Mac-Inspired Premium Design */

.chat-widget {
    position: fixed !important;
    bottom: 30px !important;
    right: 30px !important;
    z-index: 10002 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Firma Paneli sayfasında chatbox'ı gizle */
body.firma-panel-page .chat-widget,
body.bayi-panel-page .chat-widget,
.page-firma-panel .chat-widget,
.page-bayi-panel .chat-widget {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Chat Button - Mac Style */
.chat-button {
    width: 64px !important;
    height: 64px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #e63946 0%, #ff6b9d 100%) !important;
    border: none !important;
    box-shadow: 
        0 8px 32px rgba(230, 57, 70, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: white !important;
    font-size: 1.6rem !important;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1) !important;
    position: relative !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 10003 !important;
}

.chat-button::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    padding: 2px;
    background: linear-gradient(135deg, rgba(255,255,255,0.3), rgba(255,255,255,0.1));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s;
}

.chat-button:hover::before {
    opacity: 1;
}

.chat-button:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 
        0 12px 40px rgba(230, 57, 70, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.2) inset;
}

.chat-button:active {
    transform: scale(0.96);
}

.chat-button.active {
    transform: scale(0.92);
}

/* Chat Container - Mac Glassmorphism */
.chat-container {
    position: absolute;
    bottom: 84px;
    right: 0;
    width: 420px;
    height: 680px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(0, 0, 0, 0.05) inset,
        0 1px 0 rgba(255, 255, 255, 0.6) inset;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: macSlideUp 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.chat-container.active {
    display: flex;
}

/* Size Variants */
.chat-container.size-small {
    width: 360px;
    height: 560px;
}

.chat-container.size-medium {
    width: 420px;
    height: 680px;
}

.chat-container.size-large {
    width: 500px;
    height: 800px;
}

@keyframes macSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
        filter: blur(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

/* Header - Mac Style */
.chat-header {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.7) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    position: relative;
}

.chat-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0,0,0,0.1), transparent);
}

.chat-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #1a1a2e;
    letter-spacing: -0.3px;
}

.chat-header .status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 4px;
}

.chat-header .status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
    animation: macPulse 2s ease-in-out infinite;
}

@keyframes macPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

.chat-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-size-toggle {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 8px;
    padding: 4px;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.chat-size-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-size: 0.7rem;
    transition: all 0.2s;
    position: relative;
}

.chat-size-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #1a1a2e;
}

.chat-size-btn.active {
    background: rgba(230, 57, 70, 0.1);
    color: #e63946;
}

.chat-size-btn.active::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 2px;
    background: #e63946;
    border-radius: 1px;
}

.chat-header .close-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    transition: all 0.2s;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.chat-header .close-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    transform: rotate(90deg);
    border-color: rgba(239, 68, 68, 0.2);
}

/* Messages Area - Mac Style */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: rgba(248, 250, 252, 0.5);
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Mac Style Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
    background-clip: padding-box;
}

/* Messages */
.message {
    display: flex;
    gap: 12px;
    animation: macFadeIn 0.35s cubic-bezier(0.23, 1, 0.32, 1);
}

@keyframes macFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #e63946 0%, #ff6b9d 100%);
    color: white;
}

.message.bot .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message-content {
    max-width: 78%;
    padding: 14px 18px;
    border-radius: 20px;
    line-height: 1.6;
    font-size: 0.9rem;
    word-wrap: break-word;
    font-weight: 400;
    letter-spacing: -0.01em;
}

.message.user .message-content {
    background: linear-gradient(135deg, #e63946 0%, #ff6b9d 100%);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 12px rgba(230, 57, 70, 0.25);
}

.message.bot .message-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #1a1a2e;
    border-bottom-left-radius: 6px;
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.08),
        0 0 0 1px rgba(0, 0, 0, 0.04) inset;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.message-content strong {
    font-weight: 600;
    color: inherit;
}

.message-content a {
    color: #e63946;
    text-decoration: none;
    border-bottom: 1px solid rgba(230, 57, 70, 0.3);
    transition: all 0.2s;
}

.message-content a:hover {
    border-bottom-color: #e63946;
}

.message-content ul,
.message-content ol {
    margin: 10px 0;
    padding-left: 22px;
}

.message-content li {
    margin: 6px 0;
    line-height: 1.6;
}

/* Typing Indicator - Mac Style */
.typing-indicator {
    display: none;
    gap: 6px;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.5);
    width: fit-content;
}

.typing-indicator.active {
    display: flex;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: macTyping 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes macTyping {
    0%, 60%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-8px) scale(1.1);
        opacity: 1;
    }
}

/* Input Container - Mac Style */
.chat-input-container {
    padding: 20px 24px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    gap: 12px;
    align-items: flex-end;
    position: relative;
}

.chat-input-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0,0,0,0.08), transparent);
}

.chat-input {
    flex: 1;
    border: 1.5px solid rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    padding: 12px 18px;
    font-size: 0.9rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
    resize: none;
    max-height: 120px;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #1a1a2e;
    line-height: 1.5;
}

.chat-input::placeholder {
    color: #9ca3af;
}

.chat-input:focus {
    outline: none;
    border-color: #e63946;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 
        0 0 0 4px rgba(230, 57, 70, 0.08),
        0 4px 12px rgba(0, 0, 0, 0.05);
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e63946 0%, #ff6b9d 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(230, 57, 70, 0.25);
    position: relative;
    overflow: hidden;
}

.chat-send-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.chat-send-btn:hover::before {
    opacity: 1;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.08) translateY(-1px);
    box-shadow: 0 6px 16px rgba(230, 57, 70, 0.35);
}

.chat-send-btn:active:not(:disabled) {
    transform: scale(0.96);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: scale(1);
}

/* Quick Actions - Mac Style */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 24px 16px;
    background: transparent;
}

.quick-action-btn {
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    color: #1a1a2e;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.quick-action-btn:hover {
    background: rgba(230, 57, 70, 0.1);
    color: #e63946;
    border-color: rgba(230, 57, 70, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(230, 57, 70, 0.15);
}

.quick-action-btn:active {
    transform: translateY(0);
}

/* Welcome Message - Mac Style */
.welcome-message {
    text-align: center;
    padding: 24px;
    background: linear-gradient(135deg, rgba(230, 57, 70, 0.08) 0%, rgba(255, 107, 157, 0.08) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    margin-bottom: 16px;
    border: 1px solid rgba(230, 57, 70, 0.1);
}

.welcome-message h4 {
    margin: 0 0 10px;
    color: #1a1a2e;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.welcome-message p {
    margin: 0;
    font-size: 0.88rem;
    color: #6c757d;
    line-height: 1.6;
}

/* Responsive - Mac Style */
@media (max-width: 768px) {
    .chat-container {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
        bottom: 20px;
        right: 16px;
        left: 16px;
        border-radius: 24px;
        z-index: 10005 !important;
    }
    
    .chat-container.size-small,
    .chat-container.size-medium,
    .chat-container.size-large {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
    }
    
    .chat-widget {
        bottom: 20px !important;
        right: 16px !important;
        left: auto !important;
        z-index: 10005 !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        position: fixed !important;
    }
    
    .chat-button {
        width: 60px !important;
        height: 60px !important;
        font-size: 1.5rem !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        z-index: 10006 !important;
        position: fixed !important;
        bottom: 20px !important;
        right: 16px !important;
    }
    
    .chat-header-actions {
        display: none;
    }
    
    /* Mobilde chatbox'ı her zaman görünür yap */
    body.firma-panel-page .chat-widget,
    body.bayi-panel-page .chat-widget,
    .page-firma-panel .chat-widget,
    .page-bayi-panel .chat-widget {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    body.firma-panel-page .chat-button,
    body.bayi-panel-page .chat-button,
    .page-firma-panel .chat-button,
    .page-bayi-panel .chat-button {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* Performance Optimizations */
.chat-container,
.chat-button,
.message-content {
    will-change: transform;
    transform: translateZ(0);
}

/* Dark Mode Support (Future) */
@media (prefers-color-scheme: dark) {
    .chat-container {
        background: rgba(26, 26, 46, 0.85);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .chat-header {
        background: linear-gradient(180deg, rgba(26, 26, 46, 0.9) 0%, rgba(26, 26, 46, 0.7) 100%);
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }
    
    .chat-messages {
        background: rgba(22, 33, 62, 0.5);
    }
    
    .message.bot .message-content {
        background: rgba(26, 26, 46, 0.95);
        color: #f8f9fa;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .chat-input {
        background: rgba(26, 26, 46, 0.8);
        border-color: rgba(255, 255, 255, 0.1);
        color: #f8f9fa;
    }
    
    .chat-input-container {
        background: rgba(26, 26, 46, 0.9);
        border-top-color: rgba(255, 255, 255, 0.1);
    }
}
