/* ============================================
   UPPERCHAT - Estilos Globais
   Tema: Dark Mode com cores Upperfy (roxo + laranja)
   Layout: Inspirado no Chatwoot
   ============================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ============================================
   VARIÁVEIS
   ============================================ */
:root {
  /* Cores Upperfy */
  --uc-roxo-escuro: #270949;
  --uc-roxo-medio: #87148C;
  --uc-roxo-vivo: #4F1295;
  --uc-laranja: #FF3D00;
  --uc-laranja-claro: #FF9200;
  
  /* Dark Theme */
  --uc-bg-primary: #111118;
  --uc-bg-secondary: #1a1a24;
  --uc-bg-tertiary: #222230;
  --uc-bg-hover: #2a2a3a;
  --uc-bg-active: #32324a;
  
  /* Bordas */
  --uc-border: #2d2d40;
  --uc-border-light: #3a3a50;
  
  /* Texto */
  --uc-text-primary: #e8e8f0;
  --uc-text-secondary: #9898b0;
  --uc-text-muted: #6a6a82;
  
  /* Gradientes animados */
  --uc-gradient-primary: linear-gradient(135deg, var(--uc-laranja), var(--uc-roxo-medio));
  --uc-gradient-sidebar: linear-gradient(180deg, var(--uc-roxo-escuro) 0%, #1a0a30 100%);
  
  /* Status */
  --uc-online: #22c55e;
  --uc-away: #f59e0b;
  --uc-offline: #6b7280;
  --uc-busy: #ef4444;
  
  /* Outros */
  --uc-radius: 10px;
  --uc-radius-sm: 6px;
  --uc-radius-lg: 16px;
  --uc-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --uc-transition: all 0.2s ease;
}

/* ============================================
   RESET
   ============================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  background: var(--uc-bg-primary);
  color: var(--uc-text-primary);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ============================================
   LOADING SCREEN
   ============================================ */
.uc-loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--uc-bg-primary);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.uc-loading-screen.visible {
  opacity: 1;
  visibility: visible;
}

.uc-loading-logo {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  margin-bottom: 24px;
  animation: uc-pulse 2s ease-in-out infinite;
}

@keyframes uc-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
}

.uc-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--uc-border);
  border-top-color: var(--uc-laranja);
  border-radius: 50%;
  animation: uc-spin 0.8s linear infinite;
  margin-bottom: 16px;
}

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

.uc-loading-text {
  font-size: 14px;
  color: var(--uc-text-secondary);
  font-weight: 500;
}

/* ============================================
   ANIMATED GRADIENT LINE (topo da página)
   ============================================ */
.uc-gradient-line {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, 
    var(--uc-laranja), 
    var(--uc-roxo-medio), 
    var(--uc-laranja-claro), 
    var(--uc-roxo-vivo),
    var(--uc-laranja)
  );
  background-size: 300% 100%;
  animation: uc-gradient-flow 4s ease infinite;
  z-index: 9998;
}

@keyframes uc-gradient-flow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ============================================
   LAYOUT PRINCIPAL (3 colunas estilo Chatwoot)
   ============================================ */
#app {
  display: flex;
  height: 100vh;
  width: 100%;
  padding-top: 3px; /* Espaço pra gradient line */
}

/* ============================================
   SIDEBAR (coluna 1 - navegação)
   ============================================ */
.uc-sidebar {
  width: 64px;
  min-width: 64px;
  background: var(--uc-gradient-sidebar);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  border-right: 1px solid var(--uc-border);
  position: relative;
}

/* Brilho sutil na borda direita */
.uc-sidebar::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, 
    transparent, 
    rgba(255, 61, 0, 0.3), 
    rgba(135, 20, 140, 0.3), 
    transparent
  );
}

.uc-sidebar-header {
  margin-bottom: 24px;
}

.uc-sidebar-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  transition: var(--uc-transition);
  cursor: pointer;
}

.uc-sidebar-logo:hover {
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(255, 61, 0, 0.3);
}

.uc-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.uc-nav-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  border-radius: var(--uc-radius);
  color: var(--uc-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--uc-transition);
  position: relative;
}

.uc-nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--uc-text-primary);
}

.uc-nav-btn.active {
  color: var(--uc-laranja);
  background: rgba(255, 61, 0, 0.12);
}

.uc-nav-btn.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 24px;
  background: var(--uc-gradient-primary);
  border-radius: 0 4px 4px 0;
}

.uc-sidebar-footer {
  margin-top: auto;
}

.uc-user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--uc-gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: var(--uc-transition);
}

.uc-user-avatar:hover {
  transform: scale(1.08);
  box-shadow: 0 0 16px rgba(255, 61, 0, 0.4);
}

.uc-user-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.uc-user-avatar span {
  font-weight: 700;
  font-size: 15px;
  color: white;
}

.uc-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--uc-roxo-escuro);
}

.uc-status-dot.online { background: var(--uc-online); }
.uc-status-dot.away { background: var(--uc-away); }
.uc-status-dot.offline { background: var(--uc-offline); }

/* ============================================
   CONVERSATIONS PANEL (coluna 2 - lista)
   ============================================ */
.uc-conversations-panel {
  width: 340px;
  min-width: 340px;
  background: var(--uc-bg-secondary);
  border-right: 1px solid var(--uc-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.uc-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
}

.uc-panel-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--uc-text-primary);
}

