/* =========================================================================
   SUPPORT — WhatsApp widget + Ticket (kullanıcı & admin) stilleri
   ========================================================================= */

:root {
    --sw-green: #25d366;
    --sw-green-dark: #128c7e;
    --sw-green-darker: #075e54;
    --sw-bg: #ece5dd;
    --sw-shadow: 0 16px 48px rgba(15, 23, 42, .25);
}

/* ============================================================
   Floating Action Button (sağ alt köşe)
   ============================================================ */
.sw-root {
    position: fixed;
    right: clamp(16px, 3vw, 28px);
    bottom: clamp(16px, 3vw, 28px);
    z-index: 9000;
    font-family: inherit;
}

.sw-fab {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 0;
    padding: 0;
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    color: #fff;
    cursor: pointer;
    box-shadow:
        0 10px 24px rgba(37, 211, 102, .42),
        0 4px 10px rgba(15, 23, 42, .18),
        inset 0 1px 0 rgba(255, 255, 255, .25);
    transition: transform .22s cubic-bezier(.4, 0, .2, 1),
                box-shadow .22s ease,
                background .22s ease;
    overflow: hidden;
}
.sw-fab:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow:
        0 16px 32px rgba(37, 211, 102, .55),
        0 6px 14px rgba(15, 23, 42, .22),
        inset 0 1px 0 rgba(255, 255, 255, .3);
}
.sw-fab:active { transform: translateY(0) scale(.98); }
.sw-fab:focus-visible {
    outline: none;
    box-shadow:
        0 0 0 4px rgba(37, 211, 102, .35),
        0 12px 24px rgba(37, 211, 102, .45);
}

/* iki ikon üst üste; opacity + scale ile geçiş */
.sw-fab-icon {
    position: absolute;
    width: 28px;
    height: 28px;
    transition: opacity .25s cubic-bezier(.4, 0, .2, 1),
                transform .25s cubic-bezier(.4, 0, .2, 1);
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .15));
}
.sw-fab-icon-wa    { opacity: 1;  transform: scale(1) rotate(0); }
.sw-fab-icon-close { opacity: 0;  transform: scale(.5) rotate(-90deg); width: 22px; height: 22px; }

.sw-root.sw-open .sw-fab {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    box-shadow:
        0 10px 24px rgba(239, 68, 68, .4),
        0 4px 10px rgba(15, 23, 42, .2),
        inset 0 1px 0 rgba(255, 255, 255, .25);
}
.sw-root.sw-open .sw-fab-icon-wa    { opacity: 0; transform: scale(.5) rotate(90deg); }
.sw-root.sw-open .sw-fab-icon-close { opacity: 1; transform: scale(1) rotate(0); }

/* Pulse — FAB arkasında genişleyen halka, ikonların ALTINDA kalmalı */
.sw-fab-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
    box-shadow: 0 0 0 0 rgba(37, 211, 102, .55);
    animation: sw-pulse 2.4s ease-out infinite;
    z-index: 0;
}
.sw-fab-icon { z-index: 1; }
@keyframes sw-pulse {
    0%   { box-shadow: 0 0 0 0    rgba(37, 211, 102, .55); }
    70%  { box-shadow: 0 0 0 18px rgba(37, 211, 102, 0); }
    100% { box-shadow: 0 0 0 0    rgba(37, 211, 102, 0); }
}
.sw-root.sw-open .sw-fab-pulse { animation: none; opacity: 0; }

/* ============================================================
   Açılır chat panel
   ============================================================ */
.sw-panel {
    position: absolute;
    right: 0;
    bottom: 76px;
    width: min(360px, calc(100vw - 32px));
    max-height: min(640px, calc(100vh - 120px));
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--sw-shadow);
    transform-origin: bottom right;
    animation: sw-popin .25s cubic-bezier(.21, 1.02, .73, 1) both;
}
.sw-panel[hidden] { display: none; }

