/* ==============================================================
   SPLIT MODE (50/50 Tela Dividida) - Bloco B
============================================================== */

/* Previne scroll na body para travar a viewport real */
body.split-mode {
  overflow: hidden !important;
  height: 100dvh !important;
}

/* 1. Esconder a Bottom Nav no Split Mode */
body.split-mode #bottom-nav {
  display: none !important;
}

/* 2. Forçar a planilha (sheet-view e home-view) para a metade superior da tela (50dvh) */
body.split-mode #home-view,
body.split-mode #sheet-view {
  flex: none !important;
  height: 50dvh !important;
  max-height: 50dvh !important;
  overflow-y: auto !important;
  padding-bottom: 60px; /* espaço pro action bar reduzido não tapar o ultimo lead */
}

/* 3. Ilha Flutuante Reduzida (Fica ancorada no equador: 50dvh do chão) */
body.split-mode #action-bar {
  top: 0 !important;
  bottom: 50dvh !important;
  margin: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  height: 50dvh !important;
  left: 0 !important;
  border-radius: 0 !important;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5) !important;
  z-index: 2000 !important;
  transition: bottom 0.2s ease-out, top 0.2s ease-out;
  justify-content: center !important;
  background:
    radial-gradient(ellipse at -10% -10%, rgba(160, 130, 210, 0.18) 0%, transparent 55%),
    linear-gradient(160deg, #0a0a0f 0%, #1a0e2e 40%, #3b1f5e 100%) !important;
}

body.split-mode #action-bar .ab-info {
  padding: 8px 12px !important;
}
body.split-mode #action-bar .ab-info-text {
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
}
body.split-mode #action-bar .ab-name {
  font-size: 14px !important;
}
body.split-mode #action-bar .ab-phone {
  font-size: 12px !important;
  opacity: 0.7;
}
/* Histórico e botões agora têm mais espaço, pois a ilha ocupa toda a metade superior */
body.split-mode #action-bar .ab-history {
  display: flex !important; /* Exibe o histórico */
}
body.split-mode #action-bar .ab-btns {
  padding: 12px 16px !important;
  gap: 10px !important;
}

/* Ocultar o botão de fechar original da ilha flutuante no modo dividido */
body.split-mode #action-bar .btn-close {
  display: none !important;
}

/* No split mode, a ilha reduzida prioriza o botão de Ligar. Etiquetas ficam compactas. */
body.split-mode #action-bar .abtn {
  padding: 6px !important;
}
body.split-mode #action-bar .abtn-call {
  font-size: 13px !important;
  grid-column: span 12 !important; /* Toma a linha inteira */
}

/* 4. Painel Inferior: Dialer / Chamada em andamento ocupando a base (50dvh) */
body.split-mode #dialer-view {
  display: block !important;
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 50dvh !important;
  max-height: 50dvh !important;
  z-index: 1999 !important;
  background: linear-gradient(180deg, #3b1f5e 0%, #000000 100%) !important;
  overflow-y: auto;
  border-top: none !important;
}

/* Redimensionamento dos elementos do discador para caberem em 50dvh */
body.split-mode #dialer-view .md-dialer {
  margin-top: 0 !important;
}
body.split-mode #dialer-view .md-pad {
  gap: 6px !important;
}
body.split-mode #dialer-view .md-key {
  height: 40px !important; /* Compacto */
}

/* 5. Botão Global 'X' de saída do Split Mode */
.split-close-btn {
  display: none;
  position: fixed;
  top: 15px;
  right: 15px;
  width: 40px;
  height: 40px;
  background: rgba(239, 68, 68, 0.9); /* Vermelho */
  color: white;
  border-radius: 50%;
  text-align: center;
  line-height: 40px;
  font-size: 20px;
  font-weight: bold;
  z-index: 99999;
  cursor: pointer;
  border: none;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
}
body.split-mode .split-close-btn {
  display: block;
}

/* ==============================================================
   CALL SPLIT PANEL (TELA B)
============================================================== */
#call-split-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 50dvh;
  z-index: 2001; /* Above dialer-view */
  background: linear-gradient(180deg, #3b1f5e 0%, #000000 100%);
  color: white;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 15px rgba(0,0,0,0.5);
  transition: background 0.3s ease;
  font-family: 'Inter', sans-serif;
}

/* Estado: Aguardando */
#call-split-panel.is-waiting {
  background: linear-gradient(180deg, #3b1f5e 0%, #000000 100%);
}

/* Header (Badge, Nome, Número, Progresso) */
.csp-header {
  padding: 16px 24px;
  text-align: center;
  position: relative;
}
.csp-mode-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  background: rgba(255,255,255,0.1);
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 12px;
  color: #a78bfa;
}
#call-split-panel.is-waiting .csp-mode-badge {
  color: #fff;
  background: rgba(0,0,0,0.2);
}
.csp-call-info {
  margin-bottom: 4px;
}
.csp-contact-name {
  font-size: 24px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.csp-contact-phone {
  font-size: 16px;
  opacity: 0.7;
}
.csp-progress {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.5;
}

/* Zonas de Timer/Status/Countdown (Flex 1 - Centro) */
.csp-timer-zone, .csp-countdown-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.csp-call-status {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1px;
  margin-bottom: 8px;
  color: #9ca3af;
}
.csp-timer {
  font-size: 32px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
}

/* Ring de Countdown (Espera) */
.csp-cd-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  opacity: 0.8;
  margin-bottom: 16px;
}
.csp-cd-ring {
  position: relative;
  width: 80px;
  height: 80px;
  margin-bottom: 16px;
}
.csp-cd-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.csp-cd-track {
  fill: none;
  stroke: rgba(255,255,255,0.2);
  stroke-width: 6;
}
.csp-cd-progress {
  fill: none;
  stroke: #fff;
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear;
}
.csp-cd-num {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 600;
}
.csp-btn-skip-wait {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* Controles Base (Botões de Ação) */
.csp-controls {
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 32px;
  padding-bottom: 40px; /* Safe area */
}
.csp-ctrl-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.csp-ctrl-btn svg {
  width: 28px;
  height: 28px;
}
.csp-ctrl-btn.active {
  background: #fff;
  color: #0f1115;
}
.csp-btn-end {
  background: #ef4444; /* Vermelho */
  width: 72px;
  height: 72px;
}
.csp-btn-end svg {
  width: 36px;
  height: 36px;
}
.csp-btn-end:active {
  background: #dc2626;
  transform: scale(0.95);
} 
 