/* ============================================================
   SOFTPHONE WIDGET
   ============================================================ */

.softphone-widget {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 280px;
  background: #1a1a2e;
  border: 1px solid #2d2d4e;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 9999;
  font-family: 'Inter', sans-serif;
  overflow: hidden;
  transition: all 0.2s ease;
}

.softphone-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #16213e;
  border-bottom: 1px solid #2d2d4e;
  cursor: move;
}

.softphone-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.softphone-dot.online  { background: #4DD9C0; box-shadow: 0 0 6px #4DD9C0; }
.softphone-dot.offline { background: #666; }
.softphone-dot.error   { background: #e74c3c; box-shadow: 0 0 6px #e74c3c; }

.softphone-header span:nth-child(2) {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: #e0e0e0;
}

.softphone-header-actions {
  display: flex;
  gap: 4px;
}

.softphone-vm-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.softphone-vm-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  opacity: 0.92;
}
.softphone-vm-count {
  margin-left: 2px;
  min-width: 14px;
  height: 14px;
  padding: 0 4px;
  border-radius: 999px;
  font-size: 10px;
  line-height: 14px;
  font-weight: 700;
  text-align: center;
  background: #4DD9C0;
  color: #102a43;
  display: none;
}
.softphone-vm-icon[data-vm-state="new"] .softphone-vm-count {
  display: inline-block;
}

.softphone-toggle-btn,
.softphone-close-btn {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}
.softphone-toggle-btn:hover,
.softphone-close-btn:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

.softphone-body {
  padding: 14px;
}

/* Dialer */
.softphone-number-input {
  width: 100%;
  background: #0f3460;
  border: 1px solid #2d2d4e;
  border-radius: 8px;
  color: #fff;
  font-size: 16px;
  padding: 8px 12px;
  margin-bottom: 10px;
  box-sizing: border-box;
  text-align: center;
  letter-spacing: 1px;
}
.softphone-number-input::placeholder { color: #666; font-size: 14px; letter-spacing: 0; }
.softphone-number-input:focus { outline: none; border-color: #4DD9C0; }

.softphone-dialpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.softphone-dialpad button {
  background: #0f3460;
  border: 1px solid #2d2d4e;
  border-radius: 8px;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  padding: 10px 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
  transition: background 0.15s;
}
.softphone-dialpad button span {
  font-size: 8px;
  font-weight: 400;
  color: #888;
  letter-spacing: 1px;
}
.softphone-dialpad button:hover { background: #1a4a80; }
.softphone-dialpad button:active { background: #4DD9C0; color: #000; }

.softphone-call-btn {
  width: 100%;
  background: #4DD9C0;
  color: #0a0a1a;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  padding: 11px;
  cursor: pointer;
  transition: background 0.15s;
}
.softphone-call-btn:hover { background: #3bc4ad; }

/* Incoming call */
.softphone-incoming {
  text-align: center;
  padding: 8px 0;
}

.softphone-caller-info {
  margin-bottom: 12px;
}

.softphone-caller-avatar {
  font-size: 36px;
  margin-bottom: 6px;
}

.softphone-caller-name {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 2px;
}

.softphone-caller-number {
  font-size: 13px;
  color: #888;
}

.softphone-incoming-label {
  font-size: 12px;
  color: #4DD9C0;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 14px;
  animation: pulse 1.5s infinite;
}

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

.softphone-incoming-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.softphone-answer-btn {
  background: #4DD9C0;
  color: #0a0a1a;
  border: none;
  border-radius: 50px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  flex: 1;
}
.softphone-answer-btn:hover { background: #3bc4ad; }

.softphone-reject-btn {
  background: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  flex: 1;
}
.softphone-reject-btn:hover { background: #c0392b; }

/* Active call */
.softphone-active {
  text-align: center;
  padding: 8px 0;
}

.softphone-timer {
  font-size: 28px;
  font-weight: 700;
  color: #4DD9C0;
  font-variant-numeric: tabular-nums;
  margin: 10px 0;
}

.softphone-active-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
}

.softphone-mute-btn {
  background: #0f3460;
  color: #fff;
  border: 1px solid #2d2d4e;
  border-radius: 50px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex: 1;
  transition: background 0.15s;
}
.softphone-mute-btn:hover { background: #1a4a80; }
.softphone-mute-btn.active { background: #e67e22; border-color: #e67e22; }

.softphone-hangup-btn {
  background: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  flex: 1;
}
.softphone-hangup-btn:hover { background: #c0392b; }

/* FAB button */
.softphone-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #4DD9C0;
  color: #0a0a1a;
  border: none;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(77,217,192,0.4);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
.softphone-fab.state-online {
  background: #4DD9C0;
  color: #0a0a1a;
  box-shadow: 0 4px 16px rgba(77,217,192,0.45);
}
.softphone-fab.state-offline {
  background: #7d8698;
  color: #f3f4f6;
  box-shadow: 0 4px 16px rgba(30,41,59,0.40);
}
.softphone-fab.state-dnd {
  background: #f2b44f;
  color: #1f2937;
  box-shadow: 0 4px 16px rgba(242,180,79,0.45);
}
.softphone-fab.state-error {
  background: #ef4444;
  color: #fff;
  box-shadow: 0 4px 16px rgba(239,68,68,0.45);
}
.softphone-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(77,217,192,0.6);
}

.softphone-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e74c3c;
  color: #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse 1s infinite;
}

@media (max-width: 900px) {
  .softphone-widget {
    left: 10px;
    right: 10px;
    width: auto;
    max-width: none;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 72px);
  }
  .softphone-body {
    max-height: min(70vh, 540px);
    overflow: auto;
  }
  .softphone-fab {
    right: 12px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  }
  .softphone-fab[data-state-label]::after {
    content: attr(data-state-label);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: -17px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(17,24,39,0.92);
    color: #f8fafc;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1;
    padding: 2px 6px;
    text-transform: uppercase;
  }
  .softphone-vm-label {
    display: none;
  }
}