@keyframes sw-popin {
    from { opacity: 0; transform: translateY(10px) scale(.96); }
    to   { opacity: 1; transform: none; }
}

.sw-head {
    background: linear-gradient(135deg, var(--sw-green-darker) 0%, var(--sw-green-dark) 100%);
    color: #fff;
    padding: 16px 16px 18px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
}
.sw-head-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .2);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1);
}
.sw-head-avatar svg { width: 22px; height: 22px; }

.sw-head-text strong {
    display: block;
    font-size: 15px;
    line-height: 1.3;
    margin-bottom: 2px;
}
.sw-head-text span {
    display: block;
    font-size: 12.5px;
    opacity: .85;
}

.sw-close {
    background: rgba(255, 255, 255, .18);
    color: #fff;
    border: 0;
    width: 28px; height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s ease;
}
.sw-close:hover { background: rgba(255, 255, 255, .32); }

.sw-body {
    background:
        radial-gradient(circle at 20% 0%, rgba(255,255,255,.6), transparent 50%),
        var(--sw-bg);
    padding: 18px 16px 14px;
    flex: 1;
    overflow-y: auto;
}

.sw-bubble {
    background: #fff;
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
    position: relative;
    margin-bottom: 14px;
    margin-left: 4px;
    max-width: 92%;
}
.sw-bubble-tail {
    position: absolute;
    left: -7px; top: 12px;
    width: 10px; height: 10px;
    background: #fff;
    transform: rotate(45deg);
    border-radius: 2px;
    box-shadow: -1px 1px 1px rgba(15, 23, 42, .04);
}
.sw-welcome {
    margin: 0;
    color: #0f172a;
    font-size: 13.5px;
    line-height: 1.55;
    white-space: pre-line;
}