.uc-panel-actions {
  display: flex;
  gap: 4px;
}

.uc-icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: var(--uc-radius-sm);
  color: var(--uc-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--uc-transition);
}

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

/* Barra de busca */
.uc-search-bar {
  margin: 0 16px 12px;
  position: relative;
  display: flex;
  align-items: center;
}

.uc-search-bar svg {
  position: absolute;
  left: 12px;
  color: var(--uc-text-muted);
  pointer-events: none;
}

.uc-search-input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  border: 1px solid var(--uc-border);
  border-radius: var(--uc-radius);
  background: var(--uc-bg-tertiary);
  color: var(--uc-text-primary);
  font-family: inherit;
  font-size: 13px;
  transition: var(--uc-transition);
}

.uc-search-input::placeholder {
  color: var(--uc-text-muted);
}

.uc-search-input:focus {
  outline: none;
  border-color: var(--uc-roxo-medio);
  box-shadow: 0 0 0 3px rgba(135, 20, 140, 0.15);
}

/* Tabs de inbox */
.uc-inbox-tabs {
  display: flex;
  gap: 2px;
  padding: 0 16px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.uc-inbox-tabs::-webkit-scrollbar {
  display: none;
}

.uc-tab {
  padding: 6px 14px;
  border: none;
  background: transparent;
  border-radius: 20px;
  color: var(--uc-text-secondary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--uc-transition);
}

.uc-tab:hover {
  background: var(--uc-bg-hover);
  color: var(--uc-text-primary);
}

.uc-tab.active {
  background: rgba(255, 61, 0, 0.15);
  color: var(--uc-laranja);
}

/* Lista de conversas */
.uc-conversation-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--uc-border) transparent;
}

.uc-conversation-list::-webkit-scrollbar {
  width: 4px;
}

.uc-conversation-list::-webkit-scrollbar-thumb {
  background: var(--uc-border);
  border-radius: 4px;
}

/* Item de conversa */
.uc-conversation-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  cursor: pointer;
  transition: var(--uc-transition);
  border-left: 3px solid transparent;
  position: relative;
}

.uc-conversation-item:hover {
  background: var(--uc-bg-hover);
}

.uc-conversation-item.active {
  background: var(--uc-bg-active);
  border-left-color: var(--uc-laranja);
}

.uc-conversation-item.unread {
  background: rgba(255, 61, 0, 0.04);
}

.uc-conv-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--uc-bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--uc-laranja);
  flex-shrink: 0;
}

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

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

.uc-conv-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--uc-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

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

.uc-conv-badge {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: var(--uc-laranja);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

/* Empty state */
.uc-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px;
  text-align: center;
}

.uc-empty-state p {
  font-size: 14px;
  font-weight: 600;
  color: var(--uc-text-secondary);
  margin-top: 16px;
}

.uc-empty-state span {
  font-size: 12px;
  color: var(--uc-text-muted);
  margin-top: 6px;
  max-width: 220px;
}

/* ============================================
   MESSAGES PANEL (coluna 3 - central)
   ============================================ */
.uc-messages-panel {
  flex: 1;
  background: var(--uc-bg-primary);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Textura sutil no fundo do painel de mensagens */
.uc-messages-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 20% 50%, rgba(79, 18, 149, 0.05) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 80%, rgba(255, 61, 0, 0.03) 0%, transparent 50%);
  pointer-events: none;
}

/* Welcome screen */
.uc-welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  position: relative;
  z-index: 1;
}

.uc-welcome-icon {
  width: 100px;
  height: 100px;
  border-radius: 28px;
  margin-bottom: 24px;
  animation: uc-float 3s ease-in-out infinite;
  box-shadow: 0 16px 48px rgba(255, 61, 0, 0.2);
}

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

.uc-welcome-screen h2 {
  font-size: 24px;
  font-weight: 800;
  color: var(--uc-text-primary);
  margin-bottom: 8px;
}

.uc-welcome-screen p {
  font-size: 14px;
  color: var(--uc-text-secondary);
  margin-bottom: 32px;
}

.uc-welcome-info {
  display: flex;
  gap: 16px;
}

.uc-info-card {
  background: var(--uc-bg-secondary);
  border: 1px solid var(--uc-border);
  border-radius: var(--uc-radius-lg);
  padding: 20px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: var(--uc-transition);
}

.uc-info-card:hover {
  border-color: var(--uc-roxo-medio);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(135, 20, 140, 0.15);
}

.uc-info-number {
  font-size: 22px;
  font-weight: 800;
  background: var(--uc-gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-transform: capitalize;
}

.uc-info-label {
  font-size: 12px;
  color: var(--uc-text-muted);
  font-weight: 500;
}

/* ============================================
   SCROLLBAR GLOBAL
   ============================================ */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--uc-border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--uc-border-light);
}

/* ============================================
   ANIMAÇÕES DE ENTRADA
   ============================================ */
@keyframes uc-fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.uc-sidebar { animation: uc-fade-in 0.3s ease; }
.uc-conversations-panel { animation: uc-fade-in 0.4s ease; }
.uc-messages-panel { animation: uc-fade-in 0.5s ease; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .uc-conversations-panel {
    width: 100%;
    min-width: 100%;
  }
  .uc-messages-panel {
    display: none;
  }
  .uc-messages-panel.active {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 100;
  }
}
