﻿/* ============================================
   Type2Work Support Admin — Modern UI v4
   ============================================ */

:root {
  --brand-primary: #128c7e;
  --brand-primary-dark: #075e54;
  --brand-accent: #25d366;
  --brand-purple: #6c63ff;
  --brand-gradient: linear-gradient(135deg, #128c7e 0%, #25d366 100%);
  --brand-gradient-soft: linear-gradient(135deg, rgba(18, 140, 126, 0.12), rgba(37, 211, 102, 0.08));

  --wa-bg-primary: #e5ddd5;
  --wa-bg-secondary: #f0f2f5;
  --wa-bg-white: #ffffff;
  --wa-bg-green: #dcf8c6;
  --wa-text-primary: #111b21;
  --wa-text-secondary: #667781;
  --wa-text-muted: #8696a0;
  --wa-border: #e9edef;
  --wa-green: #25d366;
  --wa-green-dark: #128c7e;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.18);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 999px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

body {
  color: var(--wa-text-primary);
  background: var(--wa-bg-secondary);
  display: flex;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* ========== LAYOUT ========== */
.sidebar {
  width: 380px;
  min-width: 300px;
  background: var(--wa-bg-white);
  display: flex;
  flex-direction: column;
  z-index: 10;
  border-right: 1px solid var(--wa-border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  height: 100vh;
  background: var(--wa-bg-primary);
}

#content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  height: 100vh;
}

/* ========== SIDEBAR HEADER ========== */
.sidebarHeader {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: var(--brand-gradient);
  color: white;
  flex-shrink: 0;
}

.brandMark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  backdrop-filter: blur(8px);
}

.sidebarBrandText {
  flex: 1;
  min-width: 0;
}

.sidebarTitle {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebarSubtitle {
  font-size: 12px;
  opacity: 0.85;
  font-weight: 500;
}

.threadCountBadge {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.22);
  color: white;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ========== SIDEBAR SEARCH ========== */
.sidebarSearchWrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 14px;
  padding: 0 14px;
  height: 42px;
  background: var(--wa-bg-secondary);
  border: 1px solid var(--wa-border);
  border-radius: var(--radius-full);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.sidebarSearchWrap:focus-within {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(18, 140, 126, 0.12);
}

.searchIcon {
  font-size: 14px;
  opacity: 0.55;
}

.sidebarSearchInput {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--wa-text-primary);
  outline: none;
}

.sidebarSearchInput::placeholder {
  color: var(--wa-text-muted);
}

/* ========== THREAD LIST ========== */
.threadList {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: #cbd5db transparent;
}

.loadingThreads,
.emptyThreads {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  color: var(--wa-text-muted);
  text-align: center;
  font-size: 14px;
}

.emptyThreads.error {
  color: #ef4444;
}

.loadingSpinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--wa-border);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.userItem {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--wa-border);
  background: var(--wa-bg-white);
  transition: background 0.15s, transform 0.15s;
  position: relative;
}

.userItem::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--brand-accent);
  transform: scaleY(0);
  transition: transform 0.2s ease;
  border-radius: 0 4px 4px 0;
}

.userItem:hover {
  background: #f7f8f8;
}

.userItem.active {
  background: var(--brand-gradient-soft);
}

.userItem.active::before,
.userItem:hover::before {
  transform: scaleY(1);
}

.userAvatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--brand-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(18, 140, 126, 0.25);
}

.userPreview {
  flex: 1;
  min-width: 0;
}

.userPreview strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--wa-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}

.userPreview div {
  font-size: 13px;
  color: var(--wa-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.userItem .right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.threadTime {
  font-size: 11px;
  color: var(--wa-text-muted);
  font-weight: 500;
}

.badge {
  background: var(--brand-accent);
  color: white;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.35);
}

/* ========== NO SELECTION ========== */
.noSelection {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background:
    radial-gradient(circle at 20% 30%, rgba(18, 140, 126, 0.08), transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(108, 99, 255, 0.06), transparent 40%),
    var(--wa-bg-primary);
}

.noSelectionCard {
  max-width: 420px;
  text-align: center;
  padding: 40px 32px;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow-md);
}

