/* Chat Window */
.chat-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    left: auto;
    width: 400px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 40px);
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: height 0.3s, box-shadow 0.3s;
    overflow: hidden;
}

.chat-window.minimized {
    height: 70px !important;
    overflow: hidden;
}

.chat-window.minimized .chat-content {
    display: none !important;
}

.chat-window.minimized .message-input-area {
    display: none !important;
}

.chat-window.hidden {
    display: none;
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    position: relative;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.chat-profile-img,
.chat-status-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
}

.chat-header-text h3 {
    margin: 0;
    font-size: 1.1em;
}

.chat-status-container {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85em;
    opacity: 0.95;
}

.online-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
    flex-shrink: 0;
}

.typing-indicator {
    padding: 0 16px 10px;
}

.typing-indicator.hidden {
    display: none;
}

.typing-bubble {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #ececec;
    color: #555;
    border-radius: 14px;
    padding: 7px 12px;
    font-size: 13px;
}

.typing-dots {
    display: inline-flex;
    gap: 3px;
}

.typing-dots i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #888;
    animation: typingBounce 1.2s infinite;
}

.typing-dots i:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dots i:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-3px); opacity: 1; }
}

.chat-badge {
    position: absolute;
    top: 8px;
    right: 50px;
    background: #ff4444;
    color: white;
    border-radius: 12px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
    line-height: 1;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    z-index: 10;
}

.chat-minimize,
.chat-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 5px;
    transition: background 0.2s;
    z-index: 10;
    position: relative;
}

.chat-minimize:hover,
.chat-close:hover {
    background: rgba(255,255,255,0.2);
}

.chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-content.hidden {
    display: none;
}

/* Verification */
.verification-container {
    padding: 30px;
    text-align: center;
}

.verification-container h3 {
    margin-bottom: 15px;
    color: #333;
}

.verification-container input {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: transform 0.2s;
    margin-top: 10px;
}

.btn-primary:hover {
    transform: translateY(-2px);
}

#verificationMessage {
    margin-top: 15px;
    font-size: 0.9em;
}

/* Messages */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f5f5;
}

.message-bubble {
    margin-bottom: 15px;
    max-width: 80%;
    word-wrap: break-word;
    position: relative;
}

.message-bubble.visitor {
    margin-left: auto;
    text-align: right;
}

.message-bubble.admin {
    margin-right: auto;
    text-align: left;
}

.message-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    position: relative;
}

.message-bubble.visitor .message-wrapper {
    flex-direction: row-reverse;
}

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    display: inline-block;
    max-width: 100%;
}

.message-bubble.visitor .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message-bubble.admin .message-content {
    background: #e0e0e0;
    color: #333;
}

.message-profile-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.message-profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #667eea;
}

.message-profile-name {
    font-size: 0.85em;
    font-weight: 600;
    color: #667eea;
}

.message-time {
    font-size: 0.75em;
    color: #999;
    margin-top: 5px;
    padding: 0 5px;
}

/* Message Input */
.message-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
}

.message-buttons-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pending-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
}

.pending-images.hidden {
    display: none;
}

.pending-image-item {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    background: #f7f7f7;
}

.pending-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pending-image-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 14px;
    line-height: 20px;
    cursor: pointer;
    padding: 0;
}

.message-input-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.message-input-area textarea {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    resize: none;
    font-size: 14px;
    font-family: inherit;
    max-height: 150px;
    min-height: 60px;
    line-height: 1.5;
}

.btn-send {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1em;
    transition: transform 0.2s;
}

.btn-send:hover {
    transform: translateY(-2px);
}

.emoji-btn,
.location-btn,
.image-upload-btn,
.audio-record-btn {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    transition: background 0.2s;
}

.emoji-btn:hover,
.location-btn:hover,
.image-upload-btn:hover,
.audio-record-btn:hover {
    background: #f0f0f0;
}

.audio-record-btn.recording {
    background-color: #dc3545;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Emoji Picker */
.emoji-picker {
    position: absolute;
    bottom: 80px;
    left: 15px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    width: 300px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 5px;
}

.emoji-picker.hidden {
    display: none;
}

.emoji-item {
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    text-align: center;
    border-radius: 5px;
    transition: background 0.2s;
}

.emoji-item:hover {
    background: #f0f0f0;
}

/* Location Message */
.location-message {
    margin: 0;
}

.location-map-container {
    position: relative;
    width: 100%;
    height: 200px;
    border-radius: 12px;
    overflow: hidden;
    background: #f5f5f5;
}

.location-map-iframe {
    width: 100%;
    height: 100%;
    border: none;
    pointer-events: none;
}

.location-map-container {
    cursor: pointer;
}

.location-map-container:hover .location-map-iframe {
    opacity: 0.9;
}

.location-map-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    pointer-events: none;
}

