/* Premium Dark/Glassmorphism Design System for Cloudflare Customer Service System */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #09090b;
  --bg-secondary: #18181b;
  --bg-tertiary: #27272a;
  
  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  
  --accent-client: linear-gradient(135deg, #0ea5e9, #2563eb);
  --accent-client-hover: linear-gradient(135deg, #38bdf8, #3b82f6);
  --accent-admin: linear-gradient(135deg, #8b5cf6, #6366f1);
  --accent-admin-hover: linear-gradient(135deg, #a78bfa, #818cf8);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --glow-shadow-client: 0 0 15px rgba(14, 165, 233, 0.35);
  --glow-shadow-admin: 0 0 15px rgba(99, 102, 241, 0.35);
  
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Glassmorphism Styles */
.glass-panel {
  background: rgba(24, 24, 27, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
}

/* Login Page Styling */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.15), transparent 45%),
              radial-gradient(circle at bottom left, rgba(14, 165, 233, 0.1), transparent 40%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 40px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.login-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #a78bfa, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 30px;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  background: rgba(9, 9, 11, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 16px;
  font-family: inherit;
  color: inherit;
  font-size: 15px;
  outline: none;
  transition: var(--transition-smooth);
}

.form-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}

.btn-submit {
  width: 100%;
  background: var(--accent-admin);
  border: none;
  border-radius: 8px;
  padding: 12px;
  color: white;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: var(--transition-smooth);
  margin-top: 10px;
}

.btn-submit:hover {
  background: var(--accent-admin-hover);
  box-shadow: var(--glow-shadow-admin);
  transform: translateY(-1px);
}

.btn-submit:active {
  transform: translateY(0);
}

/* Chat Client Layout */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
}

@media (max-width: 600px) {
  .chat-container {
    padding: 0;
  }
  .glass-panel {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
}

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

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

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-client);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: white;
}

.avatar.admin {
  background: var(--accent-admin);
}

.status-dot {
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px #10b981;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 75%;
}

.message-wrapper.self {
  align-self: flex-end;
}

.message-wrapper.other {
  align-self: flex-start;
}

.message-sender {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  padding-left: 4px;
}

.message-wrapper.self .message-sender {
  text-align: right;
  padding-right: 4px;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 15px;
  word-break: break-word;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  animation: messageIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

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

.message-wrapper.self .message-bubble {
  background: var(--accent-client);
  color: white;
  border-bottom-right-radius: 4px;
}

.message-wrapper.self.admin-sender .message-bubble {
  background: var(--accent-admin);
  color: white;
  border-bottom-right-radius: 4px;
}

.message-wrapper.other .message-bubble {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.message-bubble img {
  max-width: 100%;
  max-height: 240px;
  border-radius: 8px;
  margin-top: 4px;
  cursor: pointer;
  transition: opacity 0.2s ease;
  display: block;
}

.message-bubble img:hover {
  opacity: 0.9;
}

.message-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  align-self: flex-end;
}

.message-wrapper.other .message-time {
  align-self: flex-start;
  padding-left: 4px;
}

.chat-input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chat-input-container {
  flex: 1;
  position: relative;
  background: rgba(9, 9, 11, 0.5);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  display: flex;
  align-items: center;
  padding: 6px 12px;
  transition: var(--transition-smooth);
}

.chat-input-container:focus-within {
  border-color: #0ea5e9;
  box-shadow: 0 0 10px rgba(14, 165, 233, 0.15);
}

.admin-input-theme:focus-within {
  border-color: #6366f1;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.15);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  padding: 8px;
  font-family: inherit;
  font-size: 15px;
  resize: none;
  max-height: 120px;
  min-height: 24px;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

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

.btn-send {
  background: var(--accent-client);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-send:hover {
  background: var(--accent-client-hover);
  box-shadow: var(--glow-shadow-client);
  transform: scale(1.05);
}

.btn-send.admin-theme {
  background: var(--accent-admin);
}

.btn-send.admin-theme:hover {
  background: var(--accent-admin-hover);
  box-shadow: var(--glow-shadow-admin);
}

/* Image Preview Lightbox */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: zoom-out;
  opacity: 0;
  transition: opacity 0.25s ease-out;
}

.lightbox.show {
  display: flex;
  opacity: 1;
}

.lightbox-content {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.1, 0.8, 0.25, 1);
  cursor: default;
}

.lightbox.show .lightbox-content {
  transform: scale(1);
}

/* Sleep Mode Overlay */
.sleep-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(9, 9, 11, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 999;
  border-radius: 16px;
  padding: 30px;
  text-align: center;
}

.sleep-overlay.show {
  display: flex;
}

.sleep-icon {
  font-size: 48px;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.sleep-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.sleep-desc {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
  max-width: 320px;
}

.btn-wake {
  background: var(--accent-client);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 10px 24px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-wake:hover {
  box-shadow: var(--glow-shadow-client);
  transform: scale(1.05);
}

.btn-wake.admin-theme {
  background: var(--accent-admin);
}

.btn-wake.admin-theme:hover {
  box-shadow: var(--glow-shadow-admin);
}

/* Admin Dashboard Layout */
.admin-layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
}

.admin-sidebar {
  width: 320px;
  border-right: 1px solid var(--border-color);
  background: rgba(24, 24, 27, 0.4);
  display: flex;
  flex-direction: column;
}

@media (max-width: 768px) {
  .admin-sidebar {
    width: 80px;
  }
  .admin-sidebar .room-info,
  .admin-sidebar .sidebar-header h2,
  .admin-sidebar .btn-create-room span,
  .admin-sidebar .room-meta {
    display: none;
  }
  .admin-sidebar .btn-create-room {
    padding: 12px;
    justify-content: center;
  }
}

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

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

.btn-create-room {
  background: var(--accent-admin);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition-smooth);
  width: calc(100% - 40px);
  margin: 16px 20px;
}

.btn-create-room:hover {
  background: var(--accent-admin-hover);
  box-shadow: var(--glow-shadow-admin);
}

.rooms-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 20px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.room-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: 1px solid transparent;
}

