/* File: chat.css */
/* Minimal, mobil odaklı Sahasenin sohbet tasarımı */

:root {
    --chat-accent: var(--theme-color, #4caf50);
    --chat-accent-dark: #388e3c;
    --chat-accent-soft: #f3fff6;
    --chat-surface: #ffffff;
    --chat-surface-soft: rgba(255, 255, 255, 0.92);
    --chat-border: #edf0f3;
    --chat-text: #20242a;
    --chat-muted: #7b8494;
    --chat-shadow: 0 10px 30px rgba(20, 30, 45, 0.07);
    --chat-shadow-soft: 0 6px 18px rgba(20, 30, 45, 0.055);
    --chat-radius: 12px;
    --chat-radius-sm: 12px;
    --chat-time-reveal-progress: 0;
    --chat-time-reveal-width: 0px;
    --chat-time-reveal-shift: -10px;
    --chat-time-reveal-scale: 0.94;
    --chat-time-reveal-bubble-shift: 0px;
    --chat-time-reveal-bubble-scale: 1;
    --chat-scroll-shift: 0px;
    --chat-scroll-scale: 1;
    --chat-scroll-rotate: 0deg;
}

#MessagesArea,
.messages-area {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    touch-action: pan-y;
    --chat-time-reveal-progress: 0;
    --chat-time-reveal-width: 0px;
    --chat-time-reveal-shift: -10px;
    --chat-time-reveal-scale: 0.94;
    --chat-time-reveal-bubble-shift: 0px;
    --chat-time-reveal-bubble-scale: 1;
    padding: 8px 12px 14px;
    border-radius: var(--chat-radius); 
    background: transparent !important;
    scrollbar-width: none;
}

#MessagesArea::-webkit-scrollbar,
.messages-area::-webkit-scrollbar {
    width: 0;
    height: 0;
}

#MessagesArea.chat-loading,
.messages-area.chat-loading {
    pointer-events: none;
}

.chat-message-item {
    position: relative;
    width: 100%;
    display: flex;
    align-items: flex-end;
    gap: 0;
    margin: 3px 0;
    animation: chatMessageIn 360ms cubic-bezier(0.16, 1, 0.3, 1) both;
    will-change: transform, opacity, filter;
    contain: layout style;
}

.chat-message-item.is-mine {
    animation-name: chatMessageInMine;
}

.chat-message-item.is-other {
    animation-name: chatMessageInOther;
}

.chat-message-item.is-mine {
    justify-content: flex-end;
}

.chat-message-item.is-other {
    justify-content: flex-start;
}

.chat-message-item.is-action-card {
    justify-content: center;
    margin: 8px 0;
}

.chat-message-item.is-group-first {
    margin-bottom: 1px;
}

.chat-message-item.is-group-middle {
    margin-top: 1px;
    margin-bottom: 1px;
}

.chat-message-item.is-group-last {
    margin-top: 1px;
    margin-bottom: 7px;
}

.chat-message-item.is-single {
    margin-top: 5px;
    margin-bottom: 8px;
}

.chat-bubble {
    position: relative;
    max-width: min(78%, 520px);
    padding: 8px 10px 7px;
    border-radius: var(--chat-radius);
    background: var(--chat-surface);
    color: var(--chat-text);
    border: 1px solid rgba(237, 240, 243, 0.96);
    box-shadow: var(--chat-shadow-soft);
    overflow: hidden;
    isolation: isolate;
    transform-origin: bottom left;
    transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 220ms ease, border-radius 180ms ease, filter 180ms ease;
    will-change: transform, filter;
}

.chat-bubble::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    opacity: 0;
    background: radial-gradient(circle at 25% 0%, rgba(255, 255, 255, 0.48), transparent 38%);
    transition: opacity 220ms ease;
    pointer-events: none;
}

.chat-message-item.is-mine .chat-bubble::after {
    opacity: 0.24;
}

.chat-message-item.is-other.is-group-first .chat-bubble {
    border-bottom-left-radius: 8px;
}

