:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --bg-input: #1e2a4a;
    --bg-message-self: #0f3460;
    --bg-message-other: #1e2a4a;
    --bg-hover: #1e2a4a;
    --bg-active: #0f3460;
    --text-primary: #e4e6eb;
    --text-secondary: #b0b3b8;
    --text-muted: #6b7280;
    --accent: #4f8cff;
    --accent-hover: #3a7aee;
    --accent-light: rgba(79,140,255,0.12);
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #ef4444;
    --border: #2d3748;
    --shadow: 0 2px 12px rgba(0,0,0,0.25);
    --radius: 8px;
    --radius-lg: 16px;
    --sidebar-width: 320px;
    --header-height: 56px;
    --input-height: 64px;
    --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.2s ease;
    --neural-rgb: 120, 140, 200;
}

/* ===== ROL BAZLI RENK — tekniker mavi, musteri yesil ===== */
body[data-role="technician"], body[data-role="admin"] {
    --accent: #4f8cff;
    --accent-hover: #3a7aee;
    --accent-light: rgba(79,140,255,0.12);
    --bg-message-self: #0f3460;
    --bg-active: #0f3460;
    --neural-rgb: 79, 140, 255;
}

body[data-role="customer"] {
    --accent: #10b981;
    --accent-hover: #059669;
    --accent-light: rgba(16,185,129,0.14);
    --bg-message-self: #0f3d2e;
    --bg-active: #123d30;
    --bg-tertiary: #103029;
    --neural-rgb: 16, 185, 129;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --bg-tertiary: #e5e7eb;
    --bg-input: #f9fafb;
    --bg-message-self: #4f8cff;
    --bg-message-other: #f3f4f6;
    --bg-hover: #f3f4f6;
    --bg-active: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    overflow-x: hidden;
    max-width: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh; /* mobil: URL cubugu dahil olmasin */
    overflow: hidden;
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    height: 100dvh;
    background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
    position: relative;
    overflow: hidden;
}

.login-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.login-card {
    position: relative;
    z-index: 1;
    background: rgba(22, 33, 62, 0.78);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 380px;
    max-width: calc(100vw - 28px);
    box-shadow: var(--shadow);
}

[data-theme="light"] .login-card { background: rgba(255,255,255,0.82); }

.login-brand {
    text-align: center;
    margin-bottom: 28px;
}

.serkon-logo {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--text-primary);
}

.serkon-logo .ai-text {
    color: #ef4444;
    text-shadow: 0 0 8px rgba(239,68,68,0.95), 0 0 22px rgba(239,68,68,0.55), 0 0 44px rgba(239,68,68,0.22);
}

.login-card .login-brand p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 10px;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.btn-login-icon {
    height: 48px;
}

.btn-login-icon svg { display: block; }

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border var(--transition);
}

.form-group input:focus {
    border-color: var(--accent);
}

/* ===== ICON-PREFIXED INPUTS (login) ===== */
.input-icon-wrap {
    position: relative;
}

.input-icon-wrap .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.input-icon-wrap input {
    padding-left: 44px;
}

.input-icon-wrap input:focus + .input-icon,
.input-icon-wrap:focus-within .input-icon {
    color: var(--accent);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    width: 100%;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.login-error {
    color: var(--danger);
    font-size: 13px;
    margin-top: 12px;
    display: none;
}

/* ===== MAIN LAYOUT ===== */
.app-container {
    display: none;
    height: 100vh;
    height: 100dvh;
}

.app-container.active { display: flex; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-badge.admin { background: rgba(239,68,68,0.15); color: var(--danger); }
.user-badge.technician { background: rgba(79,140,255,0.15); color: var(--accent); }
.user-badge.customer { background: rgba(52,211,153,0.15); color: var(--success); }

.sidebar-search {
    padding: 12px 16px;
}

.sidebar-search input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}

.sidebar-search input:focus { border-color: var(--accent); }

.conversation-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.conv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: var(--bg-active); }
.conv-item.unassigned { opacity: 0.5; }
.unassigned-tag {
    font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
    color: var(--warning); border: 1px solid var(--warning); border-radius: 4px;
    padding: 0 4px; margin-left: 6px; opacity: 0.8;
}

