/* Modern Chat Container CSS */
.chat-container {
    width: 80vw;
    min-width: 0;
    background: linear-gradient(135deg, var(--bg-secondary, #1a1a2e) 80%, var(--bg-tertiary, #232338) 100%);
    border-left: 1px solid var(--glass-border, rgba(255, 255, 255, 0.2));
    position: relative;
    display: flex;
    padding-top: 40px;
    flex-direction: column;
    height: 100vh;
    justify-content: flex-end;
    flex-grow: 1;
    border-radius: 0 8px 8px 0;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.toggle-btn {
    z-index: 1000;
    position: absolute;
    top: 0px;
    left: -4px;
    background: rgba(26, 26, 46, 0.95);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    color: var(--text-primary, #ffffff);
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.2));
    border-left: 1px solid var(--glass-border, rgba(255, 255, 255, 0.2));
    border-top: none;
    border-radius: 0 0 8px 0;
    padding: 26px 5px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: translateX(0);
}

.toggle-btn:hover {
    background: rgba(26, 26, 46, 0.98);
    transform: translateX(2px);
    border-color: var(--primary, #4361ee);
}

.toggle-btn.rotated i {
    transform: rotate(180deg);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-btn.open {
    transform: translateX(calc(75vw)) !important;
}


/* Container transition'ları ile AYNI süre */
.open-tggl {
    width: 75vw;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.close-tggl {
    width: 25vw;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Chat Header - Glass Morphism */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(26, 26, 46, 0.9);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    padding: 12px 20px;
    border-bottom: 1px solid var(--glass-border, rgba(255, 255, 255, 0.2));
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.25);
    position: absolute;
    top: 0;
    width: calc(100% - 1px);
    height: 64px;
    box-sizing: border-box;
    z-index: 10;
}

.chat-user-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.user-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid transparent;
    background: linear-gradient(135deg, var(--primary, #4361ee), var(--secondary, #7209b7)) border-box;
    box-shadow: 
        0 4px 15px rgba(67, 97, 238, 0.25),
        0 0 0 2px rgba(26, 26, 46, 0.8);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.user-avatar:hover {
    transform: scale(1.18) rotate(-5deg);
    box-shadow: 
        0 6px 20px rgba(67, 97, 238, 0.4),
        0 0 0 3px rgba(26, 26, 46, 0.8);
}

.chat-user-details h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #ffffff);
    letter-spacing: 0.2px;
    background: linear-gradient(135deg, var(--text-primary, #ffffff) 0%, var(--primary-light, #4cc9f0) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.user-status {
    display: none;
    font-size: 13px;
    color: var(--text-secondary, #d1d5db);
    margin-top: 2px;
    font-weight: 400;
}

/* Chat Actions */
.chat-actions {
    display: flex;
    gap: 8px;
}

.chat-action-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary, #d1d5db);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
}

.chat-action-btn:hover {
    color: var(--primary-light, #4cc9f0);
    transform: scale(1.18) rotate(8deg);
    background: rgba(67, 97, 238, 0.2);
    border-color: var(--primary, #4361ee);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3);
}

/* Chat Box - Glass Morphism */
.chat-box {
    margin-top: 0;
    background: rgba(26, 26, 46, 0.7);
    -webkit-backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
    border-radius: 12px;
    padding: 18px 18px 8px 18px;
    overflow-y: auto;
    display: block;
    flex-direction: column;
    flex-grow: 1;
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    max-width: 100%;
    min-height: 320px;
    margin: 8px 5px;
    height: 100%;
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.15));
}

/* Messages Container */
#message {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 8px;
    list-style-type: none;
}

/* Message Styling */
.chat-message {
    margin: 10px 0;
    padding: 10px;
    border-radius: 10px;
    color: var(--text-primary, #ffffff);
    animation: messageSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* My Message - Gradient Style */
.my-message {
    background: linear-gradient(135deg, var(--primary, #4361ee) 0%, var(--primary-dark, #3a56d4) 100%);
    color: white;
    margin-left: auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
    width: fit-content;
    max-width: 35vw;
    min-width: 18ch;
    padding: 14px 16px 12px 16px;
    border-radius: 16px 16px 4px 16px;
    margin-top: 7px;
    margin-bottom: 7px;
    position: relative;
    padding-top: 22px;
    box-shadow: 
        0 4px 15px rgba(67, 97, 238, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

/* Other Message - Glass Morphism Style */
.other-message {
    background: rgba(67, 97, 238, 0.08);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: var(--text-primary, #ffffff);
    margin-right: auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
    width: fit-content;
    min-width: 18ch;
    max-width: 35vw;
    padding: 14px 16px 12px 16px;
    border-radius: 16px 16px 16px 4px;
    margin-top: 7px;
    margin-bottom: 7px;
    position: relative;
    padding-top: 22px;
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    border: 1px solid rgba(67, 97, 238, 0.15);
}

.other-message-name {
    position: absolute;
    left: 12px;
    top: 5px;
    font-size: 11px;
    color: var(--primary-light, #4cc9f0);
    font-weight: 600;
    opacity: 0.85;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.my-message-name {
    position: absolute;
    left: 12px;
    top: 5px;
    font-size: 11px;
    color: var(--primary-light, rgba(67, 97, 238, 0.08));
    font-weight: 600;
    opacity: 0.85;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}


/* Message Time */
.message-time {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    position: absolute;
    bottom: 4px;
    right: 12px;
    opacity: 0.7;
}

.other-message .message-time {
    color: var(--text-tertiary, #9ca3af);
}

/* Input Container - Glass Morphism */
.input-container {
    display: flex;
    margin: 3px 5px 8px 5px;
    background: rgba(26, 26, 46, 0.9);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 4px;
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    align-items: center;
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.15));
}

.input-container input {
    width: 100%;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-radius: 20px;
    color: var(--text-primary, #ffffff);
    outline: none;
    font-size: 16px;
    margin-right: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
}

.input-container input:focus {
    background: rgba(255, 255, 255, 0.05);
}

.input-container input::placeholder {
    color: var(--text-tertiary, #9ca3af);
    font-weight: 400;
}

.input-container button {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary, #4361ee) 0%, var(--secondary, #7209b7) 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: white;
    margin-left: 2px;
    outline: none;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 4px 15px rgba(67, 97, 238, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    position: relative;
    overflow: hidden;
}

.input-container button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.input-container button:hover::before {
    width: 300px;
    height: 300px;
}

.input-container button:hover {
    transform: scale(1.08) rotate(-8deg);
    box-shadow: 
        0 6px 20px rgba(67, 97, 238, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.input-container button:active {
    transform: scale(0.95);
}

/* Enhanced Typing Indicator */
.typing-indicator {
    padding: 0px 0px;
    font-style: italic;
    color: #43e97b;
    display: none;
    align-items: center;
    background: transparent;
    border-radius: 18px;
    max-width: fit-content;
    animation: slideInUp 0.3s ease-out;
}

/* Inline styling for the animated "typing" word */
#typing-indicator .typing-word {
    display: flex;
    gap: 2px;
    margin-bottom: 6px;
    align-items: flex-end;
    font-weight: 700;
    color: #43e97b;
    font-size: 14px;
    letter-spacing: 1px;
}

#typing-indicator .typing-letter {
    display: inline-block;
    opacity: 0.25;
    transform: translateY(3px) scale(0.96);
    animation: letterPop 1.2s infinite ease-in-out;
}

/* staggered delays to mimic dot-typing rhythm */
#typing-indicator .typing-letter:nth-child(1){ animation-delay: 0s; }
#typing-indicator .typing-letter:nth-child(2){ animation-delay: 0.12s; }
#typing-indicator .typing-letter:nth-child(3){ animation-delay: 0.24s; }
#typing-indicator .typing-letter:nth-child(4){ animation-delay: 0.36s; }
#typing-indicator .typing-letter:nth-child(5){ animation-delay: 0.48s; }
#typing-indicator .typing-letter:nth-child(6){ animation-delay: 0.60s; }

@keyframes letterPop {
    0%, 80%, 100% { opacity: 0.25; transform: translateY(6px) scale(0.96); }
    40% { opacity: 1; transform: translateY(0) scale(1.03); }
}

.typing-dots {
    display: flex;
    gap: 2px;
    align-items: flex-end;  /* Changed from center to flex-end */
}

.typing-dots span {
    width: 3px;
    height: 3px;
    padding-top: 2px;
    border-radius: 50%;
    background: linear-gradient(135deg, #43e97b 0%, #00eaff 100%);
    display: inline-block;
    animation: bubble-dance 1.4s infinite ease-in-out;
    transform-origin: center;
    font-size: 0;
}

.typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

.typing-indicator > span:last-child {
    font-size: 14px;
    color: #43e97b;
    font-weight: 500;
    margin-left: 4px;
}

/* Animations */
@keyframes bubble-dance {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
        background: linear-gradient(135deg, #43e97b 0%, #00eaff 50%);
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
        background: linear-gradient(135deg, #00eaff 0%, #43e97b 100%);
    }
}

@keyframes slideInUp {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes slideOutDown {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
}

.typing-indicator.visible {
    display: flex !important;
}

.typing-indicator.hiding {
    animation: slideOutDown 0.3s ease-in forwards;
}

/* Message Status Indicators */
.message-status {
    font-size: 10px;
    position: absolute;
    bottom: 4px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.status-delivered {
    color: var(--success, #4ade80);
}

.status-read {
    color: var(--primary, #4361ee);
}

.status-pending {
    color: var(--text-tertiary, #9ca3af);
}

/* Scrollbar Styling */
.chat-box::-webkit-scrollbar {
    width: 6px;
}

.chat-box::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.chat-box::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary, #4361ee) 0%, var(--secondary, #7209b7) 100%);
    border-radius: 3px;
}

.chat-box::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--primary-dark, #3a56d4) 0%, var(--secondary, #7209b7) 100%);
}

/* Message Actions */
.message-actions {
    position: absolute;
    top: -20px;
    right: 10px;
    display: none;
    gap: 4px;
    background: rgba(26, 26, 46, 0.9);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 4px;
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.15));
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.chat-message:hover .message-actions {
    display: flex;
}

.message-action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    color: var(--text-secondary, #d1d5db);
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 12px;
}

.message-action-btn:hover {
    background: rgba(67, 97, 238, 0.2);
    color: var(--primary-light, #4cc9f0);
    transform: scale(1.1);
}

/* Responsive */
@media (max-width: 768px) {
    .toggle-btn {
        display: flex;
    }
    
    .chat-container {
        width: 100vw;
        border-radius: 0;
    }
    
    .my-message,
    .other-message {
        max-width: 75vw;
        min-width: 30ch;
    }
    
    .typing-indicator {
        border-radius: 16px;
    }
    
    .typing-dots span {
        width: 5px;
        height: 5px;
    }
    
}

/* Dark/Light Mode Support */
@media (prefers-color-scheme: light) {
    .chat-container {
        background: linear-gradient(135deg, rgba(248, 250, 252, 0.9) 80%, rgba(226, 232, 240, 0.9) 100%);
        border-left: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    .chat-header {
        background: rgba(255, 255, 255, 0.9);
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    .chat-user-details h3 {
        background: linear-gradient(135deg, #1a1a2e 0%, #4361ee 100%);
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
    }
    
    .other-message {
        background: rgba(0, 0, 0, 0.05);
        color: #1a1a2e;
        border: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    .input-container {
        background: rgba(255, 255, 255, 0.9);
    }
    
    .input-container input {
        color: #1a1a2e;
    }
    
    .input-container input::placeholder {
        color: #64748b;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .chat-message,
    .input-container button,
    .chat-action-btn,
    .user-avatar {
        animation: none !important;
        transition: none !important;
    }
    
}

/* Focus States */
.toggle-btn:focus-visible,
.chat-action-btn:focus-visible,
.input-container button:focus-visible,
.input-container input:focus-visible {
    outline: 2px solid var(--primary, #4361ee);
    outline-offset: 2px;
}

/* Ensure proper display */
#typing-indicator {
    display: none;
}

/* Loading States */
.message-loading {
    opacity: 0.7;
    position: relative;
}

.message-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Empty State */
.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary, #d1d5db);
    text-align: center;
    padding: 2rem;
}

.chat-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.chat-empty-text {
    font-size: 1.125rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.chat-empty-subtext {
    font-size: 0.9rem;
    color: var(--text-tertiary, #9ca3af);
}