.chat-message-item.is-other.is-group-middle .chat-bubble {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.chat-message-item.is-other.is-group-last .chat-bubble {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 18px;
}

.chat-message-item.is-mine .chat-bubble {
    transform-origin: bottom right;
    border-color: transparent;
    background: linear-gradient(135deg, var(--chat-accent) 0%, #66c86f 100%);
    color: #ffffff;
    box-shadow: 0 10px 24px rgba(76, 175, 80, 0.22);
}

.chat-message-item.is-mine.is-group-first .chat-bubble {
    border-bottom-right-radius: 8px;
}

.chat-message-item.is-mine.is-group-middle .chat-bubble {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.chat-message-item.is-mine.is-group-last .chat-bubble {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 18px;
}

#MessagesArea.chat-scrolling .chat-bubble,
.messages-area.chat-scrolling .chat-bubble {
    transform: translate3d(0, var(--chat-scroll-shift, 0px), 0) scale(var(--chat-scroll-scale, 1)) rotate(var(--chat-scroll-rotate, 0deg));
    filter: saturate(1.03);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

@media (hover: none) and (pointer: coarse) {

    #MessagesArea.chat-scrolling .chat-bubble,
    .messages-area.chat-scrolling .chat-bubble,
    #MessagesArea.chat-time-reveal-visible .chat-bubble,
    .messages-area.chat-time-reveal-visible .chat-bubble,
    #MessagesArea.chat-time-reveal-visible .chat-reveal-time,
    .messages-area.chat-time-reveal-visible .chat-reveal-time {
        will-change: transform, opacity, width;
    }
}

.chat-reveal-time {
    width: var(--chat-time-reveal-width, 0px);
    min-width: var(--chat-time-reveal-width, 0px);
    max-width: 76px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    overflow: hidden;
    white-space: nowrap;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    opacity: var(--chat-time-reveal-progress, 0);
    transform: translate3d(var(--chat-time-reveal-shift, -10px), 0, 0) scale(var(--chat-time-reveal-scale, 0.94));
    color: rgba(92, 101, 116, 0.92) !important;
    font-size: 0.62rem !important;
    font-weight: 850;
    letter-spacing: 0.01em;
    transition: width 170ms cubic-bezier(0.16, 1, 0.3, 1), min-width 170ms cubic-bezier(0.16, 1, 0.3, 1), opacity 140ms ease, transform 170ms cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-message-item.is-mine .chat-reveal-time {
    color: rgba(92, 101, 116, 0.86) !important;
}

#MessagesArea.chat-time-reveal-visible .chat-bubble,
.messages-area.chat-time-reveal-visible .chat-bubble {
    transform: translate3d(var(--chat-time-reveal-bubble-shift, 0px), 0, 0) scale(var(--chat-time-reveal-bubble-scale, 1));
}

#MessagesArea.chat-time-reveal-visible .chat-reveal-time,
.messages-area.chat-time-reveal-visible .chat-reveal-time {
    text-shadow: 0 1px 6px rgba(20, 30, 45, 0.08);
}

.chat-message-content {
    min-width: 0;
}

.chat-text-wrap {
    min-width: 0;
}

.chat-text {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    color: var(--chat-text) !important;
    font-size: 0.78rem !important;
    font-weight: 650 !important;
    line-height: 1.45;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.chat-message-item.is-mine .chat-text,
.chat-message-item.is-mine .chat-time,
.chat-message-item.is-mine .chat-file-link,
.chat-message-item.is-mine .chat-file-link span,
.chat-message-item.is-mine .chat-file-link i,
.chat-message-item.is-mine .chat-member-name {
    color: rgba(255, 255, 255, 0.96) !important;
}

.chat-message-meta {
    display: none;
    align-items: center;
    gap: 8px;
    margin-top: 5px;
    color: var(--chat-muted) !important;
    line-height: 1;
}

.chat-message-item.show-sender-info .chat-message-meta {
    display: flex;
}

.chat-message-meta.is-meta-mine {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.chat-meta-member {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
}

.chat-avatar {
    width: 20px;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.88);
    background: #fff;
    box-shadow: 0 2px 8px rgba(20, 30, 45, 0.10);
}

.chat-member-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.62rem !important;
    font-weight: 800;
    line-height: 1.1;
    color: #596170;
}

.chat-time {
    display: inline-flex;
    color: var(--chat-muted) !important;
    font-size: 0.6rem !important;
    font-weight: 750;
    line-height: 1;
    opacity: 0.82;
}

.chat-image-box {
    display: block;
    width: min(260px, 68vw);
    max-width: 100%;
    margin: 2px 0 6px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(237, 240, 243, 0.9);
    background: #eef2f7;
}

.chat-message-image,
.chat-image-box img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 280px;
    object-fit: cover;
    transition: transform 260ms cubic-bezier(0.16, 1, 0.3, 1), filter 220ms ease;
}

.chat-image-box:active img {
    transform: scale(0.985);
    filter: brightness(0.96);
}

.chat-file-link {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    width: fit-content;
    max-width: 100%;
    margin-top: 6px;
    padding: 6px 8px;
    border-radius: 999px;
    background: rgba(76, 175, 80, 0.09);
    color: var(--chat-accent-dark) !important;
    font-size: 0.68rem !important;
    font-weight: 800 !important;
    text-decoration: none !important;
    transition: transform 150ms ease, background-color 150ms ease;
}

.chat-message-item.is-mine .chat-file-link {
    background: rgba(255, 255, 255, 0.17);
}

.chat-file-link:active {
    transform: scale(0.97);
}

.chat-date-badge {
    position: relative;
    z-index: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 12px 0 9px;
    pointer-events: none;
    animation: chatDateIn 200ms ease both;
}

.chat-date-badge::before,
.chat-date-badge::after {
    content: "";
    flex: 1;
    max-width: 70px;
    height: 1px;
    background: rgba(142, 151, 165, 0.18);
}

.chat-date-badge span,
.chat-floating-date-badge span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 4px 11px;
    border-radius: 999px;
    border: 1px solid rgba(237, 240, 243, 0.88);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #5d6675 !important;
    font-size: 0.62rem !important;
    font-weight: 850;
    box-shadow: none;
}

.chat-floating-date-badge {
    position: sticky;
    top: 6px;
    z-index: 8;
    display: flex;
    justify-content: center;
    width: 100%;
    height: 0;
    margin: 0;
    overflow: visible;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 140ms ease, transform 140ms ease;
}

.chat-floating-date-badge.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.chat-floating-date-badge span {
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 2px 10px rgba(20, 30, 45, 0.045);
}

.chat-loader,
.chat-top-loader {
    align-self: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 30px;
    margin: 8px auto;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--chat-surface-soft);
    color: var(--chat-muted) !important;
    font-size: 0.68rem !important;
    font-weight: 800;
    box-shadow: var(--chat-shadow-soft);
}

.chat-loader::before,
.chat-top-loader::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-top-color: transparent;
    animation: chatSpin 720ms linear infinite;
}

.chat-empty-state {
    min-height: 45%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 28px 18px;
    color: var(--chat-muted) !important;
    text-align: center;
}

.chat-empty-icon {
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--chat-accent-soft);
    color: var(--chat-accent) !important;
    box-shadow: 0 8px 22px rgba(76, 175, 80, 0.12);
}