.conv-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: var(--accent);
    flex-shrink: 0;
    position: relative;
}

.conv-avatar .online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success);
    border: 2px solid var(--bg-secondary);
}

.conv-info {
    flex: 1;
    min-width: 0;
}

.conv-info-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.conv-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-time {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.conv-preview {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-unread {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-footer .user-info {
    font-size: 12px;
    color: var(--text-secondary);
}

.sidebar-footer .user-info strong {
    display: block;
    color: var(--text-primary);
    font-size: 13px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    font-size: 16px;
}

.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Yeni konusma ikon butonu (header) */
.btn-new-conv-icon {
    color: var(--accent);
    border-color: transparent;
    background: transparent;
}
.btn-new-conv-icon:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.sidebar-header-actions { display: flex; align-items: center; gap: 6px; }

/* Admin (gear) butonu — yalnizca admin rolunde gorunur */
#btnAdmin { display: none; border-color: transparent; background: transparent; }
body[data-role="admin"] #btnAdmin { display: flex; }
#btnAdmin:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ===== YONETIM PANELI ===== */
.admin-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 250;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}

.admin-panel {
    width: min(1500px, 96vw);
    height: 92vh;
    max-width: 96vw;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.admin-header h2 { font-size: 17px; font-weight: 700; }

.admin-tabs { display: flex; gap: 4px; padding: 10px 16px 0; border-bottom: 1px solid var(--border); }
.admin-tab {
    padding: 9px 16px; font-size: 13px; font-weight: 600;
    background: transparent; border: none; border-bottom: 2px solid transparent;
    color: var(--text-secondary); cursor: pointer;
}
.admin-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.admin-tab:disabled { opacity: 0.4; cursor: not-allowed; }

.admin-body { flex: 1; min-height: 0; padding: 18px 20px; overflow: hidden; }
.admin-tabpane { height: 100%; display: flex; flex-direction: column; min-height: 0; }

.admin-form { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.admin-form input {
    flex: 1; min-width: 160px; padding: 10px 14px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text-primary); font-size: 14px; outline: none;
}
.admin-form input:focus { border-color: var(--accent); }

.admin-list { display: flex; flex-direction: column; gap: 10px; }

/* ===== MASTER-DETAIL SPLIT ===== */
.admin-split { display: flex; gap: 16px; align-items: stretch; flex: 1; min-height: 0; }
.admin-master { flex: 1.25; min-width: 0; height: 100%; overflow-y: auto; }
.admin-detail { flex: 1; min-width: 0; border-left: 1px solid var(--border); padding-left: 16px; height: 100%; overflow-y: auto; }
.detail-empty { color: var(--text-muted); font-size: 13px; padding: 20px 4px; text-align: center; }

/* ===== SWITCH (aktif/pasif) ===== */
.switch { width: 38px; height: 20px; border-radius: 11px; background: #3a4256; position: relative; cursor: pointer; transition: background .2s; display: inline-block; vertical-align: middle; flex-shrink: 0; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #cbd5e1; transition: left .2s, background .2s; }
.switch.on { background: rgba(52,211,153,0.4); }
.switch.on::after { left: 20px; background: var(--success); }

/* ===== ADMIN GRID (musteri tablosu) ===== */
.admin-grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-grid thead th {
    text-align: left; padding: 8px 10px; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.admin-grid td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-grid tr.crow { cursor: pointer; }
.admin-grid tr.crow:hover { background: var(--bg-hover); }
.admin-grid tr.crow.inactive { opacity: 0.5; }
.admin-grid .cname { font-weight: 600; color: var(--text-primary); }
.admin-grid .cexpand { color: var(--text-muted); font-size: 11px; transition: transform 0.15s; display: inline-block; }
.admin-grid tr.crow.open .cexpand { transform: rotate(90deg); }
.admin-grid .pill { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--bg-input); color: var(--text-secondary); }
.admin-grid .pill.on { background: rgba(52,211,153,0.15); color: var(--success); }
.admin-grid .pill.off { background: rgba(107,114,128,0.15); color: var(--text-muted); }
.admin-grid .rowbtn {
    font-size: 11px; padding: 4px 9px; border-radius: 6px; cursor: pointer; white-space: nowrap;
    border: 1px solid var(--border); background: var(--bg-tertiary); color: var(--text-secondary);
}
.admin-grid .rowbtn:hover { color: var(--text-primary); }

/* Detay satiri (operatorler) */
.detail-cell { background: var(--bg-primary); padding: 14px 16px !important; }
.detail-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 10px; }
.op-add-form { display: flex; gap: 8px; margin-bottom: 12px; }
.op-add-form input { flex: 1; padding: 8px 12px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; color: var(--text-primary); font-size: 13px; outline: none; }
.op-add-form button { padding: 8px 14px; border-radius: 6px; border: none; background: var(--accent); color: #fff; font-size: 13px; cursor: pointer; }

.op-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.op-row:last-child { border-bottom: none; }
.op-name { font-weight: 600; font-size: 13px; min-width: 140px; }
.op-guid { flex: 1; font-family: 'Consolas', monospace; font-size: 11px; color: var(--text-secondary); word-break: break-all; user-select: all; }

/* GUID kopya/yenile butonlari */
.gbtn { background: var(--bg-tertiary); border: 1px solid var(--border); color: var(--text-secondary); border-radius: 6px; padding: 5px 9px; font-size: 11px; cursor: pointer; white-space: nowrap; }
.gbtn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ===== TEKNIKER KARTLARI ===== */
.tech-card { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tech-card.inactive { opacity: 0.55; }
.tech-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tech-name { font-size: 14px; font-weight: 700; }
.tech-user { font-size: 12px; color: var(--text-muted); margin-left: 8px; font-weight: 500; }
.tech-assign-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin: 10px 0 6px; }
.tech-companies { display: flex; flex-wrap: wrap; gap: 8px; }
.tech-chk { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 5px 10px; border-radius: 14px; background: var(--bg-tertiary); border: 1px solid var(--border); cursor: pointer; color: var(--text-secondary); }
.tech-chk.sel { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

/* Secili satir vurgusu */
.admin-grid tr.crow.selected { background: var(--accent-light); }
.admin-grid tr.crow.selected .cname { color: var(--accent); }

/* Detay paneli basligi */
.detail-head { font-size: 14px; font-weight: 700; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.detail-head small { display: block; font-size: 11px; font-weight: 500; color: var(--text-muted); margin-top: 2px; }

/* Operator ilk sifre bilgi kutusu (tek seferlik) */
.op-initpw {
    background: rgba(52,211,153,0.12); border: 1px solid rgba(52,211,153,0.4);
    border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; font-size: 12px; color: var(--text-primary);
}
.op-initpw b { color: var(--success); font-family: 'Consolas', monospace; }
.op-initpw .hint { display: block; color: var(--text-secondary); margin-top: 4px; font-size: 11px; }

/* Tekniker atama satirlari (detay panelinde) */
.assign-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 9px 4px; border-bottom: 1px solid var(--border);
}
.assign-row:last-child { border-bottom: none; }
.assign-row .ac-name { font-size: 13px; }

/* ===== NEW CONVERSATION BUTTON ===== */
.btn-new-conv {
    margin: 12px 16px;
    padding: 8px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    cursor: pointer;
    transition: background var(--transition);
}

.btn-new-conv:hover { background: var(--accent-hover); }

/* ===== CONVERSATION FILTERS ===== */
.conv-filters {
    display: flex;
    gap: 6px;
    padding: 0 16px 10px;
}

.conv-filter {
    flex: 1;
    padding: 6px 4px;
    font-size: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.conv-filter:hover { color: var(--text-primary); }
.conv-filter.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ===== CHAT PANEL ===== */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header {
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-info h3 {
    font-size: 15px;
    font-weight: 500;
}

.chat-header-info .status-text {
    font-size: 12px;
    color: var(--text-muted);
}

.chat-header-info .status-text.online { color: var(--success); }

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.active { background: rgba(52,211,153,0.15); color: var(--success); }
.status-badge.resolved { background: rgba(107,114,128,0.15); color: var(--text-muted); }

/* ===== MESSAGES AREA ===== */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.msg-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 8px;
}

.msg-group.self { align-items: flex-end; }
.msg-group.other { align-items: flex-start; }

.msg-sender {
    font-size: 11px;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 2px;
}

.msg-bubble {
    max-width: 65%;
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    position: relative;
}

.msg-group.self .msg-bubble {
    background: var(--bg-message-self);
    border-bottom-right-radius: 4px;
}

[data-theme="light"] .msg-group.self .msg-bubble { color: #fff; }

.msg-group.other .msg-bubble {
    background: var(--bg-message-other);
    border-bottom-left-radius: 4px;
}

.msg-bubble .msg-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 4px;
}

.msg-time {
    font-size: 10px;
    color: var(--text-muted);
}

.msg-status {
    font-size: 12px;
}

.msg-status.sent { color: var(--text-muted); }
.msg-status.delivered { color: var(--text-secondary); }
.msg-status.read { color: var(--accent); }

.msg-system {
    text-align: center;
    padding: 8px 16px;
    font-size: 12px;
    color: var(--text-muted);
}

.msg-date-divider {
    text-align: center;
    padding: 12px 0;
    font-size: 12px;
    color: var(--text-muted);
    position: relative;
}

.msg-date-divider::before,
.msg-date-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: calc(50% - 60px);
    height: 1px;
    background: var(--border);
}

.msg-date-divider::before { left: 0; }
.msg-date-divider::after { right: 0; }

.typing-indicator {
    display: none;
    padding: 8px 16px;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

.typing-indicator.visible { display: block; }

/* ===== INPUT AREA ===== */
.input-area {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.input-area textarea {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    resize: none;
    min-height: 40px;
    max-height: 120px;
    outline: none;
    transition: border var(--transition);
}

.input-area textarea:focus { border-color: var(--accent); }

.btn-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
    flex-shrink: 0;
}

.btn-send:hover { background: var(--accent-hover); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-attach {
    flex-shrink: 0;
    font-size: 20px;
}

/* ===== ATTACHMENT PREVIEW ===== */
.attach-preview {
    padding: 8px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.attach-preview-info {
    flex: 1;
    min-width: 0;
}

.attach-preview-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attach-preview-size {
    font-size: 11px;
    color: var(--text-muted);
}

.attach-preview-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    object-fit: cover;
}

.attach-preview .btn-remove {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ===== UPLOAD PROGRESS ===== */
.upload-progress {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}

.upload-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    width: 0;
    transition: width 0.3s ease;
}

/* ===== MESSAGE ATTACHMENTS ===== */
.msg-attachment {
    margin-top: 6px;
}

.msg-attachment img {
    max-width: 280px;
    max-height: 200px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: opacity var(--transition);
}

.msg-attachment img:hover { opacity: 0.85; }

.msg-attachment-file {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0,0,0,0.15);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition);
    text-decoration: none;
    color: inherit;
}

.msg-attachment-file:hover { background: rgba(0,0,0,0.25); }

.msg-attachment-file .file-icon { font-size: 20px; }
.msg-attachment-file .file-name { font-size: 13px; font-weight: 500; }
.msg-attachment-file .file-size { font-size: 11px; color: var(--text-muted); }

/* ===== IMAGE LIGHTBOX ===== */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}

/* ===== EMPTY STATE ===== */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 12px;
}

.empty-state .icon { font-size: 48px; opacity: 0.3; }
.empty-state p { font-size: 14px; }

/* ===== CONNECTION STATUS BAR ===== */
.connection-bar {
    display: none;
    padding: 6px 16px;
    font-size: 12px;
    text-align: center;
    font-weight: 500;
}

.connection-bar.connecting { display: block; background: var(--warning); color: #000; }
.connection-bar.disconnected { display: block; background: var(--danger); color: #fff; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { width: 100%; position: absolute; z-index: 10; height: 100%; min-width: 0; }
    .sidebar.hidden { display: none; }
    .chat-panel { width: 100%; }
    .msg-bubble { max-width: 85%; }
    .btn-back { display: flex !important; }

    /* Dokunmatik hedefler biraz buyusun */
    .btn-icon { width: 40px; height: 40px; }
    .input-area { padding: 10px 12px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
    .sidebar-footer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
    .messages-area { padding: 14px 12px; }
    .chat-header { padding: 0 12px; }
    .sidebar-header, .sidebar-search { padding-left: 12px; padding-right: 12px; }

    /* SOS butonu mobilde biraz daha belirgin */
    .sos-btn { width: 36px; height: 36px; }

    /* Resim ekleri ekrana sigsin */
    .msg-attachment img { max-width: 72vw; }

    /* ===== YONETIM PANELI — mobilde tam ekran + dikey stack ===== */
    .admin-panel { width: 100vw; height: 100vh; height: 100dvh; max-width: 100vw; border-radius: 0; }
    .admin-body { padding: 12px; }
    .admin-header { padding: 12px 14px; }
    .admin-form { flex-direction: column; }
    .admin-form input, .admin-form .btn { width: 100%; }
    .admin-split { flex-direction: column; gap: 12px; }
    .admin-master, .admin-detail {
        height: auto; flex: none; max-height: 42vh;
        border-left: none; padding-left: 0;
    }
    .admin-detail { border-top: 1px solid var(--border); padding-top: 12px; }
    .admin-grid { font-size: 12px; }
    .admin-grid td, .admin-grid thead th { padding: 7px 6px; }
    .op-add-form { flex-wrap: wrap; }
    .op-row { flex-wrap: wrap; }
    .op-name { min-width: 0; width: 100%; }

    /* Modal/overlay kartlari */
    .confirm-box { width: calc(100vw - 28px); }
    .emergency-card { width: calc(100vw - 28px); }
    .login-card { padding: 28px 22px; }
}

@media (max-width: 768px) and (orientation: landscape) {
    .admin-master, .admin-detail { max-height: 60vh; }
}

.btn-back { display: none; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg-group { animation: fadeIn 0.2s ease; }

@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.typing-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    margin: 0 1px;
    animation: pulse 1.4s infinite;
}

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

/* ===== SOS / ACIL CAGRI BUTONU — header'da, AKTIF'in solunda (yalnizca musteri) ===== */
.sos-btn {
    display: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    border: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 0 0 0 rgba(239,68,68,0.55);
    animation: sosPulse 1.6s ease-in-out infinite;
    transition: transform 0.12s;
}

body[data-role="customer"] .sos-btn { display: flex; }

.sos-btn:hover { transform: scale(1.08); }
.sos-btn:active { transform: scale(0.94); }
.sos-btn.sent { animation: none; opacity: 0.6; }

@keyframes sosPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.5); }
    50% { box-shadow: 0 0 0 7px rgba(239,68,68,0); }
}

/* AKTIF rozeti — yanip sonen yesil sinyal isigi */
.status-badge.active::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px var(--success), 0 0 2px var(--success);
    margin-right: 6px;
    vertical-align: middle;
    animation: signalBlink 1.1s ease-in-out infinite;
}

.status-badge.resolved::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    margin-right: 6px;
    vertical-align: middle;
}