.noSelectionIconWrap {
  width: 88px;
  height: 88px;
  margin: 0 auto 20px;
  border-radius: 24px;
  background: var(--brand-gradient-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}

.noSelectionIcon {
  font-size: 44px;
}

.noSelectionTitle {
  font-size: 24px;
  font-weight: 700;
  color: var(--wa-text-primary);
  margin-bottom: 10px;
}

.noSelectionText {
  font-size: 15px;
  color: var(--wa-text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}

.noSelectionTips {
  list-style: none;
  text-align: left;
  font-size: 13px;
  color: var(--wa-text-muted);
}

.noSelectionTips li {
  padding: 8px 0 8px 24px;
  position: relative;
}

.noSelectionTips li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--brand-primary);
  font-weight: 700;
}

.noSelectionTips code {
  background: rgba(18, 140, 126, 0.1);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 12px;
}

/* ========== CHAT AREA ========== */
.chatArea {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100vh;
  background: var(--wa-bg-primary);
}

.chatHeader {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--wa-bg-white);
  border-bottom: 1px solid var(--wa-border);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  z-index: 10;
}

.backToUsersBtn {
  display: none;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--wa-bg-secondary);
  color: var(--wa-text-secondary);
  font-size: 18px;
  cursor: pointer;
}

.chatHeaderUser {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.chatHeaderAvatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: white;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.threadUser {
  min-width: 0;
}

.threadUserName {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: var(--wa-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.threadUserStatus {
  font-size: 12px;
  color: var(--brand-primary);
  font-weight: 500;
}

.threadMeta {
  font-size: 12px;
  color: var(--wa-text-muted);
  text-align: right;
}

.typingIndicator {
  color: var(--brand-accent);
  font-weight: 600;
}

/* ========== MESSAGES ========== */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background-color: var(--wa-bg-primary);
  background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 40h80M40 0v80' stroke='%23d4cdc4' stroke-width='0.5' opacity='0.35'/%3E%3C/svg%3E");
  scroll-behavior: smooth;
}

.msg {
  display: flex;
  flex-direction: column;
  max-width: min(68%, 520px);
  animation: messageIn 0.25s ease;
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.user { align-self: flex-start; }
.msg.admin { align-self: flex-end; }

.bubble {
  padding: 8px 10px 9px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  box-shadow: var(--shadow-sm);
}

.msg.user .bubble {
  background: var(--wa-bg-white);
  border-bottom-left-radius: 4px;
}

.msg.admin .bubble {
  background: var(--wa-bg-green);
  border-bottom-right-radius: 4px;
}

.msgMeta {
  font-size: 11px;
  color: var(--wa-text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.msg.admin .msgMeta { text-align: right; }

.readStatus.delivered { color: var(--wa-text-muted); }
.readStatus.read { color: #53bdeb; }

.imageWrap {
  margin-top: 6px;
  border-radius: 10px;
  overflow: hidden;
}

.imageWrap img {
  max-width: 100%;
  display: block;
  border-radius: 10px;
}

.imageSkeleton {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--wa-bg-secondary);
  color: var(--wa-text-muted);
  font-size: 13px;
}

/* ========== QUICK REPLIES ========== */
.quickRepliesBar {
  flex-shrink: 0;
  padding: 10px 14px 12px;
  background: linear-gradient(180deg, #fff 0%, #f8faf9 100%);
  border-top: 1px solid var(--wa-border);
}

.quickRepliesHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.quickRepliesLabel {
  font-size: 12px;
  font-weight: 700;
  color: var(--brand-primary-dark);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.quickRepliesList {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.quickRepliesList::-webkit-scrollbar { display: none; }

.quickReplyBtn {
  flex-shrink: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--brand-gradient-soft);
  color: var(--brand-primary-dark);
  border-color: rgba(18, 140, 126, 0.2);
}

.quickReplyBtn--payment {
  background: rgba(37, 211, 102, 0.1);
  border-color: rgba(37, 211, 102, 0.25);
  color: #0d7a44;
}

.quickReplyBtn--wallet {
  background: rgba(108, 99, 255, 0.1);
  border-color: rgba(108, 99, 255, 0.25);
  color: #4f46e5;
}

.quickReplyBtn--closing {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.2);
  color: #b91c1c;
}

.quickReplyBtn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  filter: brightness(0.98);
}

.quickReplyBtn:active {
  transform: scale(0.97);
}

.quickReplyBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========== FOOTER / INPUT ========== */
.floatingFooter {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: var(--wa-bg-secondary);
  border-top: 1px solid var(--wa-border);
  flex-shrink: 0;
}

.emojiBtn,
.floatingFileLabel {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--wa-bg-white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  color: var(--wa-text-secondary);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  transition: transform 0.15s;
}

.emojiBtn:hover,
.floatingFileLabel:hover {
  transform: scale(1.05);
}

.floatingFileLabel input[type="file"] {
  display: none;
}

.floatingInput {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
  padding: 11px 16px;
  border: 1px solid var(--wa-border);
  border-radius: var(--radius-full);
  background: var(--wa-bg-white);
  font-family: inherit;
  font-size: 14px;
  resize: none;
  outline: none;
  line-height: 1.4;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.floatingInput:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(18, 140, 126, 0.12);
}

.floatingSendBtn {
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(18, 140, 126, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}

.floatingSendBtn:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 18px rgba(18, 140, 126, 0.45);
}

.floatingSendBtn:active {
  transform: scale(0.96);
}

.floatingSendBtn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.imagePreviewContainer {
  display: flex;
  align-items: center;
  gap: 6px;
}

.imagePreview {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 8px;
}

.floatingSmallBtn {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--wa-text-muted);
  font-size: 16px;
}

/* ========== LOGIN OVERLAY ========== */
.overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, rgba(7, 94, 84, 0.92), rgba(18, 140, 126, 0.88));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
}

.loginBox {
  width: 100%;
  max-width: 400px;
  padding: 36px 32px;
  background: rgba(255, 255, 255, 0.97);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: loginPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes loginPop {
  from { opacity: 0; transform: scale(0.92) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.loginBrand {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 20px;
  background: var(--brand-gradient-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}

.loginTitle {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}

.loginSubtitle {
  font-size: 14px;
  color: var(--wa-text-secondary);
  margin-bottom: 20px;
}

.loginInput {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--wa-border);
  border-radius: var(--radius-md);
  font-size: 16px;
  margin-bottom: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.loginInput:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(18, 140, 126, 0.15);
}

.loginBtn {
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--brand-gradient);
  color: white;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 20px rgba(18, 140, 126, 0.35);
  transition: transform 0.15s;
}

.loginBtn:hover {
  transform: translateY(-1px);
}

.loginBtnArrow {
  font-size: 18px;
}

.help {
  margin-top: 16px;
  font-size: 12px;
  color: var(--wa-text-muted);
}

/* ========== IMAGE VIEWER ========== */
.imageViewerOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.imageViewerOverlay.open { opacity: 1; }

.imageViewerContent {
  position: relative;
  max-width: 92vw;
  max-height: 92vh;
}

.imageViewerImg {
  max-width: 92vw;
  max-height: 85vh;
  border-radius: 8px;
}

.imageViewerClose {
  position: absolute;
  top: -40px;
  right: 0;
  background: transparent;
  border: none;
  color: white;
  font-size: 32px;
  cursor: pointer;
}

.imageViewerDownload {
  display: inline-block;
  margin-top: 12px;
  color: white;
  font-size: 14px;
}

/* ========== MOBILE ========== */
.mobileMenuToggle,
.sidebarOverlay {
  display: none;
}

@media (max-width: 768px) {
  body {
    flex-direction: column;
    position: fixed;
    inset: 0;
  }

  .sidebar {
    position: fixed;
    inset: 0;
    width: 100%;
    z-index: 1000;
    transform: translateX(0);
  }

  .sidebar.hidden {
    transform: translateX(-100%);
  }

  .main {
    position: fixed;
    inset: 0;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 1001;
  }

  .main.chatActive {
    transform: translateX(0);
  }

  .backToUsersBtn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .chatHeader {
    padding-left: 56px;
  }

  .msg {
    max-width: 88%;
  }

  .floatingInput {
    font-size: 16px;
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}