.chat-empty-state strong {
    color: #475062 !important;
    font-size: 0.82rem !important;
    font-weight: 850;
}

.chat-empty-state span {
    max-width: 240px;
    color: var(--chat-muted) !important;
    font-size: 0.7rem !important;
    font-weight: 650;
    line-height: 1.35;
}

.chat-action-card,
.globalRequestCard.w-100 {
    width: 100% !important;
}

.chat-action-card {
    max-width: 560px;
    animation: chatMessageIn 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.chat-action-card .card,
.globalRequestCard .card {
    border-radius: var(--chat-radius) !important;
    border-color: var(--chat-border) !important;
    box-shadow: var(--chat-shadow-soft) !important;
}

.chat-action-card .chat-image-box,
.chat-action-card .slider-container.chat-image-box {
    width: 70px !important;
    height: 70px !important;
    margin: 0;
    border-radius: 12px !important;
}


.chat-input-container {
    position: sticky;
    bottom: 0;
    z-index: 20;
    width: 100%;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    background: transparent !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-top: 1px solid rgba(237, 240, 243, 0.72);
}

#chatForm,
.chat-form {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    width: 100%;
    min-height: 48px;
    padding: 5px;
    border: 1px solid rgba(237, 240, 243, 0.95);
    border-radius: 22px;
    background: none;
    box-shadow: none;
}

#messageText {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 38px;
    max-height: 120px;
    padding: 9px 7px !important;
    border: 0 !important;
    outline: none !important;
    resize: none !important;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--chat-text) !important;
    font-size: 16px !important;
    font-weight: 650 !important;
    line-height: 1.35;
    overflow-y: auto;
    user-select: text !important;
    -webkit-user-select: text !important;
}

#messageText::placeholder {
    color: #a3acba;
    font-weight: 650;
}

.chat-attachment-btn,
.chat-send-btn {
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    outline: none;
    color: #687285;
    background: transparent;
    transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1), background-color 170ms ease, color 170ms ease, box-shadow 180ms ease;
}

.chat-attachment-btn:active,
.chat-send-btn:active {
    transform: scale(0.94);
}

.chat-attachment-btn:hover {
    background: rgba(20, 30, 45, 0.045);
    color: #475062;
}

.chat-send-btn {
    color: #ffffff;
    background: var(--chat-accent);
    box-shadow: 0 8px 18px rgba(76, 175, 80, 0.24);
}