@keyframes signalBlink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.25; transform: scale(0.7); }
}

/* ===== ACIL UYARI OVERLAY (tekniker) ===== */
.emergency-overlay {
    position: fixed;
    inset: 0;
    background: rgba(80,0,0,0.55);
    backdrop-filter: blur(3px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}

.emergency-card {
    width: 420px;
    max-width: calc(100vw - 40px);
    background: var(--bg-secondary);
    border: 2px solid var(--danger);
    border-radius: var(--radius-lg);
    padding: 28px;
    text-align: center;
    box-shadow: 0 0 0 4px rgba(239,68,68,0.25), 0 20px 60px rgba(0,0,0,0.6);
    animation: emgShake 0.5s ease;
}

.emergency-icon {
    width: 84px;
    height: 84px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: rgba(239,68,68,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--danger);
    animation: sosPulse 1s ease-in-out infinite;
}

.emergency-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--danger);
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.emergency-info { font-size: 15px; color: var(--text-primary); margin-bottom: 4px; }
.emergency-info strong { color: var(--text-primary); }
.emergency-sub { font-size: 13px; color: var(--text-secondary); margin-bottom: 22px; }

.emergency-actions { display: flex; gap: 10px; }
.emergency-actions button { flex: 1; padding: 12px; border-radius: var(--radius); font-size: 14px; font-weight: 700; cursor: pointer; border: none; }
.emergency-actions .emg-view { background: var(--danger); color: #fff; }
.emergency-actions .emg-view:hover { filter: brightness(1.1); }
.emergency-actions .emg-close { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border); }