.room-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.room-item.active {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.2);
}

.room-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
}

.room-item.active .room-avatar {
  background: var(--accent-admin);
  color: white;
}

.room-content {
  flex: 1;
  min-width: 0;
}

.room-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

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

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

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

.unread-badge {
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: bold;
  border-radius: 10px;
  padding: 2px 6px;
  min-width: 18px;
  text-align: center;
}

.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  position: relative;
}

.admin-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  padding: 40px;
  text-align: center;
}

.admin-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  color: var(--text-muted);
}

/* Modal Styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.show {
  display: flex;
}

.modal-card {
  width: 90%;
  max-width: 480px;
  padding: 30px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 20px;
}

.link-result-container {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  margin-top: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.link-text {
  font-family: monospace;
  font-size: 13px;
  color: #38bdf8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.btn-copy {
  background: var(--accent-admin);
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  color: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-copy:hover {
  background: var(--accent-admin-hover);
}

/* WeChat-style Collapsible Announcement Banner */
.announcement-banner {
  background: rgba(245, 158, 11, 0.08);
  border-bottom: 1px solid rgba(245, 158, 11, 0.15);
  padding: 10px 20px;
  font-size: 13px;
  transition: var(--transition-smooth);
  overflow: hidden;
  position: relative;
}

.announcement-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-weight: 600;
  color: #fbbf24;
}

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

.announcement-body {
  margin-top: 6px;
  color: var(--text-secondary);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 0;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: hidden;
}

.announcement-banner.expanded .announcement-body {
  max-height: 200px;
  opacity: 1;
  overflow-y: auto;
  padding-bottom: 4px;
}

.announcement-arrow {
  font-size: 10px;
  transition: transform 0.3s ease;
  color: var(--text-muted);
}

.announcement-banner.expanded .announcement-arrow {
  transform: rotate(180deg);
}

/* Quick Response (Quick Reply) Panel */
.quick-reply-panel {
  position: absolute;
  bottom: 74px;
  left: 20px;
  right: 20px;
  max-height: 240px;
  background: rgba(24, 24, 27, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  display: none;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
  animation: panelSlideUp 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.1);
}

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

.quick-reply-panel.show {
  display: flex;
}

.quick-reply-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
}

.quick-reply-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.quick-reply-item {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
}

.quick-reply-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.quick-reply-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.quick-reply-delete {
  opacity: 0;
  color: #ef4444;
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
  transition: opacity 0.2s ease;
}

.quick-reply-item:hover .quick-reply-delete {
  opacity: 1;
}

.quick-reply-add-box {
  padding: 8px 12px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
}

.btn-mini {
  background: var(--accent-admin);
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  color: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-mini:hover {
  background: var(--accent-admin-hover);
}