.location-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.location-link,
.whatsapp-link {
    display: inline-block;
    padding: 8px 16px;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.9em;
    transition: background 0.2s;
}

.location-link {
    background: #667eea;
}

.location-link:hover {
    background: #5568d3;
}

.whatsapp-link {
    background: #25d366;
}

.whatsapp-link:hover {
    background: #20ba5a;
}

/* Image Message */
.image-message {
    margin: 0;
}

.message-image {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    cursor: pointer;
    object-fit: contain;
    margin-top: 5px;
}

.message-image:hover {
    transform: scale(1.02);
}

/* Audio Message */
.audio-message {
    margin: 0;
    display: block;
    width: 100%;
}

.message-audio-hidden {
    display: none;
}

.custom-audio-player {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    border-radius: 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    max-width: 300px;
    min-width: 250px;
}

.message-bubble.admin .custom-audio-player {
    background: #e0e0e0;
}

.audio-play-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.3);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.message-bubble.admin .audio-play-btn {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

.audio-play-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.05);
}

.message-bubble.admin .audio-play-btn:hover {
    background: rgba(0, 0, 0, 0.15);
}

.audio-progress-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.audio-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.message-bubble.admin .audio-progress-bar {
    background: rgba(0, 0, 0, 0.1);
}

.audio-progress-fill {
    height: 100%;
    background: white;
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s;
}

.message-bubble.admin .audio-progress-fill {
    background: #667eea;
}

.audio-time {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: white;
    font-weight: 500;
}

.message-bubble.admin .audio-time {
    color: #333;
}

.audio-current-time,
.audio-duration {
    font-variant-numeric: tabular-nums;
}

.audio-separator {
    opacity: 0.7;
}

/* Message Menu */
.message-menu {
    position: relative;
    flex-shrink: 0;
}

.message-menu-btn {
    
    border: none;
    color: #715cba;
    font-size: 20px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
}

.message-bubble.admin .message-menu-btn {
    color: #333;
}

.message-menu-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.message-bubble.admin .message-menu-btn:hover {
    background: rgba(0, 0, 0, 0.15);
}

.message-menu-dropdown {
    position: absolute;
    top: 30px;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 150px;
    z-index: 1000;
    display: none;
    overflow: hidden;
}

.message-bubble.visitor .message-menu-dropdown {
    right: 0;
}

.message-bubble.admin .message-menu-dropdown {
    left: 0;
    right: auto;
}

.message-menu-dropdown.show {
    display: block;
}

.message-menu-item {
    width: 100%;
    padding: 6px 6px;
    border: none;
    background: white;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.message-menu-item:hover {
    background: #f5f5f5;
}

.message-menu-delete {
    color: #e74c3c;
}

.message-menu-delete:hover {
    background: #fee;
    color: #c0392b;
}

/* Message Deleted */
.message-deleted {
    padding: 12px 16px;
    border-radius: 18px;
    background: rgba(0, 0, 0, 0.05);
    color: #999;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.message-deleted-bubble {
    opacity: 0.6;
}

.message-deleted-icon {
    font-size: 16px;
}

.message-deleted-text {
    font-size: 13px;
}

/* Location Confirm Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease-out;
}

.modal-overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content-location {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 400px;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header-location {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

.modal-icon-location {
    font-size: 48px;
    margin-bottom: 10px;
}

.modal-header-location h3 {
    margin: 0;
    font-size: 1.5em;
}

.modal-body-location {
    padding: 25px;
    text-align: center;
}

.modal-body-location p {
    margin: 10px 0;
    color: #333;
    font-size: 1.1em;
}

.modal-subtitle {
    color: #666;
    font-size: 0.9em !important;
}

.modal-footer-location {
    padding: 20px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-primary-location,
.btn-secondary-location {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-primary-location {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary-location:hover {
    transform: translateY(-2px);
}

.btn-secondary-location {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary-location:hover {
    background: #d0d0d0;
}

/* Responsive — iPhone'da left+right ile sabitle, width:100% kullanma */
@media (max-width: 768px) {
    .chat-window {
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: auto;
        max-width: none;
        height: auto;
        max-height: none;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .chat-window.minimized {
        top: auto;
        left: auto;
        right: 16px;
        bottom: 16px;
        width: calc(100vw - 32px);
        max-width: 400px;
        height: 70px !important;
        border-radius: 15px;
        padding: 0;
    }
}