@keyframes emgShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

/* Acil mesaj baloncugu */
.msg-bubble.alert-bubble {
    background: rgba(239,68,68,0.18) !important;
    border: 1px solid rgba(239,68,68,0.45);
    font-weight: 700;
}

/* ===== UNREAD DOT ===== */
.conv-unread-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
    align-self: center;
}

/* ===== CONVERSATION GROUP (firma bazinda) ===== */
.conv-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 1;
}

.conv-group-header:hover { filter: brightness(1.1); }
.conv-group-header .cg-chevron { font-size: 10px; color: var(--text-secondary); width: 12px; }
.conv-group-header .cg-name { flex: 1; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-group-header .cg-count {
    font-size: 11px; color: var(--text-secondary);
    background: var(--bg-input); border-radius: 10px; padding: 1px 8px;
}

.conv-item.grouped { padding-left: 28px; }

/* ===== CONFIRM MODAL ===== */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.12s ease;
}

.confirm-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 360px;
    max-width: calc(100vw - 40px);
    box-shadow: var(--shadow);
}

.confirm-box h3 { font-size: 16px; margin-bottom: 8px; color: var(--text-primary); }
.confirm-box p { font-size: 13px; color: var(--text-secondary); margin-bottom: 20px; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }
.confirm-actions .confirm-cancel { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border); }
.confirm-actions .confirm-ok { background: var(--danger); color: #fff; }
.confirm-actions .confirm-ok:hover { filter: brightness(1.1); }

/* ===== CONTEXT MENU ===== */
.ctx-menu {
    position: fixed;
    z-index: 300;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 6px;
    min-width: 180px;
    animation: fadeIn 0.12s ease;
}

.ctx-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 6px;
    user-select: none;
}