.sw-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    margin-left: 4px;
    margin-bottom: 14px;
    background: #fff;
    border-radius: 999px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
    font-size: 11.5px;
    color: #475569;
}
.sw-status .sw-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, .25);
}
.sw-status.sw-offline .sw-dot { background: #94a3b8; box-shadow: none; }

.sw-form { display: grid; gap: 8px; }
.sw-input-row { display: block; }

.sw-input,
.sw-textarea {
    width: 100%;
    padding: 11px 13px;
    border-radius: 12px;
    border: 1px solid #d1d5db;
    background: #fff;
    font-size: 13.5px;
    line-height: 1.4;
    font-family: inherit;
    color: #0f172a;
    box-sizing: border-box;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.sw-textarea { resize: vertical; min-height: 78px; }
.sw-input:focus,
.sw-textarea:focus {
    outline: none;
    border-color: var(--sw-green);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, .18);
}

.sw-send-btn {
    background: var(--sw-green);
    color: #fff;
    border: 0;
    border-radius: 999px;
    padding: 11px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background .15s ease, transform .15s ease;
}
.sw-send-btn:hover { background: #1ebe5b; transform: translateY(-1px); }
.sw-send-btn:disabled {
    background: #cbd5e1;
    color: #f8fafc;
    cursor: not-allowed;
    transform: none;
}

.sw-foot {
    padding: 10px 14px 12px;
    background: #fff;
    border-top: 1px solid #f1f5f9;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: 12px;
}
.sw-foot-link {
    color: #475569 !important;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    text-decoration: none;
}
.sw-foot-link:hover { color: var(--sw-green-dark) !important; text-decoration: underline; }
.sw-foot-link span { font-size: 13px; }

@media (max-width: 480px) {
    .sw-panel { width: calc(100vw - 24px); right: 0; }
    .sw-fab { width: 56px; height: 56px; }
    .sw-fab-icon { width: 26px; height: 26px; }
}

/* ============================================================
   Ticket — KPI kartları (Admin Tickets index)
   ============================================================ */
.tk-kpi {
    display: block;
    text-decoration: none !important;
    color: inherit !important;
    cursor: pointer;
    transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.tk-kpi:hover {
    transform: translateY(-2px);
    border-color: rgba(37, 99, 235, .35);
    box-shadow: 0 6px 14px rgba(37, 99, 235, .12);
}
.tk-kpi.active {
    border-color: var(--ab-primary, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

/* ============================================================
   Ticket Tablosu
   ============================================================ */
.tk-table .tk-numara {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 12.5px;
    color: var(--ab-primary, #2563eb);
    text-decoration: none;
    font-weight: 600;
}
.tk-table .tk-numara:hover { text-decoration: underline; }

.tk-table .tk-konu {
    color: var(--ab-ink, #0f172a) !important;
    font-weight: 500;
    text-decoration: none;
}
.tk-table .tk-konu:hover { color: var(--ab-primary, #2563eb) !important; }

.tk-yeni-rozet {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 7px;
    background: #ef4444;
    color: #fff;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .5px;
    vertical-align: middle;
    animation: sw-pulse-soft 2.4s ease-in-out infinite;
}
@keyframes sw-pulse-soft {
    0%, 100% { opacity: 1; }
    50% { opacity: .6; }
}

.tk-user strong { display: block; font-size: 13.5px; }
.tk-user small { font-size: 11.5px; }

.tk-kategori {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    background: #eef2ff;
    color: #4338ca;
    font-size: 11.5px;
    font-weight: 600;
}

/* ============================================================
   Ticket Detail (admin & user paylaşımlı)
   ============================================================ */
.tk-detail-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 18px;
    align-items: start;
}
@media (max-width: 900px) {
    .tk-detail-grid { grid-template-columns: 1fr; }
}

.tk-meta-list {
    margin: 0;
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 8px 12px;
    font-size: 13px;
}
.tk-meta-list dt {
    color: #64748b;
    font-weight: 500;
}
.tk-meta-list dd {
    margin: 0;
    color: var(--ab-ink, #0f172a);
}
.tk-hr {
    border: 0;
    border-top: 1px solid #e2e8f0;
    margin: 14px 0;
}

/* ============================================================
   Mesaj balonları (sohbet görünümü)
   ============================================================ */
.tk-mesajlar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px 2px 14px;
    max-height: 560px;
    overflow-y: auto;
}
.tk-msg {
    max-width: 78%;
    border-radius: 14px;
    padding: 10px 13px;
    font-size: 13.5px;
    line-height: 1.5;
    box-shadow: 0 1px 1px rgba(15, 23, 42, .04);
    word-wrap: break-word;
}
.tk-msg-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    font-size: 11.5px;
    color: #64748b;
    font-weight: 500;
}
.tk-msg-meta strong { color: inherit; font-weight: 700; }
.tk-msg-body {
    color: #0f172a;
    white-space: pre-wrap;
}

/* user → solda, açık zemin */
.tk-msg-user {
    align-self: flex-start;
    background: #f1f5f9;
    border-bottom-left-radius: 4px;
}
.tk-msg-user .tk-msg-meta { color: #475569; }

/* admin → sağda, mavi zemin */
.tk-msg-admin {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(37, 99, 235, .12) 0%, rgba(37, 99, 235, .06) 100%);
    border: 1px solid rgba(37, 99, 235, .15);
    border-bottom-right-radius: 4px;
}
.tk-msg-admin .tk-msg-meta strong { color: #1d4ed8; }

/* User view (Support/Detail) — admin/user yer değiştirir gibi:
   "Siz" sağda gösterilsin için tk-mesajlar-user-view varyantı */
.tk-mesajlar-user-view .tk-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(37, 99, 235, .12) 0%, rgba(37, 99, 235, .06) 100%);
    border: 1px solid rgba(37, 99, 235, .15);
    border-bottom-right-radius: 4px;
    border-bottom-left-radius: 14px;
}
.tk-mesajlar-user-view .tk-msg-admin {
    align-self: flex-start;
    background: #f1f5f9;
    border: 0;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 14px;
}

.tk-thread .ab-form { margin-top: 4px; }