#chatForm.chat-form-sending .chat-send-btn,
#chatForm.chat-form-sending button[type="submit"] {
    animation: chatSendPulse 780ms ease infinite;
    opacity: 0.8;
}

.chat-selected-files {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
    padding: 0 4px;
    color: var(--chat-muted) !important;
    font-size: 0.66rem !important;
    font-weight: 750;
}

.chat-selected-files.has-files {
    display: flex;
}

.chat-selected-files span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-selected-files button {
    border: 0;
    background: transparent;
    color: #9aa3b3;
    padding: 2px 4px;
}

body.chat-keyboard-open #mobileFooterBar,
body.chat-keyboard-open .mobileFooterBar {
    transform: translateY(110%);
    transition: transform 180ms ease;
}

body.chat-keyboard-open .chat-input-container {
    padding-bottom: 8px;
}

@media (hover: hover) and (pointer: fine) {
    .chat-bubble:hover {
        transform: translateY(-2px) scale(1.006);
        box-shadow: 0 14px 32px rgba(20, 30, 45, 0.10);
    }

    .chat-message-item.is-mine .chat-bubble:hover {
        box-shadow: 0 12px 28px rgba(76, 175, 80, 0.25);
    }
}

@media (max-width: 768px) {

    #MessagesArea,
    .messages-area {
        border-left: 0;
        border-right: 0;
        border-radius: 0;
        padding: 8px 8px 12px;
        min-height: 180px;
    }

    .chat-bubble {
        max-width: 86%;
        padding: 8px 9px 7px;
        border-radius: 17px;
    }

    .chat-reveal-time {
        max-width: 68px;
        font-size: 0.6rem !important;
    }

    .chat-action-card {
        max-width: 100%;
    }

    .chat-member-name {
        max-width: 130px;
    }

    .chat-image-box {
        width: min(245px, 74vw);
    }

    .chat-input-container {
        padding-left: 7px;
        padding-right: 7px;
    }

    #chatForm,
    .chat-form {
        border-radius: 20px;
        padding: 5px;
    }

    #messageText {
        min-height: 38px;
        padding-top: 9px !important;
        padding-bottom: 9px !important;
    }

    .chat-attachment-btn,
    .chat-send-btn,
    #chatForm button[type="submit"],
    #chatForm input[type="submit"] {
        width: 40px !important;
        min-width: 40px !important;
        height: 40px !important;
        min-height: 40px !important;
    }
}

@media (max-width: 390px) {
    .chat-bubble {
        max-width: 90%;
    }

    .chat-text {
        font-size: 0.75rem !important;
    }

    .chat-avatar {
        width: 18px;
        min-width: 18px;
        height: 18px;
    }

    .chat-attachment-btn {
        width: 34px !important;
        min-width: 34px !important;
    }
}

@media (prefers-reduced-motion: reduce) {

    #MessagesArea,
    .messages-area,
    .chat-message-item,
    .chat-date-badge,
    .chat-floating-date-badge,
    .chat-loader::before,
    .chat-top-loader::before,
    #chatForm,
    #chatForm button,
    .chat-bubble,
    .chat-reveal-time,
    .chat-image-box img {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

@keyframes chatMessageIn {
    0% {
        opacity: 0;
        transform: translateY(14px) scale(0.965);
        filter: blur(6px) saturate(0.92);
    }

    60% {
        opacity: 1;
        transform: translateY(-2px) scale(1.012);
        filter: blur(0) saturate(1.04);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0) saturate(1);
    }
}

@keyframes chatMessageInMine {
    0% {
        opacity: 0;
        transform: translate3d(18px, 14px, 0) scale(0.965);
        filter: blur(6px) saturate(0.92);
    }

    60% {
        opacity: 1;
        transform: translate3d(-2px, -2px, 0) scale(1.012);
        filter: blur(0) saturate(1.04);
    }

    100% {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
        filter: blur(0) saturate(1);
    }
}

@keyframes chatMessageInOther {
    0% {
        opacity: 0;
        transform: translate3d(-18px, 14px, 0) scale(0.965);
        filter: blur(6px) saturate(0.92);
    }

    60% {
        opacity: 1;
        transform: translate3d(2px, -2px, 0) scale(1.012);
        filter: blur(0) saturate(1.04);
    }

    100% {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
        filter: blur(0) saturate(1);
    }
}

@keyframes chatDateIn {
    0% {
        opacity: 0;
        transform: translateY(-4px) scale(0.96);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes chatSpin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes chatSendPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.94);
    }
}