.ctx-menu-item:hover { background: var(--bg-hover); }
.ctx-menu-item.danger { color: var(--danger); }
.ctx-menu-item .ci-icon { font-size: 15px; width: 18px; text-align: center; }
.ctx-menu-sep { height: 1px; background: var(--border); margin: 4px 0; }

.ctx-reactions {
    display: flex;
    gap: 4px;
    padding: 6px 8px 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.ctx-reaction {
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: transform 0.1s ease, background 0.1s ease;
}

.ctx-reaction:hover { transform: scale(1.25); background: var(--bg-hover); }

/* ===== REPLY BAR (input) ===== */
.reply-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.reply-bar-content {
    flex: 1;
    min-width: 0;
    border-left: 3px solid var(--accent);
    padding-left: 10px;
}

.reply-bar-sender {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
}

.reply-bar-text {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== REPLY QUOTE (in bubble) ===== */
.msg-reply-quote {
    border-left: 3px solid var(--accent);
    padding: 4px 8px;
    margin-bottom: 6px;
    background: rgba(0,0,0,0.12);
    border-radius: 4px;
    font-size: 12px;
}

.msg-reply-quote .rq-sender { font-weight: 600; color: var(--accent); display: block; }
.msg-reply-quote .rq-text { color: var(--text-secondary); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== MESSAGE REACTIONS ===== */
.msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.msg-reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    border-radius: 11px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.1s ease;
}

.msg-reaction-pill:hover { background: var(--bg-hover); }
.msg-reaction-pill.mine { background: var(--accent-light); border-color: var(--accent); }
.msg-reaction-pill .rp-count { font-size: 11px; color: var(--text-secondary); }
